From: Chris Wilson Date: Fri, 18 Apr 2014 21:04:23 +0000 (-0300) Subject: drm/i915: Validate BDB section before reading X-Git-Tag: v4.9.8~6258^2~56^2~51 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d1f13fd261f4490b3b69c1da87711fd3813c2a9f;p=platform%2Fkernel%2Flinux-rpi3.git 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 Signed-off-by: Rodrigo Vivi Reviewed-by: Shobhit Kumar Signed-off-by: Daniel Vetter --- diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c index fba9efd..148d8a7 100644 --- a/drivers/gpu/drm/i915/intel_bios.c +++ b/drivers/gpu/drm/i915/intel_bios.c @@ -49,13 +49,19 @@ find_section(struct bdb_header *bdb, int section_id) total = bdb->bdb_size; /* walk the sections looking for section_id */ - while (index < total) { + while (index + 3 < total) { current_id = *(base + index); index++; + current_size = *((u16 *)(base + index)); index += 2; + + if (index + current_size > total) + return NULL; + if (current_id == section_id) return base + index; + index += current_size; }