drm/i915: Sanity check mmap length against object size
authorChris Wilson <chris@chris-wilson.co.uk>
Thu, 14 Mar 2019 07:58:29 +0000 (07:58 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Mon, 18 Mar 2019 12:58:15 +0000 (12:58 +0000)
commit794a11cb67201ad1bb61af510bb8460280feb3f3
tree09ca18dd377c64ac23b325ad9bc921f06502a8b3
parent535d8d27c0e2f6c35f5f92fc0999f780f0e4b2e9
drm/i915: Sanity check mmap length against object size

We assumed that vm_mmap() would reject an attempt to mmap past the end of
the filp (our object), but we were wrong.

Applications that tried to use the mmap beyond the end of the object
would be greeted by a SIGBUS. After this patch, those applications will
be told about the error on creating the mmap, rather than at a random
moment on later access.

Reported-by: Antonio Argenziano <antonio.argenziano@intel.com>
Testcase: igt/gem_mmap/bad-size
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Antonio Argenziano <antonio.argenziano@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: stable@vger.kernel.org
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190314075829.16838-1-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/i915_gem.c