CVE-2023-53665
kernel: md: don't dereference mddev after export_rdev()
Severity
ModerateRed Hat Product Security
CVSS 3.1
Review impact separately from score.
Published · October 7, 2025
Updated · June 30, 2026
Description
A use-after-free vulnerability was found in the Linux kernel multiple device RAID subsystem's device lifetime management. A local user with privileges to manage MD arrays can trigger concurrent device addition and removal operations via sysfs, causing a race condition where the mddev structure is freed when the last rdev is removed but then dereferenced afterward, which leads to memory corruption and can result in denial of service via kernel crash or potentially privilege escalation through heap manipulation.
Statement
The issue arises because of incorrect object lifetime management in the MD RAID device removal path. The mddev->kobject reference is primarily held through rdev->kobject references. When export_rdev() removes the last remaining device from an array, the mddev structure can be freed as its reference count drops to zero. However, the code path in rdev_attr_store() continues to use the mddev pointer after calling export_rdev(), leading to a use-after-free condition. This can be triggered by racing concurrent writes to sysfs: one thread continuously adds devices via /sys/block/md0/md/new_dev while another removes them via /sys/block/md0/md/dev-<device>/state. The race window is narrow, occurring at very low frequency even under stress testing, which justifies the high attack complexity. The general protection fault shows the freed memory contains the SLAB poison pattern (0x6b6b6b6b6b6b6bcb), confirming use-after-free. While use-after-free vulnerabilities are known memory corruption primitives that can enable privilege escalation through careful heap manipulation, successful exploitation requires both timing the race precisely and controlling heap layout, making this significantly more complex than a straightforward memory safety violation.
CVSS score applicability
The CVSS score(s) listed for this vulnerability do not reflect the associated product's status, and are included for informational purposes to better understand the severity of this vulnerability.
Mitigation
To mitigate this issue, prevent the md_mod module from loading. See https://access.redhat.com/solutions/41278 for instructions on blacklisting kernel modules.
CVSS / CWE
CVSS 3.1 · 7CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H
CWE-911 · Improper Update of Reference Count