]> git.baikalelectronics.ru Git - kernel.git/commit
drm/i915: Fix a potential integer overflow with framebuffers extending past 4 GiB
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 12 Sep 2018 18:04:43 +0000 (21:04 +0300)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Thu, 13 Sep 2018 19:42:51 +0000 (22:42 +0300)
commit45d32634a85eb7e4c498b4584dab25e0fb3dc634
tree75d170d31d31c786a170f6898ca30e11fc4d7121
parentdfc0dbe575177f7bcb98b60ca56a0192f28f6c67
drm/i915: Fix a potential integer overflow with framebuffers extending past 4 GiB

If we have framebuffers that are >= 4GiB in size we will overflow
the fb size check in intel_fill_fb_info().

Currently that is only possible with NV12 and CCS as offsets[1]
may be anything between 0 and 0xffffffff. offsets[0] is currently
required to be 0 so we can't hit the overflow with any single
plane format (thanks to max fb size of 8kx8k and max stride of
32 KiB).

In the future we may allow almost any framebuffer to exceed 4GiB
in size so we really should fix the overflow. Not that the overflow
is particularly dangerous. It's mostly just a sanity check against
insane userspace. The display engine can't write to memory anyway
so I suppose in the worst case we might anger the hw by attempting
scanout past the end of the ggtt, or we might scan out some data
that we're not supposed to see from other parts of the ggtt.

Note that triggering this overflow depends on the driver
aligning the fb height to the next tile boundary to push the
calculated size above 4GiB. With linear buffers the effective
tile height is one so that never happens, and the core already
has a check for 32bit overflow of offsets[]+pitches[]*height.

v2: Drop the unnecessary cast (Chris)

Testcase: igt/kms_big_fb/x-tiled-addfb-size-offset-overflow
Testcase: igt/kms_big_fb/y-tiled-addfb-size-offset-overflow
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20180912180443.28649-1-ville.syrjala@linux.intel.com
drivers/gpu/drm/i915/intel_display.c