All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jesse Barnes <jbarnes@virtuousgeek.org>
To: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 4/7] drm: plane: Check source coordinates
Date: Fri, 11 Nov 2011 09:20:11 -0800	[thread overview]
Message-ID: <20111111092011.08a3ce84@jbarnes-desktop> (raw)
In-Reply-To: <20111111171851.GE3477@intel.com>


[-- Attachment #1.1: Type: text/plain, Size: 2971 bytes --]

On Fri, 11 Nov 2011 19:18:52 +0200
Ville Syrjälä <ville.syrjala@linux.intel.com> wrote:

> On Fri, Nov 11, 2011 at 08:24:18AM -0800, Jesse Barnes wrote:
> > On Fri, 11 Nov 2011 18:04:04 +0200
> > ville.syrjala@linux.intel.com wrote:
> > 
> > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > 
> > > Make sure the source coordinates stay within the buffer.
> > > 
> > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > ---
> > >  drivers/gpu/drm/drm_crtc.c |   23 +++++++++++++++++++++++
> > >  1 files changed, 23 insertions(+), 0 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> > > index 70f5747..098cc50 100644
> > > --- a/drivers/gpu/drm/drm_crtc.c
> > > +++ b/drivers/gpu/drm/drm_crtc.c
> > > @@ -1654,6 +1654,7 @@ int drm_mode_setplane(struct drm_device *dev, void *data,
> > >  	struct drm_crtc *crtc;
> > >  	struct drm_framebuffer *fb;
> > >  	int ret = 0;
> > > +	unsigned int fb_width, fb_height;
> > >  
> > >  	if (!drm_core_check_feature(dev, DRIVER_MODESET))
> > >  		return -EINVAL;
> > > @@ -1702,6 +1703,28 @@ int drm_mode_setplane(struct drm_device *dev, void *data,
> > >  	}
> > >  	fb = obj_to_fb(obj);
> > >  
> > > +	fb_width = fb->width << 16;
> > > +	fb_height = fb->height << 16;
> > > +
> > > +	/* Make sure source coordinates are inside the fb. */
> > > +	if (plane_req->src_w > fb_width ||
> > > +	    plane_req->src_x > fb_width - plane_req->src_w ||
> > > +	    plane_req->src_h > fb_height ||
> > > +	    plane_req->src_y > fb_height - plane_req->src_h) {
> > > +		DRM_DEBUG_KMS("Invalid source coordinates "
> > > +			      "%01u.%06ux%01u.%06u+%01u.%06u+%01u.%06u\n",
> > > +			      plane_req->src_w >> 16,
> > > +			      ((plane_req->src_w & 0xffff) * 15625) >> 10,
> > > +			      plane_req->src_h >> 16,
> > > +			      ((plane_req->src_h & 0xffff) * 15625) >> 10,
> > > +			      plane_req->src_x >> 16,
> > > +			      ((plane_req->src_x & 0xffff) * 15625) >> 10,
> > > +			      plane_req->src_y >> 16,
> > > +			      ((plane_req->src_y & 0xffff) * 15625) >> 10);
> > > +		ret = -EINVAL;
> > > +		goto out;
> > > +	}
> > > +
> > >  	ret = plane->funcs->update_plane(plane, crtc, fb,
> > >  					 plane_req->crtc_x, plane_req->crtc_y,
> > >  					 plane_req->crtc_w, plane_req->crtc_h,
> > 
> > Good sanity check (saves the drivers from having to do it), but I
> > wonder if we can use a better return value like ENOSPC or something to
> > make it easier for userspace to figure out.
> 
> Yeah, getting EINVAL for every kind of failure is rather annoying. The
> only issue I have with ENOSPC is the strerror() output. It doesn't
> exactly fit this use case. But if there's nothing better I'm OK with
> ENOSPC.

Yeah, dunno what's best.  Check out include/asm-generic/errno-base.h
and errno.h; maybe you'll find a better fit.

-- 
Jesse Barnes, Intel Open Source Technology Center

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2011-11-11 17:19 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-11 16:04 drm plane fixes and additional checks ville.syrjala
2011-11-11 16:04 ` [PATCH 1/7] drm: Zero initialize drm_mode_fb_cmd2 in legacy addfb ioctl handler ville.syrjala
2011-11-11 16:55   ` Jesse Barnes
2011-11-11 16:04 ` [PATCH 2/7] drm: plane: Fix size of formats memcpy() ville.syrjala
2011-11-11 16:22   ` Jesse Barnes
2011-11-11 16:04 ` [PATCH 3/7] drm: plane: Clear plane.crtc and plane.fb after disable_plane() ville.syrjala
2011-11-11 16:56   ` Jesse Barnes
2011-11-11 16:04 ` [PATCH 4/7] drm: plane: Check source coordinates ville.syrjala
2011-11-11 16:24   ` Jesse Barnes
2011-11-11 17:18     ` Ville Syrjälä
2011-11-11 17:20       ` Jesse Barnes [this message]
2011-11-11 16:04 ` [PATCH 5/7] drm: plane: Check crtc coodrinates against integer overflows in setplane ioctl ville.syrjala
2011-11-11 17:01   ` Jesse Barnes
2011-11-11 17:11     ` Ville Syrjälä
2011-11-11 17:21       ` Jesse Barnes
2011-11-11 16:04 ` [PATCH 6/7] drm: plane: Make 'formats' parameter to drm_plane_init() const ville.syrjala
2011-11-11 16:25   ` Jesse Barnes
2011-11-11 16:04 ` [PATCH 7/7] drm: plane: Check that the fb pixel format is supported by the plane ville.syrjala
2011-11-11 16:25   ` Jesse Barnes

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=20111111092011.08a3ce84@jbarnes-desktop \
    --to=jbarnes@virtuousgeek.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ville.syrjala@linux.intel.com \
    /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.