public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Daniel Vetter <daniel.vetter@intel.com>,
	Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
	DRI Development <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH] drm: check for garbage in unused addfb2 fields
Date: Tue, 26 May 2015 14:38:44 +0200	[thread overview]
Message-ID: <20150526123842.GA21049@ulmo.nvidia.com> (raw)
In-Reply-To: <1432133633-19965-1-git-send-email-daniel.vetter@ffwll.ch>


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

On Wed, May 20, 2015 at 04:53:53PM +0200, Daniel Vetter wrote:
> Unfortunately old userspace didn't clear this properly, but since
> we've added fb modifiers that's fixed. Checking properly that unused
> fields is important for abi extensions, and just right now there's a
> bunch of discussions going on about how exactly the additional aux
> planes for render compression should be specified.
> 
> So let's first make sure that the values in those additional fields
> can be indeed used.
> 
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Testcase: igt/kms_addfb/unused-*
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  drivers/gpu/drm/drm_crtc.c | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)

I think this is fine for now. There's still some unclarity about how
exactly to pass in auxiliary planes, but in order to do so we need to
prevent userspace from passing in garbage, so:

Reviewed-by: Thierry Reding <treding@nvidia.com>

> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 2e26988a9762..8ad582f4026b 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -3308,6 +3308,32 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r)
>  		}
>  	}
>  
> +	for (i = num_planes; i < 4; i++) {
> +		if (r->modifier[i]) {
> +			DRM_DEBUG_KMS("non-zero modifier for unused plane %d\n", i);
> +			return -EINVAL;
> +		}
> +
> +		/* Pre-FB_MODIFIERS userspace didn't clear the structs properly. */
> +		if (!(r->flags & DRM_MODE_FB_MODIFIERS))
> +			continue;
> +
> +		if (r->handles[i]) {
> +			DRM_DEBUG_KMS("buffer object handle for unused plane %d\n", i);
> +			return -EINVAL;
> +		}
> +
> +		if (r->pitches[i]) {
> +			DRM_DEBUG_KMS("non-zero pitch for unused plane %d\n", i);
> +			return -EINVAL;
> +		}
> +
> +		if (r->offsets[i]) {
> +			DRM_DEBUG_KMS("non-zero offset for unused plane %d\n", i);
> +			return -EINVAL;
> +		}
> +	}
> +
>  	return 0;
>  }
>  
> -- 
> 2.1.4
> 

[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 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

  parent reply	other threads:[~2015-05-26 12:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-20 14:53 [PATCH] drm: check for garbage in unused addfb2 fields Daniel Vetter
2015-05-21 21:05 ` shuang.he
2015-05-26 12:38 ` Thierry Reding [this message]
2015-05-26 12:43   ` Daniel Vetter

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=20150526123842.GA21049@ulmo.nvidia.com \
    --to=thierry.reding@gmail.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox