KernelScan.io

HIGH Introduced in 4.0

usb-gadget FunctionFS UAF

CVE-2026-90044

CVSS 7.8 / 10.0 NVD

CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

KernelScan AI6.9MEDIUM

01

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.

02

Engine v0.6.0

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.

Affecteddrivers/usb/gadget/function/f_fs.c (USB gadget FunctionFS)

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.

03

BranchIntroducedFixed inPatch commit
6.124.06.12.111b5f0e80a03e8
6.184.06.18.51153b5ecd29ed
6.64.06.6.1600a2f71ccf9c2
7.24.07.2.54a2fb2d12b87
mainline4.07.3e78dcb1f7ec2
cip/6.124.06.12.111-cip32b5f0e80a03e8

04

State of the newest release of each Civil Infrastructure Platform SLTS tree, from CIP's own fix records.

CIP treeState
cip/6.12Fixed in 6.12.111-cip32
cip/6.1Affected — no CIP fix yet (latest 6.1.189-cip61)
cip/6.1-rtAffected — no CIP fix yet (latest 6.1.189-cip61-rt32)
cip/5.10Affected — no CIP fix yet (latest 5.10.271-cip78)
cip/5.10-rtAffected — no CIP fix yet (latest 5.10.268-cip77-rt34)
cip/4.19Affected — no CIP fix yet (latest 4.19.325-cip136)
cip/4.19-rtAffected — no CIP fix yet (latest 4.19.325-cip136-rt50)
cip/4.4Affected — no CIP fix yet (latest 4.4.302-cip115)
cip/4.4-rtAffected — no CIP fix yet (latest 4.4.302-cip115-rt63)