From: sashiko-bot@kernel.org
To: "Marek Czernohous" <mczernohous@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 2/4] drm/nouveau: subscribe to the channel-kill event after the fence context
Date: Wed, 12 Aug 2026 23:25:39 +0000 [thread overview]
Message-ID: <20260812232539.83BEA1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260812231330.705425-3-mczernohous@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Teardown symmetry bug in `nouveau_fence_context_del` can lead to UAF of `fctx` via a rescheduled work item.
--
--- Patch [2]: [PATCH v3 2/4] drm/nouveau: subscribe to the channel-kill event after the fence context ---
commit 0d333033075f8f241623e82cf6a4863bcbfcda8f
Author: Marek Czernohous <marek@czernohous.de>
drm/nouveau: subscribe to the channel-kill event after the fence context
nouveau_channel_init() arms the channel-kill subscription early, right
after mapping userd, and only creates the fence context at the very end
of the same function. The handler it installs, nouveau_channel_killed(),
reaches nouveau_fence_context_kill(chan->fence).
> diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
> index f142f63105966..07b0bd1bc519f 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_chan.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
[ ... ]
While reviewing this, I noticed a pre-existing issue in the fence teardown
sequence:
drivers/gpu/drm/nouveau/nouveau_fence.c:nouveau_fence_context_del() {
cancel_work_sync(&fctx->uevent_work);
nouveau_fence_context_kill(fctx, 0);
nvif_event_dtor(&fctx->event);
fctx->dead = 1;
...
}
[Severity: High]
This is a pre-existing issue, but does this teardown order create a
use-after-free risk for fctx?
If userspace emits a fence with signaling enabled and then immediately closes
the channel, nouveau_fence_context_del() is called. It executes
cancel_work_sync(&fctx->uevent_work) before stopping the event source.
If a hardware interrupt for the fence fires immediately after
cancel_work_sync() returns but before nouveau_fence_context_kill() blocks the
event, the interrupt handler nouveau_fence_wait_uevent_handler() will execute
and call schedule_work(&fctx->uevent_work).
The teardown sequence then continues, freeing the fctx memory via
nouveau_fence_context_free(). When the asynchronously scheduled work executes
later, nouveau_fence_uevent_work() accesses the freed fctx, resulting in a
use-after-free.
Should the event source be blocked or destroyed before synchronizing the work
cancellation?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260812231330.705425-1-mczernohous@gmail.com?part=2
next prev parent reply other threads:[~2026-08-12 23:25 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-12 23:13 [PATCH v3 0/4] drm/nouveau: channel-kill event ordering fixes, and lower the gate to NV50 Marek Czernohous
2026-08-12 23:13 ` Marek Czernohous
2026-08-12 23:13 ` [PATCH v3 1/4] drm/nouveau: unsubscribe the channel-kill event before the fence context Marek Czernohous
2026-08-12 23:13 ` Marek Czernohous
2026-08-12 23:30 ` sashiko-bot
2026-08-12 23:13 ` [PATCH v3 2/4] drm/nouveau: subscribe to the channel-kill event after " Marek Czernohous
2026-08-12 23:13 ` Marek Czernohous
2026-08-12 23:25 ` sashiko-bot [this message]
2026-08-12 23:13 ` [PATCH v3 3/4] drm/nouveau/fifo/nv04: filter benign CACHE_ERROR from Mesa NV50 bind probe Marek Czernohous
2026-08-12 23:13 ` Marek Czernohous
2026-08-12 23:13 ` [PATCH v3 4/4] drm/nouveau: subscribe to channel-kill events on NV50 and newer Marek Czernohous
2026-08-12 23:13 ` Marek Czernohous
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260812232539.83BEA1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=mczernohous@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.