mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/nouveau: Clear fence channel in no-signaling path
@ 2026-09-28  8:14 Beomseok Kim
       [not found] ` <CAGC3ukQ7gX97E7pG0Oy8H0cnmQzoA1038io+VhrBogPB3y9dDQ@mail.gmail.com>
  2026-11-12 21:40 ` Marek Czernohous
  0 siblings, 2 replies; 4+ messages in thread
From: Beomseok Kim @ 2026-09-28  8:14 UTC (permalink / raw)
  To: nouveau
  Cc: lyude, dakr, maarten.lankhorst, mripard, tzimmermann, airlied,
	simona, dri-devel, linux-kernel, Beomseok Kim, stable

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.

Fixes: 29ba89b2371d ("drm/nouveau: rework to new fence interface")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Beomseok Kim <dilddream31@gmail.com>
---
 drivers/gpu/drm/nouveau/nouveau_fence.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
index edbe9e08b..5b09cf134 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fence.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
@@ -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;
-- 
2.55.0


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

* Re: [PATCH] drm/nouveau: Clear fence channel in no-signaling path
       [not found] ` <CAGC3ukQ7gX97E7pG0Oy8H0cnmQzoA1038io+VhrBogPB3y9dDQ@mail.gmail.com>
@ 2026-10-15 10:40   ` 김범석
  2026-10-23 17:19     ` lyude
  0 siblings, 1 reply; 4+ messages in thread
From: 김범석 @ 2026-10-15 10:40 UTC (permalink / raw)
  To: nouveau
  Cc: lyude, dakr, maarten.lankhorst, mripard, tzimmermann, airlied,
	simona, dri-devel, linux-kernel, stable

Gentle Ping.

There has been some related discussion here:
https://lore.kernel.org/r/1690ea65-a1e0-4a34-bde1-bdd26e31c6c4@u-bordeaux.fr

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, 김범석 <dilddream31@gmail.com>님이 작성:
>
> Gentle Ping.
>
> There has been some related discussion here:
> https://lore.kernel.org/r/1690ea65-a1e0-4a34-bde1-bdd26e31c6c4@u-bordeaux.fr
>
> The patch has also been independently tested, with no reproduction of the issue reported so far.
>
>
> Thanks.

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

* Re: [PATCH] drm/nouveau: Clear fence channel in no-signaling path
  2026-10-15 10:40   ` 김범석
@ 2026-10-23 17:19     ` lyude
  0 siblings, 0 replies; 4+ messages in thread
From: lyude @ 2026-10-23 17:19 UTC (permalink / raw)
  To: 김범석, nouveau
  Cc: dakr, maarten.lankhorst, mripard, tzimmermann, airlied, simona,
	dri-devel, linux-kernel, stable

On Thu, 2026-10-15 at 19:40 +0900, 김범석 wrote:
> Gentle Ping.
> 
> There has been some related discussion here:
> https://lore.kernel.org/r/1690ea65-a1e0-4a34-bde1-bdd26e31c6c4@u-bordeaux.fr
> 
> 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
> 
> 
> Thanks.
> 
> 
> 2026년 10월 15일 (목) 오후 6:10, 김범석 <dilddream31@gmail.com>님이 작성:
> > 
> > Gentle Ping.
> > 
> > There has been some related discussion here:
> > https://lore.kernel.org/r/1690ea65-a1e0-4a34-bde1-bdd26e31c6c4@u-bordeaux.fr
> > 
> > The patch has also been independently tested, with no reproduction
> > of the issue reported so far.
> > 
> > 
> > Thanks.


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

* Re: [PATCH] drm/nouveau: Clear fence channel in no-signaling path
  2026-09-28  8:14 [PATCH] drm/nouveau: Clear fence channel in no-signaling path Beomseok Kim
       [not found] ` <CAGC3ukQ7gX97E7pG0Oy8H0cnmQzoA1038io+VhrBogPB3y9dDQ@mail.gmail.com>
@ 2026-11-12 21:40 ` Marek Czernohous
  1 sibling, 0 replies; 4+ messages in thread
From: Marek Czernohous @ 2026-11-12 21:40 UTC (permalink / raw)
  To: Beomseok Kim
  Cc: nouveau, Lyude Paul, Danilo Krummrich, maarten.lankhorst,
	mripard, simona, dri-devel, linux-kernel, stable, Fab Stz

On Mon, 28 Sep 2026 17:14:50 +0900, Beomseok Kim <dilddream31@gmail.com> wrote:
> 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.

[...]

> @@ -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).

Reviewed-by: Marek Czernohous <marek@czernohous.de>

[1] https://gitlab.freedesktop.org/drm/nouveau/-/issues/443
[2] https://lore.freedesktop.org/nouveau/b7f523dc-fe41-4514-a1a5-747005311cbe@yahoo.fr/
[3] https://lore.freedesktop.org/nouveau/1690ea65-a1e0-4a34-bde1-bdd26e31c6c4@u-bordeaux.fr/

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

end of thread, other threads:[~2026-11-12 21:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-28  8:14 [PATCH] drm/nouveau: Clear fence channel in no-signaling path Beomseok Kim
     [not found] ` <CAGC3ukQ7gX97E7pG0Oy8H0cnmQzoA1038io+VhrBogPB3y9dDQ@mail.gmail.com>
2026-10-15 10:40   ` 김범석
2026-10-23 17:19     ` lyude
2026-11-12 21:40 ` Marek Czernohous

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®