CVE-2026-142987: usb: gadget: f_mass_storage: take filesem in nofua store to fix backing-file UAF

Published Dec 3, 2026
·
Updated

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

1 affected component
Linux Linux kernel

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Compensating control

    In the Linux USB gadget mass-storage code, hold filesem for read around the fsync in fsg_store_nofua() so the backing file cannot be closed while it is being dereferenced.

Event History

Dec 3, 2026
CVE Published
via MITRE·09:17 AM
Data Sourced
via MITRE·09:17 AM
Description

Frequently Asked Questions

1

Which systems are exposed to this issue?

Systems using the Linux USB gadget mass-storage function with a LUN backed by a file are exposed when that backing file can be closed while gadget settings are being changed. Systems not using f_mass_storage or without a configured backing file are not described as affected.

2

What must happen for exploitation or a crash to occur?

A change from asynchronous to synchronous no-FUA behavior must cause fsg_store_nofua() to sync the LUN backing file while another operation closes that file. The close can occur through clearing the backing-file path, a SCSI START_STOP eject request, or a forced eject.

3

What can be done before applying the fix?

Avoid concurrently changing the nofua setting and closing or ejecting the mass-storage LUN backing file. Operationally, serialize configuration changes and eject or forced-eject actions for the same LUN.

4

How can administrators recognize the issue in logs?

The reported failure is a KASAN slab-use-after-free involving vfs_fsync, with fsg_lun_fsync_sub and fsg_store_nofua in the call trace. Related traces may show the backing file allocated or freed through fsg_store_file and __fput.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203