# CVE-2025-40054: f2fs: fix UAF issue in f2fs\_merge\_page\_bio()

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** HIGH 7.8
- **CVSS:** 7.8 (v3.1, CNA) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: High; Integrity impact: High; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Not remotely exploitable (local or adjacent access needed)
- **EPSS:** 0.24% (percentile 9, 2026-11-28)
- **Published:** 2025-10-28T11:48:29.073Z
- **Modified:** 2026-10-19T21:10:00.160Z

## Who should check

- Anyone running Linux \>= 0b20fcec8651569935a10afe03fedc0b812d044e, \< 1f7b44b4a2b2939f08b279cbb9e6b5dcb8ffea32; \>= 0b20fcec8651569935a10afe03fedc0b812d044e, \< e193d8953647c8b575830852aa5ea0995b98d2b1; \>= 0b20fcec8651569935a10afe03fedc0b812d044e, \< 410337c2301ae78a081e1b5ebbe8ec374fef4cb6; \>= 0b20fcec8651569935a10afe03fedc0b812d044e, \< 68e094232dfe5027c4fd2dcded93d2d6800bae04; \>= 0b20fcec8651569935a10afe03fedc0b812d044e, \< 7dd611131d82d7fc4212b555eb1103160bdad302; \>= 0b20fcec8651569935a10afe03fedc0b812d044e, \< 01118321e0c8a5f3ece57d0d377bfc92d83cd210; \>= 0b20fcec8651569935a10afe03fedc0b812d044e, \< edf7e9040fc52c922db947f9c6c36f07377c52ea
- Anyone running Linux 5.5

## 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.

## Affected and fixed versions

- Linux: \>= 0b20fcec8651569935a10afe03fedc0b812d044e, \< 1f7b44b4a2b2939f08b279cbb9e6b5dcb8ffea32; \>= 0b20fcec8651569935a10afe03fedc0b812d044e, \< e193d8953647c8b575830852aa5ea0995b98d2b1; \>= 0b20fcec8651569935a10afe03fedc0b812d044e, \< 410337c2301ae78a081e1b5ebbe8ec374fef4cb6; \>= 0b20fcec8651569935a10afe03fedc0b812d044e, \< 68e094232dfe5027c4fd2dcded93d2d6800bae04; \>= 0b20fcec8651569935a10afe03fedc0b812d044e, \< 7dd611131d82d7fc4212b555eb1103160bdad302; \>= 0b20fcec8651569935a10afe03fedc0b812d044e, \< 01118321e0c8a5f3ece57d0d377bfc92d83cd210; \>= 0b20fcec8651569935a10afe03fedc0b812d044e, \< edf7e9040fc52c922db947f9c6c36f07377c52ea (cvelist)
- Linux: 5.5 (cvelist)

## Mitigation

- No fix listed yet: follow the vendor advisory.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2025-40054. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2025-40054.md
Affected: Linux >= 0b20fcec8651569935a10afe03fedc0b812d044e, < 1f7b44b4a2b2939f08b279cbb9e6b5dcb8ffea32; >= 0b20fcec8651569935a10afe03fedc0b812d044e, < e193d8953647c8b575830852aa5ea0995b98d2b1; >= 0b20fcec8651569935a10afe03fedc0b812d044e, < 410337c2301ae78a081e1b5ebbe8ec374fef4cb6; >= 0b20fcec8651569935a10af…
Fixed in: Linux 1f7b44b4a2b2939f08b279cbb9e6b5dcb8ffea32, Linux 410337c2301ae78a081e1b5ebbe8ec374fef4cb6, Linux 68e094232dfe5027c4fd2dcded93d2d6800bae04, Linux 7dd611131d82d7fc4212b555eb1103160bdad302, Linux 01118321e0c8a5f3ece57d0d377bfc92d83cd210

Steps:
1. Search this machine and project for Linux: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2025-40054 being exploited?

There is no confirmed exploitation: CVE-2025-40054 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.24% chance of exploitation in the next 30 days (as of 2026-11-28).

### How serious is CVE-2025-40054?

High: CVSS 7.8 (v3.1, scored by CNA). Not remotely exploitable (local or adjacent access needed).

### Which versions are affected by CVE-2025-40054?

Linux \>= 0b20fcec8651569935a10afe03fedc0b812d044e, \< 1f7b44b4a2b2939f08b279cbb9e6b5dcb8ffea32; \>= 0b20fcec8651569935a10afe03fedc0b812d044e, \< e193d8953647c8b575830852aa5ea0995b98d2b1; \>= 0b20fcec8651569935a10afe03fedc0b812d044e, \< 410337c2301ae78a081e1b5ebbe8ec374fef4cb6; \>= 0b20fcec8651569935a10afe03fedc0b812d044e, \< 68e094232dfe5027c4fd2dcded93d2d6800bae04; \>= 0b20fcec8651569935a10afe03fedc0b812d044e, \< 7dd611131d82d7fc4212b555eb1103160bdad302; \>= 0b20fcec8651569935a10afe03fedc0b812d044e, \< 01118321e0c8a5f3ece57d0d377bfc92d83cd210; \>= 0b20fcec8651569935a10afe03fedc0b812d044e, \< edf7e9040fc52c922db947f9c6c36f07377c52ea; Linux 5.5.

### Is there a fix for CVE-2025-40054?

Yes. Fixed in Linux 1f7b44b4a2b2939f08b279cbb9e6b5dcb8ffea32, Linux 410337c2301ae78a081e1b5ebbe8ec374fef4cb6, Linux 68e094232dfe5027c4fd2dcded93d2d6800bae04, Linux 7dd611131d82d7fc4212b555eb1103160bdad302, Linux 01118321e0c8a5f3ece57d0d377bfc92d83cd210. No fix listed yet: follow the vendor advisory.

### How do I check if I'm affected by CVE-2025-40054?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- other: <https://git.kernel.org/stable/c/1f7b44b4a2b2939f08b279cbb9e6b5dcb8ffea32>
- other: <https://git.kernel.org/stable/c/e193d8953647c8b575830852aa5ea0995b98d2b1>
- other: <https://git.kernel.org/stable/c/410337c2301ae78a081e1b5ebbe8ec374fef4cb6>
- other: <https://git.kernel.org/stable/c/68e094232dfe5027c4fd2dcded93d2d6800bae04>
- other: <https://git.kernel.org/stable/c/7dd611131d82d7fc4212b555eb1103160bdad302>
- other: <https://git.kernel.org/stable/c/01118321e0c8a5f3ece57d0d377bfc92d83cd210>
- other: <https://git.kernel.org/stable/c/edf7e9040fc52c922db947f9c6c36f07377c52ea>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2025-40054>

HTML: <https://flawdb.com/CVE-2025-40054> · JSON: <https://flawdb.com/api/v1/entries/CVE-2025-40054>
