{"id":"CVE-2026-142987","sourceIdentifier":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","published":"2026-12-03T10:17:23.153","lastModified":"2026-12-03T10:17:23.153","vulnStatus":"Received","cveTags":[],"descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\nusb: gadget: f_mass_storage: take filesem in nofua store to fix backing-file UAF\n\nfsg_store_nofua() syncs the LUN's backing file when switching from async\nto sync mode:\n\n\tif (!nofua && curlun->nofua)\n\t\tfsg_lun_fsync_sub(curlun);\n\nfsg_lun_fsync_sub() dereferences curlun->filp (vfs_fsync(filp)). Unlike\nevery other store that touches the backing file -- fsg_store_ro() and\nfsg_store_cdrom() (down_read), fsg_store_file() (down_write) --\nfsg_store_nofua() holds no filesem while doing so.\n\nA concurrent close of the backing file runs under down_write(filesem) and\ndoes fput(curlun->filp) in fsg_lun_close() (fsg_store_file() with an empty\npath, the SCSI START_STOP eject in do_start_stop(), or forced_eject), so\nit can free the file while fsg_store_nofua() is dereferencing it:\n\n\tBUG: KASAN: slab-use-after-free in vfs_fsync+0x20/0xe0\n\t vfs_fsync+0x20/0xe0\n\t fsg_lun_fsync_sub+0xa0/0xd0\n\t fsg_store_nofua+0x138/0x160\n\t configfs_write_iter+0x1a7/0x250\n\t vfs_write+0x5df/0x940\n\tAllocated by task 3459:\n\t fsg_store_file+0x150/0x1f0\n\t configfs_write_iter+0x1a7/0x250\n\tFreed by task 3459:\n\t __fput+0x456/0x6c0\n\t __fput_deferred+0x10d/0x330\n\t fsg_store_file+0x9e/0x1f0\n\t configfs_write_iter+0x1a7/0x250\n\nHold filesem for read around the fsync in fsg_store_nofua() so the backing\nfile cannot be closed underneath it. The lock is only needed when the\nfsync actually runs, so it is taken only in that branch.\n\nReproduced on a mass_storage gadget over dummy_hcd by writing lun.N/nofua\n(1 then 0) from one task while another task rewrites and clears lun.N/file."}],"affected":[{"source":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","affectedData":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","programFiles":["drivers/usb/gadget/function/f_mass_storage.c","drivers/usb/gadget/function/storage_common.c","drivers/usb/gadget/function/storage_common.h"],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","versions":[{"version":"1da177e4c3f41524e886b7f1b8a0c1fc7321cac2","lessThan":"94bc557fc0c78e7c148974baf0be33db9b3cbc93","versionType":"git","status":"affected"},{"version":"1da177e4c3f41524e886b7f1b8a0c1fc7321cac2","lessThan":"02d11b2e20bbd98b6496458ebc7522f6d429dc36","versionType":"git","status":"affected"},{"version":"1da177e4c3f41524e886b7f1b8a0c1fc7321cac2","lessThan":"2ef64b32ceb561e85d572ed2b7aaa45d36087f26","versionType":"git","status":"affected"},{"version":"1da177e4c3f41524e886b7f1b8a0c1fc7321cac2","lessThan":"5c0e66058314fc994feef9e1a1879146ea3698b6","versionType":"git","status":"affected"},{"version":"1da177e4c3f41524e886b7f1b8a0c1fc7321cac2","lessThan":"efe2605be71f6f22dcdf08fa9a0b1669e41a68d2","versionType":"git","status":"affected"},{"version":"1da177e4c3f41524e886b7f1b8a0c1fc7321cac2","lessThan":"450fa94d7ae9fc91c3df525f5d1322bf8fecf7b2","versionType":"git","status":"affected"},{"version":"0","lessThan":"5.10.276","versionType":"semver","status":"affected"},{"version":"0","lessThan":"5.15.227","versionType":"semver","status":"affected"},{"version":"0","lessThan":"6.12.120","versionType":"semver","status":"affected"},{"version":"0","lessThan":"6.18.66","versionType":"semver","status":"affected"},{"version":"0","lessThan":"7.3.7","versionType":"semver","status":"affected"}]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","programFiles":["drivers/usb/gadget/function/f_mass_storage.c","drivers/usb/gadget/function/storage_common.c","drivers/usb/gadget/function/storage_common.h"],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","versions":[{"version":"5.10.276","lessThanOrEqual":"5.10.*","versionType":"semver","status":"unaffected"},{"version":"5.15.227","lessThanOrEqual":"5.15.*","versionType":"semver","status":"unaffected"},{"version":"6.12.120","lessThanOrEqual":"6.12.*","versionType":"semver","status":"unaffected"},{"version":"6.18.66","lessThanOrEqual":"6.18.*","versionType":"semver","status":"unaffected"},{"version":"7.3.7","lessThanOrEqual":"7.3.*","versionType":"semver","status":"unaffected"},{"version":"7.4-rc4","lessThanOrEqual":"*","versionType":"original_commit_for_fix","status":"unaffected"}]}]}],"metrics":{},"references":[{"url":"https://git.kernel.org/stable/c/02d11b2e20bbd98b6496458ebc7522f6d429dc36","source":"416baaa9-dc9f-4396-8d5f-8c081fb06d67"},{"url":"https://git.kernel.org/stable/c/2ef64b32ceb561e85d572ed2b7aaa45d36087f26","source":"416baaa9-dc9f-4396-8d5f-8c081fb06d67"},{"url":"https://git.kernel.org/stable/c/450fa94d7ae9fc91c3df525f5d1322bf8fecf7b2","source":"416baaa9-dc9f-4396-8d5f-8c081fb06d67"},{"url":"https://git.kernel.org/stable/c/5c0e66058314fc994feef9e1a1879146ea3698b6","source":"416baaa9-dc9f-4396-8d5f-8c081fb06d67"},{"url":"https://git.kernel.org/stable/c/94bc557fc0c78e7c148974baf0be33db9b3cbc93","source":"416baaa9-dc9f-4396-8d5f-8c081fb06d67"},{"url":"https://git.kernel.org/stable/c/efe2605be71f6f22dcdf08fa9a0b1669e41a68d2","source":"416baaa9-dc9f-4396-8d5f-8c081fb06d67"}]}