dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/i915: fix integer overflow in i915_gem_execbuffer2()
@ 2012-04-06 12:58 Xi Wang
  2012-04-06 12:58 ` [PATCH 2/2] drm/i915: fix integer overflow in i915_gem_do_execbuffer() Xi Wang
  2012-04-06 13:36 ` [PATCH 1/2] drm/i915: fix integer overflow in i915_gem_execbuffer2() Chris Wilson
  0 siblings, 2 replies; 10+ messages in thread
From: Xi Wang @ 2012-04-06 12:58 UTC (permalink / raw)
  To: Keith Packard, Daniel Vetter; +Cc: linux-kernel, dri-devel

A large args->buffer_count from userspace may overflow the allocation
size, leading to out-of-bounds access.

Use kmalloc_array() to avoid that.

Signed-off-by: Xi Wang <xi.wang@gmail.com>
---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index f51a696..19962bd 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -1409,8 +1409,8 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
 		return -EINVAL;
 	}
 
-	exec2_list = kmalloc(sizeof(*exec2_list)*args->buffer_count,
-			     GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY);
+	exec2_list = kmalloc_array(args->buffer_count, sizeof(*exec2_list),
+				   GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY);
 	if (exec2_list == NULL)
 		exec2_list = drm_malloc_ab(sizeof(*exec2_list),
 					   args->buffer_count);
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-04-06 20:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-06 12:58 [PATCH 1/2] drm/i915: fix integer overflow in i915_gem_execbuffer2() Xi Wang
2012-04-06 12:58 ` [PATCH 2/2] drm/i915: fix integer overflow in i915_gem_do_execbuffer() Xi Wang
2012-04-06 13:36 ` [PATCH 1/2] drm/i915: fix integer overflow in i915_gem_execbuffer2() Chris Wilson
2012-04-06 13:46   ` Xi Wang
2012-04-06 13:54     ` Chris Wilson
2012-04-06 14:01       ` Xi Wang
2012-04-06 14:44         ` Chris Wilson
2012-04-06 18:17           ` Xi Wang
2012-04-06 19:40             ` Chris Wilson
2012-04-06 20:34               ` Xi Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).