dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Xi Wang <xi.wang@gmail.com>
To: Keith Packard <keithp@keithp.com>,
	Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: [PATCH 2/2] drm/i915: fix integer overflow in i915_gem_do_execbuffer()
Date: Fri,  6 Apr 2012 08:58:19 -0400	[thread overview]
Message-ID: <1333717099-32679-2-git-send-email-xi.wang@gmail.com> (raw)
In-Reply-To: <1333717099-32679-1-git-send-email-xi.wang@gmail.com>

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

| i915_gem_do_execbuffer()
| i915_gem_execbuffer()

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 19962bd..607be3d 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -1133,8 +1133,8 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 			return -EINVAL;
 		}
 
-		cliprects = kmalloc(args->num_cliprects * sizeof(*cliprects),
-				    GFP_KERNEL);
+		cliprects = kmalloc_array(args->num_cliprects, sizeof(*cliprects),
+					  GFP_KERNEL);
 		if (cliprects == NULL) {
 			ret = -ENOMEM;
 			goto pre_mutex_err;
-- 
1.7.5.4

  reply	other threads:[~2012-04-06 12:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-06 12:58 [PATCH 1/2] drm/i915: fix integer overflow in i915_gem_execbuffer2() Xi Wang
2012-04-06 12:58 ` Xi Wang [this message]
2012-04-06 13:36 ` 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1333717099-32679-2-git-send-email-xi.wang@gmail.com \
    --to=xi.wang@gmail.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=keithp@keithp.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).