CVE-2026-139012: f2fs: compress: fix to handle race between truncate and writeback

Published Nov 30, 2026
·
Updated

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

f2fs: compress: fix to handle race between truncate and writeback

fsstress reports a kernel BUG in f2fstruncatepartialcluster():

kernel BUG at fs/f2fs/compress.c:1238! RIP: 0010:f2fstruncatepartialcluster+0x292/0x2a0 Call Trace: <TASK> f2fstruncate+0xf6/0x210 f2fssetattr+0x6b7/0x770 notifychange+0x33b/0x520 dotruncate+0xc2/0xf0 vfstruncate+0x153/0x1d0 ksystruncate+0x78/0xd0 x64systruncate+0x16/0x20 dosyscall64+0xbe/0x540

The root cause is that Thread A (truncate) and Thread B (background writeback or fsync) can race as follows:

Thread A Thread B - f2fssetattr - f2fstruncate - f2fstruncateblocks - f2fstruncatepartialcluster - f2fsiscompressedcluster return 1 - f2fswritecachepages - f2fswritemultipages - f2fswriterawpages - f2fswritesingledatapage dn.datablkaddr != COMPRESSADDR (cluster converted to normal) - f2fspreparecompressoverwrite - f2fsiscompressedcluster return 0 - return 0 - f2fsbugon(sbi, err == 0): BUG!

Writeback path does not acquire igcrwsem or filemapinvalidatelock. When a compressed cluster fails compression during writeback, it is overwritten with raw data blocks. If Thread A checked f2fsiscompressedcluster() before the conversion, but calls f2fspreparecompressoverwrite() after the conversion, f2fspreparecompressoverwrite() returns 0 because the cluster is no longer a compressed cluster.

To fix this, remove the f2fsbugon() and retry checking the cluster status when f2fspreparecompressoverwrite() returns 0, so that it can fall back to f2fsdotruncateblocks() to handle it as a normal cluster.

Affected Software

1 affected component
Linux Linux kernel

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Compensating control

    In F2FS truncate handling, remove f2fs_bug_on() and, when f2fs_prepare_compress_overwrite() returns 0, retry checking the cluster status and fall back to f2fs_do_truncate_blocks() to handle it as a normal cluster.

Event History

Nov 30, 2026
CVE Published
via MITRE·01:27 PM
Data Sourced
via MITRE·01:27 PM
Description

Frequently Asked Questions

1

What conditions are required to trigger this issue?

The race requires a truncate operation to overlap with background writeback or fsync on an F2FS compressed cluster. The failure can occur when compression fails during writeback and the cluster is converted to a normal cluster while truncation still treats it as compressed.

2

How can I tell whether this issue has occurred?

Affected systems may report a kernel BUG in f2fs_truncate_partial_cluster() at fs/f2fs/compress.c:1238. The call trace can include f2fs_truncate, f2fs_setattr, notify_change, do_truncate, and vfs_truncate.

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