CVE-2025-40054: f2fs: fix UAF issue in f2fs_merge_page_bio()

Published Oct 28, 2025
·
Updated

In the Linux kernel, the following vulnerability has been resolved:

f2fs: fix UAF issue in f2fsmergepagebio()

As JY reported in bugzilla [1],

Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 pc : [0xffffffe51d249484] f2fsiscpguaranteed+0x70/0x98 lr : [0xffffffe51d24adbc] f2fsmergepagebio+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]=PROPRIETARYMODULE, [B]=BADPAGE, [W]=WARN, [O]=OOTMODULE, [E]=UNSIGNEDMODULE Workqueue: writeback wbworkfn (flush-254:49) Call trace: f2fsiscpguaranteed+0x70/0x98 f2fsinplacewritedata+0x174/0x2f4 f2fsdowritedatapage+0x214/0x81c f2fswritesingledatapage+0x28c/0x764 f2fswritedatapages+0x78c/0xce4 dowritepages+0xe8/0x2fc writebacksingleinode+0x4c/0x4b4 writebacksbinodes+0x314/0x540 writebackinodeswb+0xa4/0xf4 wbwriteback+0x160/0x448 wbworkfn+0x2f0/0x5dc processscheduledworks+0x1c8/0x458 workerthread+0x334/0x3f0 kthread+0x118/0x1ac retfromfork+0x10/0x20

[1] https://bugzilla.kernel.org/showbug.cgi?id=220575

The panic was caused by UAF issue w/ below race condition:

kworker - writepages - f2fswritecachepages - f2fswritesingledatapage - f2fsdowritedatapage - f2fsinplacewritedata - f2fsmergepagebio - addinupage : cache page #1 into bio & cache bio in io->biolist - f2fswritesingledatapage - f2fsdowritedatapage - f2fsinplacewritedata - f2fsmergepagebio - addinupage : cache page #2 into bio which is linked in io->biolist write - f2fswritebegin : write page #1 - f2fsfoliowaitwriteback - f2fssubmitmergedipuwrite - f2fssubmitwritebio : submit bio which inclues page #1 and #2

software IRQ - f2fswriteendio - fscryptfreebouncepage : freed bounced page which belongs to page #2 - incpagecount( , WBDATATYPE(datafolio), false) : datafolio points to fio->encryptedpage the bounced page can be freed before accessing it in f2fsiscpguarantee()

It can reproduce w/ below testcase: Run below script in shell #1: for ((i=1;i>0;i++)) do xfsio -f /mnt/f2fs/enc/file \ -c "pwrite 0 32k" -c "fdatasync"

Run below script in shell #2: for ((i=1;i>0;i++)) do xfsio -f /mnt/f2fs/enc/file \ -c "pwrite 0 32k" -c "fdatasync"

So, in f2fsmergepagebio(), let's avoid using fio->encryptedpage after commit page into internal ipu cache.

Affected Software

3 affected componentsFixes available
Linux Linux kernel
debian/linux<=6.1.176-1
6.1.190-16.12.107-16.12.113-17.2.12-17.2.13-1
debian/linux-6.12
6.12.113-1~deb12u1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade debian/linux to a version that resolves this vulnerability.

    Fixed in 6.1.190-1Fixed in 6.12.107-1Fixed in 6.12.113-1Fixed in 7.2.12-1Fixed in 7.2.13-1
  2. Upgrade

    Upgrade debian/linux-6.12 to a version that resolves this vulnerability.

    Fixed in 6.12.113-1~deb12u1
  3. Compensating control

    In f2fs_merge_page_bio(), avoid using fio->encrypted_page after committing the page into the internal IPU cache, preventing access to a freed bounced page.

Event History

Oct 28, 2025
CVE Published
via MITRE·11:48 AM
Data Sourced
via MITRE·11:48 AM
DescriptionSeverity
Data Sourced
via NVD·12:15 PM
DescriptionSeverity

Parent advisories

This vulnerability appears in the following advisories.

Peer vulnerabilities

Found alongside the following vulnerabilities.

Frequently Asked Questions

1

What is the severity of CVE-2025-40054?

CVE-2025-40054 has a medium severity rating due to the potential for a use-after-free vulnerability in the Linux kernel.

2

How do I fix CVE-2025-40054?

To resolve CVE-2025-40054, you should update the Linux kernel to the latest patched version that addresses this vulnerability.

3

What impact does CVE-2025-40054 have on my system?

CVE-2025-40054 can lead to a kernel panic or system crash, impacting system stability and security.

4

Which versions of the Linux kernel are affected by CVE-2025-40054?

CVE-2025-40054 affects specific versions of the Linux kernel prior to the released fixes.

5

Is CVE-2025-40054 being actively exploited?

As of now, there is no public information indicating that CVE-2025-40054 is actively being exploited in the wild.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203