CVE-2026-139128: block: fix use-after-free of the disk in sync_bdevs()
In the Linux kernel, the following vulnerability has been resolved:
block: fix use-after-free of the disk in syncbdevs()
syncbdevs() holds a reference to the bdev inode while it takes bddisk->openmutex. For a partition the inode doesn't keep the gendisk alive, the device reference does: partrelease() drops the disk as soon as the last reference to the partition device is gone. A sync(2) racing with the last close of a partition of an already deleted disk locks a freed openmutex.
Take a device reference before touching the disk, like blkdevgetnoopen() does, and skip the bdev if it's on its way out.
Affected Software
Event History
Frequently Asked Questions
What conditions are required to trigger this issue?
A sync(2) operation must race with the last close of a partition whose underlying disk has already been deleted. The race can cause sync_bdevs() to lock the open_mutex of a freed gendisk.
Are whole-disk devices affected in the same way as partitions?
The described lifetime issue is specific to partitions. A partition inode does not keep the gendisk alive; the partition device reference does, and releasing the final device reference can drop the disk.
How does the fix prevent the use-after-free?
The fix takes a device reference before accessing the disk, as blkdev_get_no_open() does. It also skips block devices that are already being removed.