CVE-2026-143028: dm: fix use-after-free when dm_get_device() widens the open mode
In the Linux kernel, the following vulnerability has been resolved:
dm: fix use-after-free when dmgetdevice() widens the open mode
There's an UAF bug in dmgetdevice(): when a table construction calls dmgetdevice() on the same device twice with widen access mode (e.g., read-only first then read-write), the second dmgetdevice() calls upgrademode(), which reopens the device in upgraded mode, making previously returned dmdev a stale pointer.
Fixing approaches: - Add per-mode views (dmdevref) from a per-device dmdevinternal to multiple tabledevices. - Keep reusing the dmdevref when the requested mode is included, i.e., a read-only reference can reuse the read-write opened device within a table. - Maintain a canonical blockdevice pointer in dmdevinternal for handling the DMTABLEDEPS ioctl.
Also tweak the way of mode sharing check in findref() to "(x & mask) == mask". The result stays the same to the previous upgrademode() guard "(x | mask) == x".
Pros: keep the relationship between dmdevinternal and tabledevice: one dmdevinternal per device, regardless the mode, so the output of DMMTABLEDEPS ioctl unchanged.
Cons: extra dmdevref allocation.
Note that now the tabledevice's count not necessarily mean the number tables referecing this <dev, mode> pair, since we're allowing multiple references within a table.
Affected Software
Event History
Frequently Asked Questions
Which systems are exposed to this issue?
Systems using the Linux kernel device-mapper are exposed when a device-mapper table construction obtains the same underlying device more than once and later requests a wider access mode, such as requesting read-only access first and read-write access afterward.
What condition triggers the use-after-free?
The trigger is a second dm_get_device() call for the same device during table construction that widens the open mode. Reopening the device with the wider mode can make a dm_dev pointer returned by the earlier call stale.
How can I determine whether a table construction is affected?
Review device-mapper table construction paths for repeated dm_get_device() calls on the same device with differing access modes. A sequence that first requests read-only access and then read-write access matches the described vulnerable pattern.