Question: NVMe AER completion delivery during controller removal
Yaohan Li
shunsheng1218 at gmail.com
Sat Nov 14 00:17:42 PST 2026
Hi Mohamed,
Thanks for suggesting the PCI-side flush. I tested it against the previously submitted NVMe fix using three builds based on the same v7.4-rc1 configuration.
With the unmodified kernel, the injected AEN triggered async_event_work after the controller had been freed, resulting in a KASAN use-after-free.
With your proposed flush_work() in nvme_remove(), the worker completed before the controller was freed, and KASAN reported no use-after-free.
With the existing fix, which adds cancel_work_sync(&ctrl->async_event_work) in nvme_uninit_ctrl(), two runs with AEN injection completed without a post-free worker execution or KASAN report.
I also instrumented queue_work_on() in the last configuration. The trace showed a call for the controller's async event work at the AEN completion, rather than just an entry into nvme_complete_async_event().
These results suggest that the existing fix covers the late-completion window you identified. Keith has already applied that fix to nvme-7.4 as commit 9b657c565984, so I don't think a separate PCI-side flush is needed for this case.
The test still uses an out-of-specification BAR0 doorbell injection. It demonstrates the software lifetime race under this synthetic trigger, but does not establish reachability with a specification-compliant controller.
Thanks again for your help.
Yaohan
More information about the Linux-nvme
mailing list