CVE-2024-26899: block: fix deadlock between bd_link_disk_holder and partition scan
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
block: fix deadlock between bd_link_disk_holder and partition scan
'open_mutex' of gendisk is used to protect open/close block devices. But in bd_link_disk_holder(), it is used to protect the creation of symlink between holding disk and slave bdev, which introduces some issues.
When bd_link_disk_holder() is called, the driver is usually in the process of initialization/modification and may suspend submitting io. At this time, any io hold 'open_mutex', such as scanning partitions, can cause deadlocks. For example, in raid:
T1 T2bdev_open_by_dev
lock open_mutex [1]
...
efi_partition
...
md_submit_bio
md_ioctl mddev_syspend
-> suspend all io
md_add_new_disk
bind_rdev_to_array
bd_link_disk_holder
try lock open_mutex [2]
md_handle_request
-> wait mddev_resumeT1 scan partition, T2 add a new device to raid. T1 waits for T2 to resume mddev, but T2 waits for open_mutex held by T1. Deadlock occurs.
Fix it by introducing a local mutex 'blk_holder_mutex' to replace 'open_mutex'.
The Linux kernel CVE team has assigned CVE-2024-26899 to this issue.
Affected and fixed versions
===========================
Issue introduced in 6.7 with commit 1b0a2d950ee2 and fixed in 6.7.11 with commit 1e5c5b0abaee Issue introduced in 6.7 with commit 1b0a2d950ee2 and fixed in 6.8.2 with commit 5a87c1f7993b Issue introduced in 6.7 with commit 1b0a2d950ee2 and fixed in 6.9-rc1 with commit 03f12122b20b
Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.
Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at
https://cve.org/CVERecord/?id=CVE-2024-26899
will be updated if fixes are backported, please check that for the most up to date information about this issue.
Affected files
==============
The file(s) affected by this issue are:
block/holder.c
Mitigation
==========
The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:
https://git.kernel.org/stable/c/1e5c5b0abaee7b62a10b9707a62083b71ad21f62 https://git.kernel.org/stable/c/5a87c1f7993bc8ac358a3766bac5dc7126e01e98 https://git.kernel.org/stable/c/03f12122b20b6e6028e9ed69030a49f9cffcbb75