usb: gadget: f_mass_storage: take filesem in nofua store to fix backing-file UAF
- CVE-2026-142987
- GHSA-h3g4-6fr3-q6j6
- EUVD-2026-142603
Description
Show the whole descriptionHide the whole description
In the Linux kernel, the following vulnerability has been resolved: usb: gadget: f_mass_storage: take filesem in nofua store to fix backing-file UAF fsg_store_nofua() syncs the LUN's backing file when switching from async to sync mode: if (!nofua && curlun->nofua) fsg_lun_fsync_sub(curlun); fsg_lun_fsync_sub() dereferences curlun->filp (vfs_fsync(filp)). Unlike every other store that touches the backing file -- fsg_store_ro() and fsg_store_cdrom() (down_read), fsg_store_file() (down_write) -- fsg_store_nofua() holds no filesem while doing so. A concurrent close of the backing file runs under down_write(filesem) and does fput(curlun->filp) in fsg_lun_close() (fsg_store_file() with an empty path, the SCSI START_STOP eject in do_start_stop(), or forced_eject), so it can free the file while fsg_store_nofua() is dereferencing it: BUG: KASAN: slab-use-after-free in vfs_fsync+0x20/0xe0 vfs_fsync+0x20/0xe0 fsg_lun_fsync_sub+0xa0/0xd0 fsg_store_nofua+0x138/0x160 configfs_write_iter+0x1a7/0x250 vfs_write+0x5df/0x940 Allocated by task 3459: fsg_store_file+0x150/0x1f0 configfs_write_iter+0x1a7/0x250 Freed by task 3459: __fput+0x456/0x6c0 __fput_deferred+0x10d/0x330 fsg_store_file+0x9e/0x1f0 configfs_write_iter+0x1a7/0x250 Hold filesem for read around the fsync in fsg_store_nofua() 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 mass_storage gadget over dummy_hcd by writing lun.N/nofua (1 then 0) from one task while another task rewrites and clears lun.N/file.
Text from the CVE.org record.
Recommendation
Linux
- If you run a version before 7.3.7update to 7.3.7 or later
- If you run a version before 6.18.66update to 6.18.66 or later
- If you run a version before 6.12.120update to 6.12.120 or later
- If you run a version before 5.15.227update to 5.15.227 or later
- If you run a version before 5.10.276update to 5.10.276 or later
Taken from the version ranges of the CVE.org record. Check the vendor advisory: nothing is said about versions the ranges do not list. Breaking-change risk is read from the version numbers only.
Affected
Linux
Affected versions Fixed in before 7.3.7 7.3.7 before 6.18.66 6.18.66 before 6.12.120 6.12.120 before 5.15.227 5.15.227 before 5.10.276 5.10.276 from 5.10.276 up to 5.10.*: not affected none stated from 5.15.227 up to 5.15.*: not affected none stated from 6.12.120 up to 6.12.*: not affected none stated and 3 more
Product versions from the CVE.org record.
Timeline
- Published
Related news
No article from the followed outlets names this vulnerability.