All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dma-buf/sw_sync: Synchronize signal vs syncpt free
@ 2019-08-12 15:42 Chris Wilson
  2019-08-12 16:13 ` ✗ Fi.CI.CHECKPATCH: warning for " Patchwork
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Chris Wilson @ 2019-08-12 15:42 UTC (permalink / raw)
  To: dri-devel
  Cc: intel-gfx, Chris Wilson, Sumit Semwal, Sean Paul, Gustavo Padovan,
	Christian König, stable

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+
---
 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);
-- 
2.23.0.rc1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-08-15  6:47 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH] " Koenig, Christian
2019-08-12 17:04   ` Koenig, Christian
2019-08-12 19:05 ` Sasha Levin
2019-08-12 19:05 ` Sasha Levin
2019-08-14 17:24   ` Daniel Vetter
2019-08-14 17:24     ` Daniel Vetter
2019-08-15  1:46     ` Sasha Levin
2019-08-15  1:46       ` Sasha Levin
2019-08-15  6:47       ` Daniel Vetter
2019-08-12 23:52 ` ✗ Fi.CI.IGT: failure for " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.