drm/nouveau: Clear fence channel in no-signaling path
Subsystems (4)
PATCH 1/1 drm/nouveau: Clear fence channel in no-signaling path
nouveau_fence_signal() clears fence->channel before dropping its reference. nouveau_fence_no_signaling(), however, removes an already signaled fence from fctx->pending without clearing the pointer.
The fence can remain attached to a BO reservation object and be used later in nouveau_fence_sync() after channel teardown has freed the channel. This leaves a stale channel pointer that the sync path can dereference.
A diagnostic build with concurrent short-lived Wayland GL clients observed nouveau_fence_no_signaling() with a fence pointing to channel C, nouveau_channel_del(C) returning, and then nouveau_fence_sync() attempting to read C->cli. A no-fault read failed after teardown.
Clear the pointer in nouveau_fence_no_signaling() to match nouveau_fence_signal(), so the sync path uses the fence wait fallback.
--- drivers/gpu/drm/nouveau/nouveau_fence.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/nouveau/nouveau_fence.c +1 -0
@@ -488,6 +488,7 @@ static bool nouveau_fence_no_signaling(struct dma_fence *f)*/ if (nouveau_fence_is_signaled (f)) {list_del (&fence->head); +rcu_assign_pointer (fence->channel,NULL );dma_fence_put (&fence->base);return false;
Signature · 1 line
2.55.0
Gentle Ping.
There has been some related discussion here:
https://lore.kernel.org/r/[email protected]
The patch has also been independently tested, with no reproduction of the issue reported so far.
Thanks.
Gentle Ping.
There has been some related discussion here:
https://lore.kernel.org/r/[email protected]
The patch has also been independently tested, with no reproduction of the issue reported so far.
Apologies if you received this twice. My previous message was rejected by the mailing list due to HTML formatting.
Thanks.
2026년 10월 15일 (목) 오후 6:10, 김범석 <[email protected]>님이 작성:
Quoted 10 lines
Gentle Ping.
There has been some related discussion here:
https://lore.kernel.org/r/[email protected]The patch has also been independently tested, with no reproduction of the issue reported so far.
Thanks.
[email protected]
maintainerQuoted 11 lines · 김범석
Gentle Ping.
There has been some related discussion here:
https://lore.kernel.org/r/[email protected]The patch has also been independently tested, with no reproduction of the issue reported so far.
Apologies if you received this twice. My previous message was rejected
by the mailing list due to HTML formatting.
It's no problem, I'm going to try to get back to reviewing stuff asap - currently I'm in the middle of moving however so I've got to focus on higher priority stuff at work at the moment. So it might take me 2 or 3 weeks before I can start reviewing stuff again
Quoted 17 lines
Thanks.
2026년 10월 15일 (목) 오후 6:10, 김범석 <[email protected]>님이 작성:
Quoted 11 lines
Gentle Ping.
There has been some related discussion here:
https://lore.kernel.org/r/[email protected]The patch has also been independently tested, with no reproduction of the issue reported so far.
Thanks.
Quoted 3 lines · Beomseok Kim
nouveau_fence_signal()clearsfence->channelbefore dropping its reference.nouveau_fence_no_signaling(), however, removes an already signaled fence fromfctx->pendingwithout clearing the pointer.
[...]
drivers/gpu/drm/nouveau/nouveau_fence.c static bool nouveau_fence_no_signaling(struct dma_fence *f) · line 491
Quoted 5 lines
drivers/gpu/drm/nouveau/nouveau_fence.c +1
-0@@ -488,6 +488,7 @@ static bool nouveau_fence_no_signaling(struct dma_fence *f)*/ if (nouveau_fence_is_signaled (f)) {list_del (&fence->head); +rcu_assign_pointer (fence->channel,NULL );
I think this patch fixes drm/nouveau#443 [1]. The nouveau_fence_sync() oopses there and in the reporter's thread [2] (MCP79, Debian 6.12.43, 6.12.90 and 7.0.10) all fault at CR2 0x40 on the prev->cli->drm load, with prev taken from f->channel and prev->cli NULL. A channel's cli is never cleared, so prev most likely points to a freed channel. That is the stale pointer described above: the no-signaling path is the only way off fctx->pending that leaves fence->channel set, and nouveau_fence_context_kill() only walks fctx->pending.
The fix looks right to me. enable_signaling runs under the fence lock (&fctx->lock) while the fence is still on fctx->pending, so the new store happens before nouveau_fence_context_kill() takes that lock, and thus before the synchronize_rcu() in nouveau_fence_context_del(). With fence->channel NULL, nouveau_fence_sync() falls back to dma_fence_wait() on an already signaled fence.
Emmanuel Fleury's prev->cli check for the same oops [3] only helps when the freed memory reads back as zero, so I prefer this patch.
The patch applies to 6.12.y with an offset; compile-tested there with W=1 only. I have asked the reporter (Cc'd) to test it.
I did this review with help from Claude (claude-opus-5-5).
[1] https://gitlab.freedesktop.org/drm/nouveau/-/issues/443
[2] https://lore.freedesktop.org/nouveau/[email protected]/
[3] https://lore.freedesktop.org/nouveau/[email protected]/
Hello,
Quoted 2 lines
The patch applies to 6.12.y with an offset; compile-tested there with W=1 only. I have asked the reporter (Cc'd) to test it.
Thank you Marek, Beomseok and other contributors.
For my quick test of the patch by Beomseok Kim, please see https://gitlab.freedesktop.org/drm/nouveau/-/work_items/443#note_3781457
Regards
Fab