nfc: nci: Fix race between rfkill and nci_unregister_device().
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ 6a2968aaf50c7a22fced77a5e24aa636281efca8 · < c3369fc5e6120a72169e71acd72e987907a682af| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
nfc: nci: Fix race between rfkill and nci_unregister_device().
syzbot reported the splat below [0] without a repro.
It indicates that struct nci_dev.cmd_wq had been destroyed before nci_close_device() was called via rfkill.
nci_dev.cmd_wq is only destroyed in nci_unregister_device(), which (I think) was called from virtual_ncidev_close() when syzbot close()d an fd of virtual_ncidev.
The problem is that nci_unregister_device() destroys nci_dev.cmd_wq first and then calls nfc_unregister_device(), which removes the device from rfkill by rfkill_unregister().
So, the device is still visible via rfkill even after nci_dev.cmd_wq is destroyed.
Let's unregister the device from rfkill first in nci_unregister_device().
From the CVE record · Linux
The Linux kernel's NFC NCI code has a race between rfkill access and device unregistration. If rfkill calls nci_close_device() after the device's command workqueue has been destroyed, the kernel can report a locking warning. The report describes a local device-close scenario; it does not establish an authentication requirement or a need for user interaction.
Engineers running Linux kernels with NFC NCI support should check whether their kernel is affected; affected versions were not provided.