All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dma-buf/sw_sync: Avoid taking references to released fences
@ 2026-11-04 22:18 Kirtikumar Anandrao Ramchandani
  2026-11-04 22:41 ` [PATCH v2] " Kirtikumar Anandrao Ramchandani
  2026-11-05 11:33 ` [PATCH] " Christian König
  0 siblings, 2 replies; 8+ messages in thread
From: Kirtikumar Anandrao Ramchandani @ 2026-11-04 22:18 UTC (permalink / raw)
  To: sumit.semwal, christian.koenig, phasta
  Cc: dri-devel, linux-media, linaro-mm-sig, syzkaller-bugs,
	syzbot+cba1a1f459230395a076

[-- Attachment #1: Type: text/plain, Size: 1854 bytes --]

The last dma_fence_put() can drop a sync point's reference count to
zero before timeline_fence_release() acquires the timeline lock to
remove it from pt_list. If sync_timeline_signal() acquires the lock in
that window, dma_fence_get() attempts to increment a zero reference
count and triggers a refcount warning.

Use dma_fence_get_rcu() to acquire the temporary signaling reference
only if the fence is still referenced, as sync_pt_create() already
does when looking up an existing point. Skip a point whose reference
count has reached zero: its release callback will remove it from the
list and tree once the timeline lock is released.

The timeline lock prevents the release callback from removing or
freeing a listed point during this check. For a live point, retain the
temporary reference until after dropping the lock, preserving the
protection against recursive locking from signaling callbacks.

Fixes: e531fdb5cd5e ("dma-buf/sw_sync: Avoid recursive lock during fence
signal")
Reported-by: syzbot+cba1a1f459230395a076@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=cba1a1f459230395a076
Signed-off-by: Kirtikumar Anandrao Ramchandani <kirtiar15502@gmail.com>
---

 drivers/dma-buf/sw_sync.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/dma-buf/sw_sync.c b/drivers/dma-buf/sw_sync.c
index 8df20b0218a9..7f1eadee4cdf 100644
--- a/drivers/dma-buf/sw_sync.c
+++ b/drivers/dma-buf/sw_sync.c
@@ -221,7 +221,8 @@
                if (!timeline_fence_signaled(&pt->base))
                        break;

-               dma_fence_get(&pt->base);
+               if (!dma_fence_get_rcu(&pt->base))
+                       continue;

                list_move_tail(&pt->link, &signalled);
                rb_erase(&pt->node, &obj->pt_tree);

base-commit: 05441d697f7f9a927264f4058cbbc6a03dfcac9d

[-- Attachment #2: Type: text/html, Size: 2470 bytes --]

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

end of thread, other threads:[~2026-11-06  9:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-04 22:18 [PATCH] dma-buf/sw_sync: Avoid taking references to released fences Kirtikumar Anandrao Ramchandani
2026-11-04 22:41 ` [PATCH v2] " Kirtikumar Anandrao Ramchandani
2026-11-04 22:57   ` sashiko-bot
2026-11-04 23:16   ` [PATCH v3] " Kirtikumar Anandrao Ramchandani
2026-11-05 14:26     ` [PATCH v4] " Kirtikumar Anandrao Ramchandani
2026-11-05 15:14       ` Christian König
2026-11-05 11:33 ` [PATCH] " Christian König
2026-11-05 14:26   ` Kirtikumar Anandrao Ramchandani

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.