CVE-2026-143181: ALSA: caiaq: Kill EP1 URB before unregistering the input device
In the Linux kernel, the following vulnerability has been resolved:
ALSA: caiaq: Kill EP1 URB before unregistering the input device
snddisconnect() unregisters the input device via sndusbcaiaqinputdisconnect() and only afterwards kills the EP1 command URB (cdev->ep1inurb). The EP1 completion handler usbep1commandreplydispatch() feeds sndusbcaiaqinputdispatch() for EP1CMDREAD{ERP,ANALOG,IO} replies, which report into cdev->inputdev. Since commit b04dcbb7f7b1 ("ALSA: caiaq: Use sndcardfreewhenclosed() at disconnection") the input device is unregistered from sndusbcaiaqinputdisconnect() but cdev->inputdev is cleared only later, in sndusbcaiaqinputfree() from the card destructor. As the dispatch guard only tests cdev->inputdev for NULL, an EP1 reply that completes after inputunregisterdevice() but before cdev->ep1inurb is killed reports into an input device that has already been unregistered and, with no evdev client holding it open, freed.
Normally the window is closed by the USB core: usbunbindinterface() calls usbdisableinterface() before ->disconnect(), which flushes the EP1 URB as long as endpoint 0x81 belongs to the interface being unbound. But caiaq addresses EP1 through the device-wide pipe usbrcvbulkpipe(usbdev, 0x1) without checking which interface owns the endpoint. If a device declares it in another interface, the URB stays live across snddisconnect() of the interface that owns the card.
This needs a crafted device descriptor; a device that has EP1 in the interface caiaq is bound to is not affected.
Kill cdev->ep1inurb (and the paired midiouturb) before the input and audio disconnect helpers, so no EP1 completion can run once the input device has been unregistered.
Reproduced under KASAN with raw-gadget + dummyhcd emulating an Audio Kontrol 1 (17cc:0815) with the EP1 bulk pair in interface 1: only interface 0 was bound to snd-usb-caiaq and then unbound through sysfs while the gadget flooded EP1 with EP1CMDREADERP replies. With no PCM stream running the window is very short and was only hit by stalling the unbinding CPU with a kgdb breakpoint at sndusbcaiaqaudiodisconnect(). With the fix applied, the same test runs clean.
BUG: KASAN: slab-use-after-free in inputevent+0x3a/0xc0 Read of size 8 at addr ffff8880151a4028 by task sh/118
Call Trace: <IRQ> inputevent+0x3a/0xc0 sndusbcaiaqinputdispatch+0xab2/0xf00 usbep1commandreplydispatch+0x1f3/0x580 usbhcdgivebackurb+0x246/0x400 dummytimer+0x1415/0x3380 hrtimerrunqueues+0x39d/0x800 hrtimerrunsoftirq+0x187/0x2d0 handlesoftirqs+0x1ff/0x930 irqexitrcu+0x15b/0x210 irqexitrcu+0xe/0x20 sysvecapictimerinterrupt+0x81/0xb0 </IRQ> <TASK> asmsysvecapictimerinterrupt+0x1a/0x20 RIP: 0010:sndusbcaiaqaudiodisconnect+0x0/0x70 snddisconnect+0x81/0x110 usbunbindinterface+0x1a0/0x860 devicereleasedriverinternal+0x2c5/0x470 unbindstore+0xde/0x100 </TASK>
Allocated by task 80: inputallocatedevice+0x47/0x340 sndusbcaiaqinputinit+0x4c/0x1ac0 sndprobe+0xab3/0x1160 usbprobeinterface+0x2ea/0x810
Freed by task 118: kfree+0x1ea/0x5c0 inputdevrelease+0xab/0xd0 devicerelease+0xcf/0x250 kobjectput+0x169/0x320 snddisconnect+0x79/0x110 usbunbindinterface+0x1a0/0x860
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 4.20 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 5.5 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 5.10.276 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 5.15.227 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.2 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.7 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.12 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.12.120 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.18.66 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 7.3.7 - Compensating control
Kill cdev->ep1_in_urb and the paired midi_out_urb before unregistering the input device.
Event History
Frequently Asked Questions
Under what circumstances can the use-after-free occur?
An EP1 command reply must complete after the input device has been unregistered but before the EP1 URB is killed. The reported input device can be freed when no evdev client is holding it open.
Is a normal USB interface unbind expected to trigger the issue?
Normally, USB core unbind processing disables the interface before the driver's disconnect callback, flushing the EP1 URB. This protection applies as long as endpoint 0x81 belongs to the interface being unbound.