소스 검색

drm/i915: Validate BDB section before reading

Make sure that the whole BDB section is within the MMIO region prior to
accessing it contents. That we don't read outside of the secion is left
up to the individual section parsers.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@gmail.com>
Reviewed-by: Shobhit Kumar <shobhit.kumar@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Chris Wilson 11 년 전
부모
커밋
d1f13fd261
1개의 변경된 파일7개의 추가작업 그리고 1개의 파일을 삭제
  1. 7 1
      drivers/gpu/drm/i915/intel_bios.c

+ 7 - 1
drivers/gpu/drm/i915/intel_bios.c

@@ -49,13 +49,19 @@ find_section(struct bdb_header *bdb, int section_id)
 	total = bdb->bdb_size;
 	total = bdb->bdb_size;
 
 
 	/* walk the sections looking for section_id */
 	/* walk the sections looking for section_id */
-	while (index < total) {
+	while (index + 3 < total) {
 		current_id = *(base + index);
 		current_id = *(base + index);
 		index++;
 		index++;
+
 		current_size = *((u16 *)(base + index));
 		current_size = *((u16 *)(base + index));
 		index += 2;
 		index += 2;
+
+		if (index + current_size > total)
+			return NULL;
+
 		if (current_id == section_id)
 		if (current_id == section_id)
 			return base + index;
 			return base + index;
+
 		index += current_size;
 		index += current_size;
 	}
 	}