net: nfc: fix deadlock between nfc_unregister_device and rfkill_fop_write
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ 3e3b5dfcd16a3e254aab61bd1e8c417dd4503102 · < f3a8a7c1aa278f2378b2f3a10500c6674dffdfda| No fix yet |
| Linux Linux |
|
|
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.
From the CVE record · Linux
The Linux kernel’s NFC device unregister path can deadlock with an rfkill write because the two paths acquire locks in opposite orders. A local user who can write to rfkill could trigger the deadlock if that write overlaps with NFC device unregistration; the input does not specify the permissions needed to write to rfkill.
Engineers running Linux kernels with NFC support should check their kernel against the vendor advisory; affected versions are not specified.