linux-stable/drivers/dma-buf
Rob Clark d527abdb0c dma-buf/sw_sync: Avoid recursive lock during fence signal
[ Upstream commit e531fdb5cd ]

If a signal callback releases the sw_sync fence, that will trigger a
deadlock as the timeline_fence_release recurses onto the fence->lock
(used both for signaling and the the timeline tree).

To avoid that, temporarily hold an extra reference to the signalled
fences until after we drop the lock.

(This is an alternative implementation of https://patchwork.kernel.org/patch/11664717/
which avoids some potential UAF issues with the original patch.)

v2: Remove now obsolete comment, use list_move_tail() and
    list_del_init()

Reported-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Fixes: d3c6dd1fb3 ("dma-buf/sw_sync: Synchronize signal vs syncpt free")
Signed-off-by: Rob Clark <robdclark@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20230818145939.39697-1-robdclark@gmail.com
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-08-30 16:35:16 +02:00
..
dma-buf.c dma-buf: balance refcount inbalance 2019-07-31 07:28:47 +02:00
dma-fence-array.c dma-buf/fence: Fix lock inversion within dma-fence-array 2018-03-19 08:42:47 +01:00
dma-fence.c
Kconfig
Makefile
reservation.c dma-buf: Discard old fence_excl on retrying get_fences_rcu for realloc 2019-07-31 07:28:47 +02:00
seqno-fence.c
sw_sync.c dma-buf/sw_sync: Avoid recursive lock during fence signal 2023-08-30 16:35:16 +02:00
sync_debug.c
sync_debug.h
sync_file.c dma-buf/sync_file: Don't leak fences on merge failure 2021-07-28 11:12:16 +02:00
sync_trace.h