dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
Cc: daniel.vetter@ffwll.ch, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/atomic: Fix potential use of state after free
Date: Fri, 23 Jan 2015 08:55:07 +0100	[thread overview]
Message-ID: <20150123075507.GX10113@phenom.ffwll.local> (raw)
In-Reply-To: <1421998079-22945-1-git-send-email-ander.conselvan.de.oliveira@intel.com>

On Fri, Jan 23, 2015 at 09:27:59AM +0200, Ander Conselvan de Oliveira wrote:
> The atomic helpers rely on drm_atomic_state_clear() to reset an atomic
> state if a retry is needed due to the w/w mutexes. The subsequent calls
> to drm_atomic_get_{crtc,plane,...}_state() would then return the stale
> pointers in state->{crtc,plane,...}_states.
> 
> Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>

Oops, pretty bad oversight. Kinda wonder why that hasn't blown up
anywhere yet - plain legacy paths can't really fail with retries yet since
we usually grab all the locks. But real atomic_ioctl should have fallen
over with ww mutex debugging ...

Anyway, thanks for the patch, applied to my atomic branch.
-Daniel

> ---
>  drivers/gpu/drm/drm_atomic.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index 1b31982..9d16fa4 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -134,6 +134,7 @@ void drm_atomic_state_clear(struct drm_atomic_state *state)
>  
>  		connector->funcs->atomic_destroy_state(connector,
>  						       state->connector_states[i]);
> +		state->connector_states[i] = NULL;
>  	}
>  
>  	for (i = 0; i < config->num_crtc; i++) {
> @@ -144,6 +145,7 @@ void drm_atomic_state_clear(struct drm_atomic_state *state)
>  
>  		crtc->funcs->atomic_destroy_state(crtc,
>  						  state->crtc_states[i]);
> +		state->crtc_states[i] = NULL;
>  	}
>  
>  	for (i = 0; i < config->num_total_plane; i++) {
> @@ -154,6 +156,7 @@ void drm_atomic_state_clear(struct drm_atomic_state *state)
>  
>  		plane->funcs->atomic_destroy_state(plane,
>  						   state->plane_states[i]);
> +		state->plane_states[i] = NULL;
>  	}
>  }
>  EXPORT_SYMBOL(drm_atomic_state_clear);
> -- 
> 1.9.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

      reply	other threads:[~2015-01-23  7:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-23  7:27 [PATCH] drm/atomic: Fix potential use of state after free Ander Conselvan de Oliveira
2015-01-23  7:55 ` Daniel Vetter [this message]

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=20150123075507.GX10113@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=ander.conselvan.de.oliveira@intel.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@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