HIGH Introduced in 4.0
usb-gadget FunctionFS UAF
CVE-2026-90044
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
KernelScan AI6.9MEDIUM
01Description
In the Linux kernel, the following vulnerability has been resolved: usb: gadget: f_fs: Fix Use-After-Free in AIO error path In ffs_epfile_write_iter() and ffs_epfile_read_iter(), when ffs_epfile_io() fails with an error other than -EIOCBQUEUED, the io_data structure (`p`) is freed. However, for AIO operations, the kiocb cancel function was already armed and kiocb->private was set to `p`. If a concurrent cancel operation (such as sys_io_cancel()) executes after ffs_epfile_io() fails but before the function frees `p`, a Use-After-Free can occur when the cancellation handler accesses the freed pointer. To securely fix this race condition, we must properly un-arm the cancellation. Invoking `kiocb->ki_complete()` does exactly this by acquiring `ctx->ctx_lock` and safely removing the kiocb from the active sequence. In doing so, it ensures that a parallel io_cancel can no longer discover the kiocb, effectively closing the race window. We then return -EIOCBQUEUED to notify the VFS layer that the kiocb has been consumed and it should avoid attempting to complete the request again or triggering subsequent completion handlers.
02KernelScan AI Analysis
Risk summary
A local process with access to USB gadget FunctionFS endpoint files can exploit a race condition in the asynchronous I/O error path to trigger a use-after-free, potentially achieving kernel-level code execution or causing a system crash. The vulnerability requires the USB gadget subsystem to be configured and FunctionFS to be in use, and exploitation depends on winning a concurrent cancellation race.
Vulnerability analysis
The FunctionFS driver, which lets userspace programs implement USB gadget functions, has a race condition in its asynchronous I/O error handling path. When an AIO read or write operation on a FunctionFS endpoint file fails, the cleanup code frees the internal I/O data structure while the kernel's AIO cancellation machinery still holds a pointer to it. A concurrent cancellation request can then dereference the freed structure, corrupting kernel memory. The fix properly disarms the cancellation before freeing the structure by invoking the kiocb completion handler, which removes the request from the active AIO list under its lock, and then returns a status telling the VFS layer that the request has already been handled. The vulnerability is reachable by any local process that has access to FunctionFS endpoint files and can issue asynchronous I/O and cancellation requests, requiring the USB gadget subsystem to be configured on the device.
Lifecycle
03Fix Versions
| Branch | Introduced | Fixed in | Patch commit |
|---|---|---|---|
| 6.12 | 4.0 | 6.12.111 | b5f0e80a03e8 |
| 6.18 | 4.0 | 6.18.51 | 153b5ecd29ed |
| 6.6 | 4.0 | 6.6.160 | 0a2f71ccf9c2 |
| 7.2 | 4.0 | 7.2.5 | 4a2fb2d12b87 |
| mainline | 4.0 | 7.3 | e78dcb1f7ec2 |
| cip/6.12 | 4.0 | 6.12.111-cip32 | b5f0e80a03e8 |
04CIP Kernels
State of the newest release of each Civil Infrastructure Platform SLTS tree, from CIP's own fix records.
| CIP tree | State |
|---|---|
| cip/6.12 | Fixed in 6.12.111-cip32 |
| cip/6.1 | Affected — no CIP fix yet (latest 6.1.189-cip61) |
| cip/6.1-rt | Affected — no CIP fix yet (latest 6.1.189-cip61-rt32) |
| cip/5.10 | Affected — no CIP fix yet (latest 5.10.271-cip78) |
| cip/5.10-rt | Affected — no CIP fix yet (latest 5.10.268-cip77-rt34) |
| cip/4.19 | Affected — no CIP fix yet (latest 4.19.325-cip136) |
| cip/4.19-rt | Affected — no CIP fix yet (latest 4.19.325-cip136-rt50) |
| cip/4.4 | Affected — no CIP fix yet (latest 4.4.302-cip115) |
| cip/4.4-rt | Affected — no CIP fix yet (latest 4.4.302-cip115-rt63) |