Skip to contentSkip to conversation

drm/i915: fix integer overflow in i915_gem_execbuffer2()

PATCH In review Xi Wang 3 participants 5 messages Apr 23, 2012

Subsystems (3)
lore
Share & tools
lore

Xi Wang

author
#0 lore raw

PATCH v2 1/2 drm/i915: fix integer overflow in i915_gem_execbuffer2()

On 32-bit systems, a large args->buffer_count from userspace via ioctl may overflow the allocation size, leading to out-of-bounds access.

This vulnerability was introduced in commit 8408c282 ("drm/i915:
First try a normal large kmalloc for the temporary exec buffers").

---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +2 -1
index f51a696..7c50e58 100644
@@ -1404,7 +1404,8 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
 	struct drm_i915_gem_exec_object2 *exec2_list = NULL;
 	int ret;
 
-	if (args->buffer_count < 1) {
+	if (args->buffer_count < 1 ||
+	    args->buffer_count > UINT_MAX / sizeof(*exec2_list)) {
 		DRM_DEBUG("execbuf2 with %d buffers\n", args->buffer_count);
 		return -EINVAL;
 	}
Signature · 1 line
1.7.5.4
author
#1 lore raw

PATCH v2 2/2 drm/i915: fix integer overflow in i915_gem_do_execbuffer()

On 32-bit systems, a large args->num_cliprects from userspace via ioctl may overflow the allocation size, leading to out-of-bounds access.

This vulnerability was introduced in commit 432e58ed ("drm/i915: Avoid allocation for execbuffer object list").

---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +5 -0
index 7c50e58..de43194 100644
@@ -1133,6 +1133,11 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 			return -EINVAL;
 		}
 
+		if (args->num_cliprects > UINT_MAX / sizeof(*cliprects)) {
+			DRM_DEBUG("execbuf with %u cliprects\n",
+				  args->num_cliprects);
+			return -EINVAL;
+		}
 		cliprects = kmalloc(args->num_cliprects * sizeof(*cliprects),
 				    GFP_KERNEL);
 		if (cliprects == NULL) {
Signature · 1 line
1.7.5.4
Reviewed-by on v2 2/2
#2 lore raw

Re: [PATCH v2 2/2] drm/i915: fix integer overflow in i915_gem_do_execbuffer()

Quoted 9 lines · Xi Wang

On 32-bit systems, a large args->num_cliprects from userspace via ioctl may overflow the allocation size, leading to out-of-bounds access.

This vulnerability was introduced in commit 432e58ed ("drm/i915: Avoid allocation for execbuffer object list").

-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Reviewed-by on v2 1/2
#3 lore raw
In reply to Xi Wang
Quoted 9 lines · Xi Wang

On 32-bit systems, a large args->buffer_count from userspace via ioctl may overflow the allocation size, leading to out-of-bounds access.

This vulnerability was introduced in commit 8408c282 ("drm/i915:
First try a normal large kmalloc for the temporary exec buffers").

-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#4 lore raw
Quoted 11 lines · Chris Wilson
Quoted 9 lines · Xi Wang

On 32-bit systems, a large args->buffer_count from userspace via ioctl may overflow the allocation size, leading to out-of-bounds access.

This vulnerability was introduced in commit 8408c282 ("drm/i915:
First try a normal large kmalloc for the temporary exec buffers").

Both patches picked up for -fixes, thanks.
-Daniel

Signature · 3 lines
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48