CVE-2026-142802: platform/x86/amd: hfi: Fix a use-after-free when unloading the driver
In the Linux kernel, the following vulnerability has been resolved:
platform/x86/amd: hfi: Fix a use-after-free when unloading the driver
amdhfiprobe() registers CPU hotplug callbacks with cpuhpsetupstate(CPUHPAPONLINEDYN, ...) and schedules the static schedamdhfiitmtwork work item, but amdhfiremove() tears down neither. The dynamically assigned hotplug state returned by cpuhpsetupstate() is discarded, so cpuhpremovestate() can never be called, and the pending work is never cancelled.
After the module is unloaded and its memory is freed, any subsequent CPU hotplug event or execution of the scheduled work dereferences the stale callback and work function pointers, resulting in a use-after-free and kernel panic.
Store the hotplug state returned by cpuhpsetupstate() and, on removal, call cpuhpremovestate() to unregister the callbacks and cancelworksync() to flush the scheduled work before the module memory goes away.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
Store the hotplug state returned by cpuhp_setup_state() in amd_hfi_probe(); in amd_hfi_remove(), call cpuhp_remove_state() with that state to unregister the callbacks and call cancel_work_sync() to flush the scheduled work before the module memory is freed.
Event History
Frequently Asked Questions
When can this issue be triggered?
It can be triggered after the AMD HFI driver is unloaded, if a CPU hotplug event occurs or the previously scheduled AMD HFI work item executes. Those paths can call function pointers in memory that was freed during module unload.
What is the likely impact?
The described outcome is a kernel use-after-free leading to a kernel panic. The issue affects systems where the AMD HFI driver has been loaded and is then unloaded while its hotplug callbacks or scheduled work remain active.
How is the issue fixed?
The fix retains the dynamically assigned CPU hotplug state so it can be removed during driver teardown. It also unregisters the hotplug callbacks with cpuhp_remove_state() and uses cancel_work_sync() to flush pending work before the module memory is freed.