{"id":"CVE-2026-139012","summary":"f2fs: compress: fix to handle race between truncate and writeback","details":"In the Linux kernel, the following vulnerability has been resolved:\n\nf2fs: compress: fix to handle race between truncate and writeback\n\nfsstress reports a kernel BUG in f2fs_truncate_partial_cluster():\n\nkernel BUG at fs/f2fs/compress.c:1238!\nRIP: 0010:f2fs_truncate_partial_cluster+0x292/0x2a0\nCall Trace:\n \u003cTASK\u003e\n f2fs_truncate+0xf6/0x210\n f2fs_setattr+0x6b7/0x770\n notify_change+0x33b/0x520\n do_truncate+0xc2/0xf0\n vfs_truncate+0x153/0x1d0\n ksys_truncate+0x78/0xd0\n __x64_sys_truncate+0x16/0x20\n do_syscall_64+0xbe/0x540\n\nThe root cause is that Thread A (truncate) and Thread B (background\nwriteback or fsync) can race as follows:\n\nThread A                             Thread B\n- f2fs_setattr\n - f2fs_truncate\n  - f2fs_truncate_blocks\n   - f2fs_truncate_partial_cluster\n    - f2fs_is_compressed_cluster\n      return 1\n                                     - f2fs_write_cache_pages\n                                      - f2fs_write_multi_pages\n                                       - f2fs_write_raw_pages\n                                        - f2fs_write_single_data_page\n                                          dn.data_blkaddr != COMPRESS_ADDR\n                                          (cluster converted to normal)\n    - f2fs_prepare_compress_overwrite\n     - f2fs_is_compressed_cluster\n       return 0\n     - return 0\n    - f2fs_bug_on(sbi, err == 0): BUG!\n\nWriteback path does not acquire i_gc_rwsem or filemap_invalidate_lock.\nWhen a compressed cluster fails compression during writeback, it is\noverwritten with raw data blocks. If Thread A checked\nf2fs_is_compressed_cluster() before the conversion, but calls\nf2fs_prepare_compress_overwrite() after the conversion,\nf2fs_prepare_compress_overwrite() returns 0 because the cluster is no\nlonger a compressed cluster.\n\nTo fix this, remove the f2fs_bug_on() and retry checking the cluster status\nwhen f2fs_prepare_compress_overwrite() returns 0, so that it can fall back\nto f2fs_do_truncate_blocks() to handle it as a normal cluster.","modified":"2026-11-30T15:01:58.577816607Z","published":"2026-11-30T13:27:03.397Z","database_specific":{"osv_generated_from":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/139xxx/CVE-2026-139012.json","cna_assigner":"Linux"},"references":[{"type":"PACKAGE","url":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git"},{"type":"WEB","url":"https://git.kernel.org/stable/c/06e413468900775563b4c87169e28912c1855d30"},{"type":"WEB","url":"https://git.kernel.org/stable/c/305021c93f4457c56d899e858742860df7bf0b8b"},{"type":"WEB","url":"https://git.kernel.org/stable/c/3e82f85a40e71c0023408994f600fe862b83688d"},{"type":"WEB","url":"https://git.kernel.org/stable/c/3eae9d491339330d15c5a99e701d09646fb6e85c"},{"type":"WEB","url":"https://git.kernel.org/stable/c/9c7b917ffdf4be38d7074ddc23a39b4fe23dc1f7"},{"type":"WEB","url":"https://git.kernel.org/stable/c/c0337e331b065074ce20e4258a578e07dd7e4083"},{"type":"WEB","url":"https://git.kernel.org/stable/c/c0d77acef537dd3f0b1dcf94c9d0a265936d4ba6"},{"type":"WEB","url":"https://git.kernel.org/stable/c/c25c023fb531baf5e8ca57f2211aff6292506210"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/139xxx/CVE-2026-139012.json"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-139012"}],"affected":[{"ranges":[{"type":"GIT","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","events":[{"introduced":"3265d3db1f16395cfc6b8ea9b31b4001d98d05ef"},{"fixed":"3eae9d491339330d15c5a99e701d09646fb6e85c"},{"fixed":"c25c023fb531baf5e8ca57f2211aff6292506210"},{"fixed":"9c7b917ffdf4be38d7074ddc23a39b4fe23dc1f7"},{"fixed":"06e413468900775563b4c87169e28912c1855d30"},{"fixed":"305021c93f4457c56d899e858742860df7bf0b8b"},{"fixed":"c0d77acef537dd3f0b1dcf94c9d0a265936d4ba6"},{"fixed":"3e82f85a40e71c0023408994f600fe862b83688d"},{"fixed":"c0337e331b065074ce20e4258a578e07dd7e4083"}]}],"database_specific":{"source":"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-139012.json"}},{"package":{"name":"Kernel","ecosystem":"Linux"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"5.8.0"},{"fixed":"5.10.275"}]},{"type":"ECOSYSTEM","events":[{"introduced":"5.11.0"},{"fixed":"5.15.226"}]},{"type":"ECOSYSTEM","events":[{"introduced":"5.16.0"},{"fixed":"6.1.193"}]},{"type":"ECOSYSTEM","events":[{"introduced":"6.2.0"},{"fixed":"6.6.163"}]},{"type":"ECOSYSTEM","events":[{"introduced":"6.7.0"},{"fixed":"6.12.117"}]},{"type":"ECOSYSTEM","events":[{"introduced":"6.13.0"},{"fixed":"6.18.63"}]},{"type":"ECOSYSTEM","events":[{"introduced":"6.19.0"},{"fixed":"7.3.4"}]}],"database_specific":{"source":"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-139012.json"}}],"schema_version":"1.9.2"}