CVE-2026-139075: drm/nouveau: disable the fence uevent work instead of just cancelling it
In the Linux kernel, the following vulnerability has been resolved:
drm/nouveau: disable the fence uevent work instead of just cancelling it
nouveaufencecontextdel() drains the uevent work while the event that feeds it is still armed:
cancelworksync(&fctx->ueventwork); nouveaufencecontextkill(fctx, 0); nvifeventdtor(&fctx->event);
nouveaufencewaitueventhandler() queues the work unconditionally:
schedulework(&fctx->ueventwork); return NVIFEVENTKEEP;
so a non-stall interrupt arriving after cancelworksync() has returned re-arms the work that was just drained. The window closes in two steps, neither of which is the drain. The kill blocks the event when the last fence holding a notifyref is signalled, which reaches atomicxchg(&ntfy->allowed, 0) (nvkm/core/event.c:104), and nvkmeventntfy() skips a ntfy that is not allowed (:183). That stops further handlers from starting, but not one that is already inside nvkmeventntfy(): the event is created with wait = false (nouveaufence.c:201), so nvkmeventntfyblock() leaves it on the list and never takes event->listlock. Only nvifeventdtor() waits that one out: nvkmeventntfydel() (:141) goes through nvkmeventntfyremove(), which takes writelockirq() on that same listlock (:84).
Either way the re-arm happens after the drain, and the caller drops its reference immediately afterwards, for example nv84fencecontextdel():
nouveaufencecontextdel(&fctx->base); chan->fence = NULL; nouveaufencecontextfree(&fctx->base);
That is a krefput() on fctx->fenceref, so the context outlives the teardown only while emitted fences still hold a reference of their own. That is no safety net: whenever none do, the count reaches zero right there and nouveaufencecontextput() kfree()s fctx while the work is still queued. &fctx->ueventwork is embedded in that allocation, so the workqueue already dereferences freed memory when it picks the item up, and nouveaufenceueventwork() can then take fctx->lock on it. With CONFIGDEBUGOBJECTSWORK and CONFIGDEBUGOBJECTSFREE, kfree() of a still-queued work item is reported as the free of an active object.
On live memory the re-armed work has nothing left to do: nouveaufencecontextkill() empties fctx->pending and sets fctx->killed under fctx->lock, nouveaufenceemit() then returns -ENODEV rather than queueing anything new, and nouveaufenceupdate() only reaches nvifeventblock() if it signalled something off that list. The defect is the access to freed memory, not what the work would have found.
Only chips from G84 on can reach this at all: nouveaufencecontextnew() returns before nvifeventctor() when priv->uevent is clear, and nv84fencecreate() is the only place that sets it. nv84fencecontextdel() is the contextdel for all of those, because nvc0fencecreate() and gv100fencecreate() build on nv84fencecreate() and override only contextnew.
Use disableworksync() instead. It drains the work exactly like cancelworksync() does, and additionally increments the work item's disable count, after which "any attempt to queue @work will fail and return %false" (kernel/workqueue.c, disablework()). The handler's schedulework() then has nothing to re-arm, and the teardown order stays as it is.
Draining a second time after nvifeventdtor() would close the window as well, and without the newer API: once nvkmeventntfyremove() has returned, no handler can start or still be running, so nothing re-arms the work past that point. disableworksync() is preferred here because it needs one synchronisation point instead of two, it keeps the work from being queued at all rather than cleaning up after it, and it is what drm has settled on for this (drm/xe, drm/panthor, drmpagemap). Blocking the event rather than the work is not an option: fctx->event is created with wait = false, so a handler already inside nvkmeventntfy() can still queue the work.
Note for backpor ---truncated---
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
In Nouveau fence teardown, replace cancel_work_sync(&fctx->uevent_work) with disable_work_sync(&fctx->uevent_work).