{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2025-40054","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","state":"PUBLISHED","assignerShortName":"Linux","dateReserved":"2025-04-16T07:20:57.157Z","datePublished":"2025-10-28T11:48:29.073Z","dateUpdated":"2026-08-23T12:45:24.871Z"},"containers":{"cna":{"providerMetadata":{"orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","shortName":"Linux","dateUpdated":"2026-08-23T12:45:24.871Z"},"descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\nf2fs: fix UAF issue in f2fs_merge_page_bio()\n\nAs JY reported in bugzilla [1],\n\nUnable to handle kernel NULL pointer dereference at virtual address 0000000000000000\npc : [0xffffffe51d249484] f2fs_is_cp_guaranteed+0x70/0x98\nlr : [0xffffffe51d24adbc] f2fs_merge_page_bio+0x520/0x6d4\nCPU: 3 UID: 0 PID: 6790 Comm: kworker/u16:3 Tainted: P    B   W  OE      6.12.30-android16-5-maybe-dirty-4k #1 5f7701c9cbf727d1eebe77c89bbbeb3371e895e5\nTainted: [P]=PROPRIETARY_MODULE, [B]=BAD_PAGE, [W]=WARN, [O]=OOT_MODULE, [E]=UNSIGNED_MODULE\nWorkqueue: writeback wb_workfn (flush-254:49)\nCall trace:\n f2fs_is_cp_guaranteed+0x70/0x98\n f2fs_inplace_write_data+0x174/0x2f4\n f2fs_do_write_data_page+0x214/0x81c\n f2fs_write_single_data_page+0x28c/0x764\n f2fs_write_data_pages+0x78c/0xce4\n do_writepages+0xe8/0x2fc\n __writeback_single_inode+0x4c/0x4b4\n writeback_sb_inodes+0x314/0x540\n __writeback_inodes_wb+0xa4/0xf4\n wb_writeback+0x160/0x448\n wb_workfn+0x2f0/0x5dc\n process_scheduled_works+0x1c8/0x458\n worker_thread+0x334/0x3f0\n kthread+0x118/0x1ac\n ret_from_fork+0x10/0x20\n\n[1] https://bugzilla.kernel.org/show_bug.cgi?id=220575\n\nThe panic was caused by UAF issue w/ below race condition:\n\nkworker\n- writepages\n - f2fs_write_cache_pages\n  - f2fs_write_single_data_page\n   - f2fs_do_write_data_page\n    - f2fs_inplace_write_data\n     - f2fs_merge_page_bio\n      - add_inu_page\n      : cache page #1 into bio & cache bio in\n        io->bio_list\n  - f2fs_write_single_data_page\n   - f2fs_do_write_data_page\n    - f2fs_inplace_write_data\n     - f2fs_merge_page_bio\n      - add_inu_page\n      : cache page #2 into bio which is linked\n        in io->bio_list\n\t\t\t\t\t\twrite\n\t\t\t\t\t\t- f2fs_write_begin\n\t\t\t\t\t\t: write page #1\n\t\t\t\t\t\t - f2fs_folio_wait_writeback\n\t\t\t\t\t\t  - f2fs_submit_merged_ipu_write\n\t\t\t\t\t\t   - f2fs_submit_write_bio\n\t\t\t\t\t\t   : submit bio which inclues page #1 and #2\n\n\t\t\t\t\t\tsoftware IRQ\n\t\t\t\t\t\t- f2fs_write_end_io\n\t\t\t\t\t\t - fscrypt_free_bounce_page\n\t\t\t\t\t\t : freed bounced page which belongs to page #2\n      - inc_page_count( , WB_DATA_TYPE(data_folio), false)\n      : data_folio points to fio->encrypted_page\n        the bounced page can be freed before\n        accessing it in f2fs_is_cp_guarantee()\n\nIt can reproduce w/ below testcase:\nRun below script in shell #1:\nfor ((i=1;i>0;i++)) do xfs_io -f /mnt/f2fs/enc/file \\\n-c \"pwrite 0 32k\" -c \"fdatasync\"\n\nRun below script in shell #2:\nfor ((i=1;i>0;i++)) do xfs_io -f /mnt/f2fs/enc/file \\\n-c \"pwrite 0 32k\" -c \"fdatasync\"\n\nSo, in f2fs_merge_page_bio(), let's avoid using fio->encrypted_page after\ncommit page into internal ipu cache."}],"metrics":[{"cvssV3_1":{"version":"3.1","vectorString":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","baseScore":7.8,"baseSeverity":"HIGH"},"scenarios":[{"lang":"en","value":"AV:L - The bug is reached through ordinary local filesystem syscalls (write/pwrite plus fdatasync) on a mounted f2fs volume, driving the writeback kworker into f2fs_merge_page_bio(); no network or remote peer data is involved.\nAC:L - The attacker controls both sides of the race — one thread's writeback caches the encrypted bounce page in the IPU bio list while a second thread's f2fs_write_begin → f2fs_folio_wait_writeback submits that same bio and frees the bounce page — and the commit supplies a trivial two-shell reproducer loop, so it can be hit reliably by repetition.\nPR:L - Only an unprivileged local user with write access to a file in an fscrypt-encrypted directory on f2fs is needed; this is the default state for every app on Android/ChromeOS f2fs /data, and elsewhere any user can set a v2 encryption policy on their own directory without CAP_SYS_ADMIN.\nUI:N - No victim action is required — the attacker's own two processes perform all writes and syncs against an already-mounted filesystem, and the racing writeback kworker runs automatically.\nS:U - The freed object, the corrupted accounting counters and the faulting code all live within the kernel's own security authority; no VM, IOMMU or sandbox boundary is crossed.\nC:H - This is a use-after-free read of a freed fscrypt bounce-page descriptor whose contents are reused by whatever next owns that page, and the stale pointer read from it is dereferenced, giving an attacker-influenceable wild read of kernel memory that leaks into observable filesystem accounting state.\nI:H - Use-after-free of a mempool page that can be recycled into arbitrary kernel allocations makes heap grooming and control over the dereferenced pointer feasible, and the garbage value directly corrupts persistent sbi->nr_pages writeback accounting, wedging checkpoint state machine decisions such as f2fs_stop_checkpoint.\nA:H - The bug is confirmed in the wild to panic the kernel with a NULL pointer dereference in f2fs_is_cp_guaranteed() from the writeback kworker, and a mismatched WB_DATA_TYPE increment leaves F2FS_WB_CP_DATA permanently non-zero, hanging f2fs_wait_on_all_pages() in an uninterruptible loop so sync/umount never complete."}]}],"affected":[{"product":"Linux","vendor":"Linux","defaultStatus":"unaffected","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["fs/f2fs/data.c"],"versions":[{"version":"0b20fcec8651569935a10afe03fedc0b812d044e","lessThan":"1f7b44b4a2b2939f08b279cbb9e6b5dcb8ffea32","status":"affected","versionType":"git"},{"version":"0b20fcec8651569935a10afe03fedc0b812d044e","lessThan":"e193d8953647c8b575830852aa5ea0995b98d2b1","status":"affected","versionType":"git"},{"version":"0b20fcec8651569935a10afe03fedc0b812d044e","lessThan":"410337c2301ae78a081e1b5ebbe8ec374fef4cb6","status":"affected","versionType":"git"},{"version":"0b20fcec8651569935a10afe03fedc0b812d044e","lessThan":"68e094232dfe5027c4fd2dcded93d2d6800bae04","status":"affected","versionType":"git"},{"version":"0b20fcec8651569935a10afe03fedc0b812d044e","lessThan":"7dd611131d82d7fc4212b555eb1103160bdad302","status":"affected","versionType":"git"},{"version":"0b20fcec8651569935a10afe03fedc0b812d044e","lessThan":"01118321e0c8a5f3ece57d0d377bfc92d83cd210","status":"affected","versionType":"git"},{"version":"0b20fcec8651569935a10afe03fedc0b812d044e","lessThan":"edf7e9040fc52c922db947f9c6c36f07377c52ea","status":"affected","versionType":"git"}]},{"product":"Linux","vendor":"Linux","defaultStatus":"affected","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["fs/f2fs/data.c"],"versions":[{"version":"5.5","status":"affected"},{"version":"0","lessThan":"5.5","status":"unaffected","versionType":"semver"},{"version":"5.10.266","lessThanOrEqual":"5.10.*","status":"unaffected","versionType":"semver"},{"version":"5.15.217","lessThanOrEqual":"5.15.*","status":"unaffected","versionType":"semver"},{"version":"6.1.184","lessThanOrEqual":"6.1.*","status":"unaffected","versionType":"semver"},{"version":"6.6.153","lessThanOrEqual":"6.6.*","status":"unaffected","versionType":"semver"},{"version":"6.12.105","lessThanOrEqual":"6.12.*","status":"unaffected","versionType":"semver"},{"version":"6.17.3","lessThanOrEqual":"6.17.*","status":"unaffected","versionType":"semver"},{"version":"6.18","lessThanOrEqual":"*","status":"unaffected","versionType":"original_commit_for_fix"}]}],"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.5","versionEndExcluding":"5.10.266"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.5","versionEndExcluding":"5.15.217"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.5","versionEndExcluding":"6.1.184"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.5","versionEndExcluding":"6.6.153"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.5","versionEndExcluding":"6.12.105"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.5","versionEndExcluding":"6.17.3"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.5","versionEndExcluding":"6.18"}]}]}],"references":[{"url":"https://git.kernel.org/stable/c/1f7b44b4a2b2939f08b279cbb9e6b5dcb8ffea32"},{"url":"https://git.kernel.org/stable/c/e193d8953647c8b575830852aa5ea0995b98d2b1"},{"url":"https://git.kernel.org/stable/c/410337c2301ae78a081e1b5ebbe8ec374fef4cb6"},{"url":"https://git.kernel.org/stable/c/68e094232dfe5027c4fd2dcded93d2d6800bae04"},{"url":"https://git.kernel.org/stable/c/7dd611131d82d7fc4212b555eb1103160bdad302"},{"url":"https://git.kernel.org/stable/c/01118321e0c8a5f3ece57d0d377bfc92d83cd210"},{"url":"https://git.kernel.org/stable/c/edf7e9040fc52c922db947f9c6c36f07377c52ea"}],"title":"f2fs: fix UAF issue in f2fs_merge_page_bio()","x_generator":{"engine":"bippy-1.2.0"}}}}