net: nfc: fix deadlock between nfc_unregister_device and rfkill_fop_write
- Published
- Last modified
- Where the record stands: published, rejected by its publisher, or superseded by another id.What do these mean? →
- published
- Whether CISA lists it in its Known Exploited Vulnerabilities catalog: proof that attackers are using it.What do these mean? →
- Not listed in CISA KEV
- Fix
- Fixed in 5.10.248, 5.15.198, 4.5, 4.10, 4.15, and 6 more
- Whether working attack code is public (Exploit-DB, Metasploit, Nuclei or GitHub). Public code makes attacks easier.What do these mean? →
- None on Exploit-DB, Metasploit or GitHub
Summary
In the Linux kernel, the following vulnerability has been resolved: net: nfc: fix deadlock between nfc_unregister_device and rfkill_fop_write A deadlock can occur between nfc_unregister_device() and rfkill_fop_write() due to lock ordering inversion between device_lock and rfkill_global_mutex. The problematic lock order is: Thread A (rfkill_fop_write): rfkill_fop_write() mutex_lock(&rfkill_global_mutex) rfkill_set_block() nfc_rfkill_set_block() nfc_dev_down() device_lock(&dev->dev) <- waits for device_lock Thread B (nfc_unregister_device): nfc_unregister_device() device_lock(&dev->dev) rfkill_unregister() mutex_lock(&rfkill_global_mutex) <- waits for rfkill_global_mutex This creates a classic ABBA deadlock scenario. Fix this by moving rfkill_unregister() and rfkill_destroy() outside the device_lock critical section. Store the rfkill pointer in a local variable before releasing the lock, then call rfkill_unregister() after releasing device_lock. This change is safe because rfkill_fop_write() holds rfkill_global_mutex while calling the rfkill callbacks, and rfkill_unregister() also acquires rfkill_global_mutex before cleanup. Therefore, rfkill_unregister() will wait for any ongoing callback to complete before proceeding, and device_del() is only called after rfkill_unregister() returns, preventing any use-after-free. The similar lock ordering in nfc_register_device() (device_lock -> rfkill_global_mutex via rfkill_register) is safe because during registration the device is not yet in rfkill_list, so no concurrent rfkill operations can occur on this device.
Timeline
- CVE published
- Record last updated
Affected versions
- Linux Linux
From 73a0d12114b4bc1a9def79a623264754b9df698e · fixed in 2e0831e9fc46a06daa6d4d8d57a2738e343130c3; From 8a9c61c3ef187d8891225f9b932390670a43a0d3 · fixed in e02a1c33f10a0ed3aba855ab8ae2b6c4c5be8012; From 3e3b5dfcd16a3e254aab61bd1e8c417dd4503102 · fixed in ee41f4f3ccf8cd6ba3732e867abbec7e6d8d12e5; From 3e3b5dfcd16a3e254aab61bd1e8c417dd4503102 · fixed in 6b93c8ab6f6cda8818983a4ae3fcf84b023037b4; From 3e3b5dfcd16a3e254aab61bd1e8c417dd4503102 · fixed in 8fc4632fb508432895430cd02b38086bdd649083; From 3e3b5dfcd16a3e254aab61bd1e8c417dd4503102 · fixed in f3a8a7c1aa278f2378b2f3a10500c6674dffdfda; From 3e3b5dfcd16a3e254aab61bd1e8c417dd4503102 · fixed in 1ab526d97a57e44d26fadcc0e9adeb9c0c0182f5; From 5.10.82 · fixed in 5.10.248; From 5.15.5 · fixed in 5.15.198; From 4.4.293 · fixed in 4.5; From 4.9.291 · fixed in 4.10; From 4.14.256 · fixed in 4.15; From 4.19.218 · fixed in 4.20; From 5.4.162 · fixed in 5.5
- Linux Linux
5.16
- KernelLinux
fixed in 5.10.248; From 5.11.0 · fixed in 5.15.198; From 5.16.0 · fixed in 6.1.160; fixed in 6.6.120; From 6.2.0 · fixed in 6.12.64; From 6.7.0 · fixed in 6.18.4
References 7
git.kernel.org
- stable/c/2e0831e9fc46a06daa6d4d8d57a2738e343130c3
- stable/c/e02a1c33f10a0ed3aba855ab8ae2b6c4c5be8012
- stable/c/ee41f4f3ccf8cd6ba3732e867abbec7e6d8d12e5
- stable/c/6b93c8ab6f6cda8818983a4ae3fcf84b023037b4
- stable/c/8fc4632fb508432895430cd02b38086bdd649083
- stable/c/f3a8a7c1aa278f2378b2f3a10500c6674dffdfda
- stable/c/1ab526d97a57e44d26fadcc0e9adeb9c0c0182f5