CVE-2026-142866: md/raid5: fix NULL pointer dereference in raid5_free_percpu
In the Linux kernel, the following vulnerability has been resolved:
md/raid5: fix NULL pointer dereference in raid5freepercpu
If cpuhpstateaddinstance() fails in raid5allocpercpu() (e.g., the startup callback raid456cpuupprepare fails due to an allocation failure), conf->node is never added to the cpuhp instance list and its pprev remains NULL (from kzalloc initialization).
When setupconf() then jumps to abort, freeconf() calls raid5freepercpu(), which checks conf->percpu (non-NULL, since it was allocated before the cpuhp failure) and proceeds to call cpuhpstateremoveinstance(). This calls hlistdel() on the unhashed node, which dereferences node->pprev (NULL), causing a kernel panic.
Guard the removal with hlistunhashedlockless() so that the cpuhp instance is only removed if it was actually added. The lockless variant uses READONCE() for the pprev read, which is safe here because the actual removal is synchronized by cpuhpstatemutex inside cpuhpstateremoveinstance().
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
Guard the cpuhp instance removal in raid5_free_percpu() with hlist_unhashed_lockless() so it is only removed if it was added.
Event History
Frequently Asked Questions
When can the kernel panic occur?
The panic requires RAID5 per-CPU setup to begin successfully enough to allocate conf->percpu, followed by failure of cpuhp_state_add_instance(). The subsequent configuration-abort cleanup can then attempt to remove a CPU hotplug instance that was never added.
Does this affect an already registered CPU hotplug instance?
The described failure is specific to an unhashed instance whose list linkage was never established because registration failed. The fix avoids removal unless the instance was actually added to the CPU hotplug instance list.