public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Koenig, Christian" <Christian.Koenig@amd.com>
To: Chris Wilson <chris@chris-wilson.co.uk>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>
Cc: Gustavo Padovan <gustavo@padovan.org>,
	"intel-gfx@lists.freedesktop.org"
	<intel-gfx@lists.freedesktop.org>,
	Sean Paul <seanpaul@chromium.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH] dma-buf/sw_sync: Synchronize signal vs syncpt free
Date: Mon, 12 Aug 2019 17:04:32 +0000	[thread overview]
Message-ID: <994a1925-6d96-505f-c7f9-78a1cdf82051@amd.com> (raw)
In-Reply-To: <20190812154247.20508-1-chris@chris-wilson.co.uk>

Am 12.08.19 um 17:42 schrieb Chris Wilson:
> During release of the syncpt, we remove it from the list of syncpt and
> the tree, but only if it is not already been removed. However, during
> signaling, we first remove the syncpt from the list. So, if we
> concurrently free and signal the syncpt, the free may decide that it is
> not part of the tree and immediately free itself -- meanwhile the
> signaler goes onto to use the now freed datastructure.
>
> In particular, we get struct by commit 0e2f733addbf ("dma-buf: make
> dma_fence structure a bit smaller v2") as the cb_list is immediately
> clobbered by the kfree_rcu.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111381
> Fixes: d3862e44daa7 ("dma-buf/sw-sync: Fix locking around sync_timeline lists")
> References: 0e2f733addbf ("dma-buf: make dma_fence structure a bit smaller v2")
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Sumit Semwal <sumit.semwal@linaro.org>
> Cc: Sean Paul <seanpaul@chromium.org>
> Cc: Gustavo Padovan <gustavo@padovan.org>
> Cc: Christian König <christian.koenig@amd.com>
> Cc: <stable@vger.kernel.org> # v4.14+

Acked-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/dma-buf/sw_sync.c | 13 +++++--------
>   1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/dma-buf/sw_sync.c b/drivers/dma-buf/sw_sync.c
> index 051f6c2873c7..27b1d549ed38 100644
> --- a/drivers/dma-buf/sw_sync.c
> +++ b/drivers/dma-buf/sw_sync.c
> @@ -132,17 +132,14 @@ static void timeline_fence_release(struct dma_fence *fence)
>   {
>   	struct sync_pt *pt = dma_fence_to_sync_pt(fence);
>   	struct sync_timeline *parent = dma_fence_parent(fence);
> +	unsigned long flags;
>   
> +	spin_lock_irqsave(fence->lock, flags);
>   	if (!list_empty(&pt->link)) {
> -		unsigned long flags;
> -
> -		spin_lock_irqsave(fence->lock, flags);
> -		if (!list_empty(&pt->link)) {
> -			list_del(&pt->link);
> -			rb_erase(&pt->node, &parent->pt_tree);
> -		}
> -		spin_unlock_irqrestore(fence->lock, flags);
> +		list_del(&pt->link);
> +		rb_erase(&pt->node, &parent->pt_tree);
>   	}
> +	spin_unlock_irqrestore(fence->lock, flags);
>   
>   	sync_timeline_put(parent);
>   	dma_fence_free(fence);

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2019-08-12 17:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-12 15:42 [PATCH] dma-buf/sw_sync: Synchronize signal vs syncpt free Chris Wilson
2019-08-12 16:13 ` ✗ Fi.CI.CHECKPATCH: warning for " Patchwork
2019-08-12 16:46 ` ✓ Fi.CI.BAT: success " Patchwork
2019-08-12 17:04 ` Koenig, Christian [this message]
2019-08-12 19:05 ` [PATCH] " Sasha Levin
2019-08-12 23:52 ` ✗ Fi.CI.IGT: failure for " Patchwork
     [not found] ` <20190812190548.450CF20684@mail.kernel.org>
2019-08-14 17:24   ` [PATCH] " Daniel Vetter
2019-08-15  1:46     ` Sasha Levin
2019-08-15  6:47       ` 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=994a1925-6d96-505f-c7f9-78a1cdf82051@amd.com \
    --to=christian.koenig@amd.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gustavo@padovan.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=seanpaul@chromium.org \
    --cc=stable@vger.kernel.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