AZL-117881: CVE-2026-142987 affecting package kernel 6.6.161.1-1
In the Linux kernel, the following vulnerability has been resolved:
usb: gadget: fmassstorage: take filesem in nofua store to fix backing-file UAF
fsgstorenofua() syncs the LUN's backing file when switching from async to sync mode:
if (!nofua && curlun->nofua) fsglunfsyncsub(curlun);
fsglunfsyncsub() dereferences curlun->filp (vfsfsync(filp)). Unlike every other store that touches the backing file -- fsgstorero() and fsgstorecdrom() (downread), fsgstorefile() (downwrite) -- fsgstorenofua() holds no filesem while doing so.
A concurrent close of the backing file runs under downwrite(filesem) and does fput(curlun->filp) in fsglunclose() (fsgstorefile() with an empty path, the SCSI STARTSTOP eject in dostartstop(), or forcedeject), so it can free the file while fsgstorenofua() is dereferencing it:
BUG: KASAN: slab-use-after-free in vfsfsync+0x20/0xe0 vfsfsync+0x20/0xe0 fsglunfsyncsub+0xa0/0xd0 fsgstorenofua+0x138/0x160 configfswriteiter+0x1a7/0x250 vfswrite+0x5df/0x940 Allocated by task 3459: fsgstorefile+0x150/0x1f0 configfswriteiter+0x1a7/0x250 Freed by task 3459: fput+0x456/0x6c0 fputdeferred+0x10d/0x330 fsgstorefile+0x9e/0x1f0 configfswriteiter+0x1a7/0x250
Hold filesem for read around the fsync in fsgstorenofua() so the backing file cannot be closed underneath it. The lock is only needed when the fsync actually runs, so it is taken only in that branch.
Reproduced on a massstorage gadget over dummyhcd by writing lun.N/nofua (1 then 0) from one task while another task rewrites and clears lun.N/file.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
In fsg_store_nofua(), hold filesem for read around the fsync so the backing file cannot be closed while it is being accessed.
Event History
Frequently Asked Questions
What conditions are required to trigger this issue?
The system must be using the USB gadget mass-storage function with a LUN backed by a file. A concurrent operation must close or eject that backing file while another operation changes the nofua setting from asynchronous to synchronous mode, causing a sync of the file.
Which operations can race with the nofua setting change?
Closing the backing file through an empty-path write to the file attribute, a SCSI START_STOP eject operation, or a forced eject can free the backing file while the nofua store handler is using it. The resulting condition is a use-after-free during vfs_fsync.
Is the vulnerable behavior limited to a particular backing-file configuration?
The described race applies when a mass-storage LUN has a backing file and its nofua setting is switched from async to sync mode. The provided data does not establish whether the USB gadget mass-storage function or this configuration is enabled by default.
What can be done if the updated kernel cannot be deployed immediately?
Avoid changing the nofua setting from asynchronous to synchronous mode while the LUN backing file might be closed or ejected. Serialize those configuration and eject/close operations so the backing file cannot be released during the nofua update.