CVE-2025-40054
f2fs: fix UAF issue in f2fs_merge_page_bio()
Check your servers for CVE-2025-40054
The Vulnpocalypse collector sends the package list of each Linux server and of its container images once a day. Vulnpocalypse shows every server where CVE-2025-40054 affects the running kernel, with the command that installs the fix. The free plan covers one server and one domain and does not need a credit card.
Description
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.
Severity (CVSS)
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
- Attack vector
- local: the attacker needs local access, or a user has to open a prepared file
- Attack complexity
- low: an attack works without special conditions
- Privileges required
- low: the attacker needs an ordinary user account
- User interaction
- none: nobody has to click or open anything
- Scope
- unchanged: the damage stays inside the vulnerable component
- Impact
- confidentiality high, integrity high, availability high: what an attacker can read (confidentiality), change (integrity) or stop (availability)
Exploitation
EPSS 0.17%: the probability of exploitation activity in the next 30 days, from the EPSS model of FIRST. The score is higher than 6.64% of all scored CVEs. Scores of 1 Dec 2026.
Affected products
As the CNA lists them.
| Product | Versions |
|---|---|
| Linux |
affected from 0b20fcec8651569935a10afe03fedc0b812d044e, before 1f7b44b4a2b2939f08b279cbb9e6b5dcb8ffea32 affected from 0b20fcec8651569935a10afe03fedc0b812d044e, before e193d8953647c8b575830852aa5ea0995b98d2b1 affected from 0b20fcec8651569935a10afe03fedc0b812d044e, before 410337c2301ae78a081e1b5ebbe8ec374fef4cb6 affected from 0b20fcec8651569935a10afe03fedc0b812d044e, before 68e094232dfe5027c4fd2dcded93d2d6800bae04 affected from 0b20fcec8651569935a10afe03fedc0b812d044e, before 7dd611131d82d7fc4212b555eb1103160bdad302 affected from 0b20fcec8651569935a10afe03fedc0b812d044e, before 01118321e0c8a5f3ece57d0d377bfc92d83cd210 affected from 0b20fcec8651569935a10afe03fedc0b812d044e, before edf7e9040fc52c922db947f9c6c36f07377c52ea
Other versions: unaffected
|
| Linux |
affected 5.5 unaffected before 5.5 unaffected from 5.10.266 up to and including 5.10.* unaffected from 5.15.217 up to and including 5.15.* unaffected from 6.1.184 up to and including 6.1.* unaffected from 6.6.153 up to and including 6.6.* unaffected from 6.12.105 up to and including 6.12.* unaffected from 6.17.3 up to and including 6.17.* unaffected 6.18 and later
Other versions: affected
|
Is my server affected?
This CVE is in the Linux kernel. Compare the running kernel with the fixed kernel version of your distribution, and reboot after a kernel update:
uname -r
# Debian, Ubuntu: does the changelog of the running kernel name the CVE?
zgrep -l CVE-2025-40054 /usr/share/doc/linux-image-$(uname -r)/changelog.Debian.gz
# RHEL, Rocky, Alma
rpm -q --changelog kernel | grep CVE-2025-40054
With Trivy, on the host and for a container image. When a package is affected, it prints the installed and the fixed version:
trivy rootfs --scanners vuln / | grep CVE-2025-40054
trivy image --scanners vuln IMAGE | grep CVE-2025-40054
Vulnpocalypse makes this comparison every day for the package lists of your servers and container images, including language packages (npm, PyPI, Go, Maven and others), and sends the command that installs the fix. Start free with one server and one domain or read how to install the collector.
References
Other references
- https://git.kernel.org/stable/c/1f7b44b4a2b2939f08b279cbb9e6b5dcb8ffea32 git.kernel.org
- https://git.kernel.org/stable/c/e193d8953647c8b575830852aa5ea0995b98d2b1 git.kernel.org
- https://git.kernel.org/stable/c/410337c2301ae78a081e1b5ebbe8ec374fef4cb6 git.kernel.org
- https://git.kernel.org/stable/c/68e094232dfe5027c4fd2dcded93d2d6800bae04 git.kernel.org
- https://git.kernel.org/stable/c/7dd611131d82d7fc4212b555eb1103160bdad302 git.kernel.org
- https://git.kernel.org/stable/c/01118321e0c8a5f3ece57d0d377bfc92d83cd210 git.kernel.org
- https://git.kernel.org/stable/c/edf7e9040fc52c922db947f9c6c36f07377c52ea git.kernel.org
Source: the record CVE-2025-40054 of the CVE List (CVE Program), CVE Terms of Use; EPSS of FIRST. The text of the record is shown as published. Data sources and licences.
Vulnpocalypse