From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Emil Velikov <emil.l.velikov@gmail.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>,
ML dri-devel <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH 08/15] drm: omapdrm: gem: Mask out private flags passed from userspace
Date: Mon, 14 Dec 2015 22:33:18 +0200 [thread overview]
Message-ID: <1700140.jYr741kVYy@avalon> (raw)
In-Reply-To: <CACvgo536CGi6B3g=HMTGD6pRzf_Bfc-94ZYBrDM7FJ3+-+RrRA@mail.gmail.com>
Hi Emil,
On Monday 07 December 2015 14:13:43 Emil Velikov wrote:
> On 4 December 2015 at 22:27, Laurent Pinchart wrote:
> > The 8 high order bits of the buffer flags are reserved for internal use.
> > Mask them out from the flags passed by userspace.
>
> Ouch... I know that the Intel guys are pretty rigorous about input
> validation, although I wonder how many drivers are (partially or not)
> missing these.
>
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >
> > drivers/gpu/drm/omapdrm/omap_drv.c | 9 ++++++---
> > include/uapi/drm/omap_drm.h | 1 +
> > 2 files changed, 7 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c
> > b/drivers/gpu/drm/omapdrm/omap_drv.c index 83d63d71062c..e405ab23d7a6
> > 100644
> > --- a/drivers/gpu/drm/omapdrm/omap_drv.c
> > +++ b/drivers/gpu/drm/omapdrm/omap_drv.c
> > @@ -551,10 +551,13 @@ static int ioctl_gem_new(struct drm_device *dev,
> > void *data,
> > struct drm_file *file_priv)
> > {
> > struct drm_omap_gem_new *args = data;
> > + u32 flags = args->flags & OMAP_BO_USER_MASK;
> > +
> > VERB("%p:%p: size=0x%08x, flags=%08x", dev, file_priv,
> > - args->size.bytes, args->flags);
> > - return omap_gem_new_handle(dev, file_priv, args->size,
> > - args->flags, &args->handle);
> > + args->size.bytes, flags);
> > +
> > + return omap_gem_new_handle(dev, file_priv, args->size, flags,
> > + &args->handle);
> > }
> >
> > static int ioctl_gem_cpu_prep(struct drm_device *dev, void *data,
> > diff --git a/include/uapi/drm/omap_drm.h b/include/uapi/drm/omap_drm.h
> > index 1d0b1172664e..6852c26e8f78 100644
> > --- a/include/uapi/drm/omap_drm.h
> > +++ b/include/uapi/drm/omap_drm.h
> > @@ -36,6 +36,7 @@ struct drm_omap_param {
> >
> > #define OMAP_BO_SCANOUT 0x00000001 /* scanout capable (phys
> > contiguous) */
> > #define OMAP_BO_CACHE_MASK 0x00000006 /* cache type mask, see
> > cache modes */
> > #define OMAP_BO_TILED_MASK 0x00000f00 /* tiled mapping mask, see
> > tiled modes */
> > +#define OMAP_BO_USER_MASK 0x00ffffff /* flags settable by
> > userspace */
>
> Fwiw I'm not too sure that adding the mask here (UAPI) is a good
> idea.
Good point, I'll make it private.
> If you like to keep it, I'd suggest that it encapsulates only what's
> currently available. Might even want to move the individual masks in the
> respective sections/hunks. Speaking of which - OMAP_BO_TILED_MASK should be
> 0x00000300, shouldn't it ?
I suppose 0x00000f00 was chosen to reserve a couple of bits for additional
tiled modes.
--
Regards,
Laurent Pinchart
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2015-12-14 20:33 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-04 22:27 [PATCH 00/15] omapdrm: Implement dma_buf import Laurent Pinchart
2015-12-04 22:27 ` [PATCH 01/15] drm: omapdrm: Fix plane state free in plane reset handler Laurent Pinchart
2015-12-09 12:43 ` Tomi Valkeinen
2015-12-13 20:39 ` Laurent Pinchart
2015-12-14 7:59 ` Tomi Valkeinen
2015-12-04 22:27 ` [PATCH 02/15] drm: omapdrm: Make fbdev emulation optional Laurent Pinchart
2015-12-04 22:27 ` [PATCH 03/15] drm: omapdrm: gem: Remove unused function prototypes Laurent Pinchart
2015-12-04 22:27 ` [PATCH 04/15] drm: omapdrm: gem: Remove forward declarations Laurent Pinchart
2015-12-04 22:27 ` [PATCH 05/15] drm: omapdrm: gem: Group functions by purpose Laurent Pinchart
2015-12-04 22:27 ` [PATCH 06/15] drm: omapdrm: gem: Move global usergart variable to omap_drm_private Laurent Pinchart
2015-12-04 22:27 ` [PATCH 07/15] drm: omapdrm: gem: Remove omap_drm_private has_dmm field Laurent Pinchart
2015-12-04 22:27 ` [PATCH 08/15] drm: omapdrm: gem: Mask out private flags passed from userspace Laurent Pinchart
2015-12-07 14:13 ` Emil Velikov
2015-12-14 20:33 ` Laurent Pinchart [this message]
2015-12-16 17:33 ` Emil Velikov
2015-12-16 23:27 ` Rob Clark
2015-12-04 22:27 ` [PATCH 09/15] drm: omapdrm: gem: Clean up GEM objects memory flags Laurent Pinchart
2015-12-04 22:27 ` [PATCH 10/15] drm: omapdrm: gem: Free the correct memory object Laurent Pinchart
2015-12-14 11:45 ` Tomi Valkeinen
2015-12-14 19:52 ` Laurent Pinchart
2015-12-04 22:27 ` [PATCH 11/15] drm: omapdrm: gem: Don't free mmap offset twice Laurent Pinchart
2015-12-04 22:27 ` [PATCH 12/15] drm: omapdrm: gem: Simplify error handling when creating GEM object Laurent Pinchart
2015-12-04 22:27 ` [PATCH 13/15] drm: omapdrm: gem: Remove check for impossible condition Laurent Pinchart
2015-12-04 22:27 ` [PATCH 14/15] drm: omapdrm: gem: Refactor GEM object allocation Laurent Pinchart
2015-12-04 22:27 ` [PATCH 15/15] drm: omapdrm: gem: Implement dma_buf import Laurent Pinchart
2015-12-05 15:40 ` Daniel Vetter
2015-12-05 22:24 ` Laurent Pinchart
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=1700140.jYr741kVYy@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=emil.l.velikov@gmail.com \
--cc=tomi.valkeinen@ti.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox