USB: core: Fix hang in usb_kill_urb by adding memory barriers
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ 49367d8f1d9f26482cf7089489e90f0afd0a942c · < e3b131e30e612ff0e32de6c1cb4f69f89db29193| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
USB: core: Fix hang in usb_kill_urb by adding memory barriers
The syzbot fuzzer has identified a bug in which processes hang waiting for usb_kill_urb() to return. It turns out the issue is not unlinking the URB; that works just fine. Rather, the problem arises when the wakeup notification that the URB has completed is not received.
The reason is memory-access ordering on SMP systems. In outline form, usb_kill_urb() and __usb_hcd_giveback_urb() operating concurrently on different CPUs perform the following actions:
CPU 0 CPU 1 ---------------------------- --------------------------------- usb_kill_urb(): __usb_hcd_giveback_urb(): ... ... atomic_inc(&urb->reject); atomic_dec(&urb->use_count); ... ... wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0); if (atomic_read(&urb->reject)) wake_up(&usb_kill_urb_queue);
Confining your attention to urb->reject and urb->use_count, you can see that the overall pattern of accesses on CPU 0 is:
write urb->reject, then read urb->use_count;
whereas the overall pattern of accesses on CPU 1 is:
From the CVE record · Linux
A memory-ordering bug in the Linux kernel USB core can leave processes waiting indefinitely for usb_kill_urb() to return. It occurs when USB operations run concurrently on different CPUs in an SMP system. The input does not establish an attacker trigger, access requirements, or user-interaction requirements.
Engineers running Linux kernels on SMP systems should check whether their kernel includes the USB core fix; affected versions are not specified.