From: Ben Widawsky <ben@bwidawsk.net>
To: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915: Defend against userspace creating a gem object with size==0
Date: Wed, 14 Sep 2011 20:02:10 +0000 [thread overview]
Message-ID: <20110914200210.GA22458@cloud01> (raw)
In-Reply-To: <1316002468-31203-1-git-send-email-daniel.vetter@ffwll.ch>
On Wed, Sep 14, 2011 at 02:14:28PM +0200, Daniel Vetter wrote:
> From: Chris Wilson <chris@chris-wilson.co.uk>
>
> We currently only round up the userspace size to the next page. We
> assume that userspace hasn't made a mistake and requested a zero-length
> gem object and all through our internal code we then presume that every
> object is backed by at least a single page. Fix that oversight and
> report EINVAL back to userspace if they try to create a zero length
> object.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> [danvet: This fixes tests/gem_bad_length]
> Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
> drivers/gpu/drm/i915/i915_gem.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 7998827..9857e9d 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -195,6 +195,8 @@ i915_gem_create(struct drm_file *file,
> u32 handle;
>
> size = roundup(size, PAGE_SIZE);
> + if (size == 0)
> + return -EINVAL;
>
> /* Allocate the new object */
> obj = i915_gem_alloc_object(dev, size);
Could we just: s/roundup/DIV_ROUND_UP and be happy?
Ben
next prev parent reply other threads:[~2011-09-14 19:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-14 12:14 [PATCH] drm/i915: Defend against userspace creating a gem object with size==0 Daniel Vetter
2011-09-14 20:02 ` Ben Widawsky [this message]
2011-09-14 21:22 ` Ben Widawsky
2011-09-23 16:14 ` Daniel Vetter
-- strict thread matches above, loose matches on Subject: below --
2011-06-23 10:40 Chris Wilson
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=20110914200210.GA22458@cloud01 \
--to=ben@bwidawsk.net \
--cc=daniel.vetter@ffwll.ch \
--cc=intel-gfx@lists.freedesktop.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.