CVE-2025-40054: f2fs: fix UAF issue in f2fs_merge_page_bio()
In the Linux kernel, the following vulnerability has been resolved:
f2fs: fix UAF issue in f2fs_merge_page_bio()
As JY reported in bugzilla [1],
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
pc : [0xffffffe51d249484] f2fs_is_cp_guaranteed+0x70/0x98
lr : [0xffffffe51d24adbc] f2fs_merge_page_bio+0x520/0x6d4
CPU: 3 UID: 0 PID: 6790 Comm: kworker/u16:3 Tainted: P B W OE 6.12.30-android16-5-maybe-dirty-4k #1 5f7701c9cbf727d1eebe77c89bbbeb3371e895e5
Tainted: [P]=PROPRIETARY_MODULE, [B]=BAD_PAGE, [W]=WARN, [O]=OOT_MODULE, [E]=UNSIGNED_MODULE
Workqueue: writeback wb_workfn (flush-254:49)
Call trace:
f2fs_is_cp_guaranteed+0x70/0x98
f2fs_inplace_write_data+0x174/0x2f4
f2fs_do_write_data_page+0x214/0x81c
f2fs_write_single_data_page+0x28c/0x764
f2fs_write_data_pages+0x78c/0xce4
do_writepages+0xe8/0x2fc
__writeback_single_inode+0x4c/0x4b4
writeback_sb_inodes+0x314/0x540
__writeback_inodes_wb+0xa4/0xf4
wb_writeback+0x160/0x448
wb_workfn+0x2f0/0x5dc
process_scheduled_works+0x1c8/0x458
worker_thread+0x334/0x3f0
kthread+0x118/0x1ac
ret_from_fork+0x10/0x20
[1] https://bugzilla.kernel.org/show_bug.cgi?id=220575
The panic was caused by UAF issue w/ below race condition:
kworker
- writepages
- f2fs_write_cache_pages
- f2fs_write_single_data_page
- f2fs_do_write_data_page
- f2fs_inplace_write_data
- f2fs_merge_page_bio
- add_inu_page
: cache page #1 into bio & cache bio in
io->bio_list
- f2fs_write_single_data_page
- f2fs_do_write_data_page
- f2fs_inplace_write_data
- f2fs_merge_page_bio
- add_inu_page
: cache page #2 into bio which is linked
in io->bio_list
write
- f2fs_write_begin
: write page #1
- f2fs_folio_wait_writeback
- f2fs_submit_merged_ipu_write
- f2fs_submit_write_bio
: submit bio which inclues page #1 and #2
software IRQ
- f2fs_write_end_io
- fscrypt_free_bounce_page
: freed bounced page which belongs to page #2
- inc_page_count( , WB_DATA_TYPE(data_folio), false)
: data_folio points to fio->encrypted_page
the bounced page can be freed before
accessing it in f2fs_is_cp_guarantee()
It can reproduce w/ below testcase:
Run below script in shell #1:
for ((i=1;i>0;i++)) do xfs_io -f /mnt/f2fs/enc/file \
-c "pwrite 0 32k" -c "fdatasync"
Run below script in shell #2:
for ((i=1;i>0;i++)) do xfs_io -f /mnt/f2fs/enc/file \
-c "pwrite 0 32k" -c "fdatasync"
So, in f2fs_merge_page_bio(), let's avoid using fio->encrypted_page after
commit page into internal ipu cache.
Security readout for executives and security teams
Plain-English summary
A race in Linux F2FS filesystem write processing can access an already-freed encrypted page, causing a kernel crash and potentially broader memory-safety impact. Exploitation requires local, low-privileged access and an affected system using the relevant F2FS path. Availability is the clearest demonstrated business risk.
Executive priority
Treat as a high-priority stability and isolation issue where affected F2FS systems permit untrusted local activity. Patch exposed multi-user, mobile, appliance, or container-hosting systems first. Systems without F2FS are unlikely to reach this flaw. Current sources do not justify an emergency response based on active exploitation.
Technical view
CVE-2025-40054 is a use-after-free in f2fs_merge_page_bio(). Concurrent write and writeback activity can submit a cached bio and free an encryption bounce page before later code accesses fio->encrypted_page. The reported failure was a kernel NULL-pointer dereference during F2FS writeback. Linux stable commits change the code to avoid using that page after caching.
Likely exposure
Exposure is concentrated in systems running affected Linux kernel builds with F2FS, particularly encrypted F2FS files undergoing concurrent writes and writeback. The supplied affected-version data spans several kernel series but is insufficiently structured to identify every vulnerable or fixed package build. Distribution and device-vendor backports must be checked individually.
Exploitation context
The CVSS 3.1 score is 7.8 with local access, low privileges, low complexity, and no user interaction. A concurrent-write testcase reproduced a kernel panic. The bundle reports no CISA KEV listing and provides no evidence of active exploitation, public weaponization, or reliable confidentiality and integrity impact in practice.
Researcher notes
The reported crash occurred on a tainted Android-derived 6.12.30 kernel, but Linux stable fixes cover multiple branches. The demonstrated outcome is a panic during concurrent encrypted F2FS writes. Although the CVSS vector assigns high confidentiality, integrity, and availability impacts, the supplied evidence does not establish dependable privilege escalation, information disclosure, or arbitrary code execution.
Mitigation direction
Upgrade to a vendor-supported kernel containing the applicable Linux stable fix or vendor backport.
Prioritize encrypted F2FS systems that run untrusted or low-privileged local workloads.
Restrict unnecessary local access until affected systems can be updated.
Consult distribution or device-vendor guidance for exact fixed package and firmware versions.
Validation and detection
Inventory running kernel builds and systems with active F2FS mounts.
Determine whether F2FS encryption is used on affected systems.
Verify the installed kernel contains the applicable listed stable commit or vendor backport.
Review kernel logs for F2FS writeback crashes, NULL-pointer dereferences, or related panic traces.
After upgrading and rebooting, confirm the running kernel matches the remediated build.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cve · low confidence lookup
CVE-2025-40054 mapping review
Open the CVE-to-ATT&CK bridge for reviewed, inferred, or future official mappings tied to this CVE.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
1CVSS vectors
3Timeline events
0ADP providers
8Source links
CVSS vector scores
1 official score
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.