dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Ville Syrjala <ville.syrjala@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH v2 2/3 drm: Check property/enum name length
Date: Tue, 6 Mar 2018 11:22:54 +0100	[thread overview]
Message-ID: <20180306102254.GF22212@phenom.ffwll.local> (raw)
In-Reply-To: <20180302140300.31110-1-ville.syrjala@linux.intel.com>

On Fri, Mar 02, 2018 at 04:03:00PM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Reject requests to add properties/enums with an overly long name.
> Previously we would have just silently truncated the string and exposed
> it userspace.
> 
> v2: drm_property_create() returns a pointer
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

While you're typing validation code, I noticed that drm_property_add_enum
allows you to overwrite the name of an existing enum value already added.
That sounds like something we never want to allow either.

Anyway, this is

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/drm_property.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_property.c b/drivers/gpu/drm/drm_property.c
> index fe8627fb7ae6..c37ac41125b5 100644
> --- a/drivers/gpu/drm/drm_property.c
> +++ b/drivers/gpu/drm/drm_property.c
> @@ -78,6 +78,9 @@ struct drm_property *drm_property_create(struct drm_device *dev, int flags,
>  	struct drm_property *property = NULL;
>  	int ret;
>  
> +	if (WARN_ON(strlen(name) >= DRM_PROP_NAME_LEN))
> +		return NULL;
> +
>  	property = kzalloc(sizeof(struct drm_property), GFP_KERNEL);
>  	if (!property)
>  		return NULL;
> @@ -372,6 +375,9 @@ int drm_property_add_enum(struct drm_property *property, int index,
>  {
>  	struct drm_property_enum *prop_enum;
>  
> +	if (WARN_ON(strlen(name) >= DRM_PROP_NAME_LEN))
> +		return -EINVAL;
> +
>  	if (!(drm_property_type_is(property, DRM_MODE_PROP_ENUM) ||
>  			drm_property_type_is(property, DRM_MODE_PROP_BITMASK)))
>  		return -EINVAL;
> -- 
> 2.16.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2018-03-06 10:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-02 13:25 [PATCH 1/3] drm: Don't create properties without names Ville Syrjala
2018-03-02 13:25 ` [PATCH 2/3] drm: Check property/enum name length Ville Syrjala
2018-03-02 14:03   ` [PATCH v2 2/3 " Ville Syrjala
2018-03-06 10:22     ` Daniel Vetter [this message]
2018-03-06 11:50       ` Ville Syrjälä
2018-03-02 13:25 ` [PATCH v2 3/3] drm: Add BT.2020 constant luminance enum value for the COLOR_ENCODING property Ville Syrjala
2018-03-06 10:18 ` [PATCH 1/3] drm: Don't create properties without names Daniel Vetter
2018-03-06 13:35 ` [Intel-gfx] " Emil Velikov
2018-03-06 13:54   ` Ville Syrjälä
2018-03-06 15:41     ` Emil Velikov

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=20180306102254.GF22212@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox