stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: ville.syrjala@linux.intel.com
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	stable@vger.kernel.org, Daniel Vetter <daniel.vetter@ffwll.ch>,
	Tvrtko Ursulin <tvrtko.ursulin@intel.com>,
	Jani Nikula <jani.nikula@linux.intel.com>
Subject: Re: [PATCH 1/2] drm/i915: Don't clobber the addfb2 ioctl params
Date: Tue, 17 Nov 2015 10:47:06 +0100	[thread overview]
Message-ID: <20151117094706.GH16848@phenom.ffwll.local> (raw)
In-Reply-To: <1447261890-3960-1-git-send-email-ville.syrjala@linux.intel.com>

On Wed, Nov 11, 2015 at 07:11:28PM +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrj�l� <ville.syrjala@linux.intel.com>
> 
> We try to convert the old way of of specifying fb tiling (obj->tiling)
> into the new fb modifiers. We store the result in the passed in mode_cmd
> structure. But that structure comes directly from the addfb2 ioctl, and
> gets copied back out to userspace, which means we're clobbering the
> modifiers that the user provided (all 0 since the DRM_MODE_FB_MODIFIERS
> flag wasn't even set by the user). Hence if the user reuses the struct
> for another addfb2, the ioctl will be rejected since it's now asking for
> some modifiers w/o the flag set.
> 
> Fix the problem by making a copy of the user provided structure. We can
> play any games we want with the copy.
> 
> Cc: stable@vger.kernel.org
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Fixes: 2a80eada326f ("drm/i915: Add fb format modifier support")
> Testcase: igt/kms_addfb_basic/clobbered-modifier
> Signed-off-by: Ville Syrj�l� <ville.syrjala@linux.intel.com>

Out of curiosity: Where does this blow up? That should be added to the
commit message (so that people affected can match it up with this fix).
With that:

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


> ---
>  drivers/gpu/drm/i915/intel_display.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index b5f7493..c3aa6f5 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -14578,17 +14578,18 @@ static int intel_framebuffer_init(struct drm_device *dev,
>  static struct drm_framebuffer *
>  intel_user_framebuffer_create(struct drm_device *dev,
>  			      struct drm_file *filp,
> -			      struct drm_mode_fb_cmd2 *mode_cmd)
> +			      struct drm_mode_fb_cmd2 *user_mode_cmd)
>  {
>  	struct drm_framebuffer *fb;
>  	struct drm_i915_gem_object *obj;
> +	struct drm_mode_fb_cmd2 mode_cmd = *user_mode_cmd;
>  
>  	obj = to_intel_bo(drm_gem_object_lookup(dev, filp,
> -						mode_cmd->handles[0]));
> +						mode_cmd.handles[0]));
>  	if (&obj->base == NULL)
>  		return ERR_PTR(-ENOENT);
>  
> -	fb = intel_framebuffer_create(dev, mode_cmd, obj);
> +	fb = intel_framebuffer_create(dev, &mode_cmd, obj);
>  	if (IS_ERR(fb))
>  		drm_gem_object_unreference_unlocked(&obj->base);
>  
> -- 
> 2.4.10
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

  parent reply	other threads:[~2015-11-17  9:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-11 17:11 [PATCH 1/2] drm/i915: Don't clobber the addfb2 ioctl params ville.syrjala
2015-11-11 17:20 ` Chris Wilson
2015-11-11 17:24   ` Ville Syrjälä
2015-11-11 17:36     ` Chris Wilson
2015-11-17  9:47 ` Daniel Vetter [this message]
2015-11-17 11:04   ` Ville Syrjälä
2015-11-17 13:00     ` [Intel-gfx] " Ville Syrjälä
2015-11-17 14:45       ` Jani Nikula

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=20151117094706.GH16848@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=stable@vger.kernel.org \
    --cc=tvrtko.ursulin@intel.com \
    --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;
as well as URLs for NNTP newsgroup(s).