CVE-2025-22127: f2fs: fix potential deadloop in prepare_compress_overwrite()
In the Linux kernel, the following vulnerability has been resolved:
f2fs: fix potential deadloop in preparecompressoverwrite()
Jan Prusakowski reported a kernel hang issue as below:
When running xfstests on linux-next kernel (6.14.0-rc3, 6.12) I encountered a problem in generic/475 test where fsstress process gets blocked in f2fswritedatapages() and the test hangs. The options I used are:
MKFSOPTIONS -- -O compression -O extraattr -O projectquota -O quota /dev/vdc MOUNTOPTIONS -- -o acl,userxattr -o discard,compressextension= /dev/vdc /vdc
INFO: task kworker/u8:0:11 blocked for more than 122 seconds. Not tainted 6.14.0-rc3-xfstests-lockdep #1 "echo 0 > /proc/sys/kernel/hungtasktimeoutsecs" disables this message. task:kworker/u8:0 state:D stack:0 pid:11 tgid:11 ppid:2 taskflags:0x4208160 flags:0x00004000 Workqueue: writeback wbworkfn (flush-253:0) Call Trace: <TASK> schedule+0x309/0x8e0 schedule+0x3a/0x100 schedulepreemptdisabled+0x15/0x30 mutexlock+0x59a/0xdb0 f2fswritedatapages+0x3ac/0x400 dowritepages+0xe8/0x290 writebacksingleinode+0x5c/0x360 writebacksbinodes+0x22f/0x570 wbwriteback+0xb0/0x410 wbdowriteback+0x47/0x2f0 wbworkfn+0x5a/0x1c0 processonework+0x223/0x5b0 workerthread+0x1d5/0x3c0 kthread+0xfd/0x230 retfromfork+0x31/0x50 retfromforkasm+0x1a/0x30 </TASK>
The root cause is: once generic/475 starts toload error table to dm device, f2fspreparecompressoverwrite() will loop reading compressed cluster pages due to IO error, meanwhile it has held .writepages lock, it can block all other writeback tasks.
Let's fix this issue w/ below changes: - add f2fshandlepageeio() in preparecompressoverwrite() to detect IO error. - detect cperror earler in f2fsreadmultipages().
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 6.12.111-1 - Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 6.16.3-1 - Upgrade
Upgrade
debian/linux-6.12to a version that resolves this vulnerability.Fixed in 6.12.111-1~deb12u1 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.1.191 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.6.160 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.12.109 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.14.2 - Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 6.12.116-1Fixed in 7.2.15-1Fixed in 7.3.3-1 - Upgrade
Upgrade
debian/linux-6.12to a version that resolves this vulnerability.Fixed in 6.12.115-2~deb12u1 - Compensating control
Update f2fs compression overwrite error handling to call f2fs_handle_page_eio() in prepare_compress_overwrite() to detect I/O errors, and detect cp_error earlier in f2fs_read_multi_pages() to prevent looping on compressed cluster pages after an I/O error.
Event History
Frequently Asked Questions
What is the severity of CVE-2025-22127?
CVE-2025-22127 is considered a moderate severity vulnerability due to its potential to cause kernel hangs.
How do I fix CVE-2025-22127?
To fix CVE-2025-22127, update your Linux kernel to a version higher than 6.14.0-rc3.
What systems are affected by CVE-2025-22127?
CVE-2025-22127 affects Linux kernel versions from 6.12 up to 6.14.0-rc3.
What type of vulnerability is CVE-2025-22127?
CVE-2025-22127 is a kernel-level vulnerability that could lead to a deadlock in the f2fs filesystem implementation.
Who reported CVE-2025-22127?
CVE-2025-22127 was reported by Jan Prusakowski.