{"id":"CVE-2026-139012","aliases":["CVE-2026-139012"],"related":[],"kind":"vulnerability","state":"published","title":"f2fs: compress: fix to handle race between truncate and writeback","summary":"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 <TASK>\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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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 <TASK>\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.","source":"cvelist"}],"published":"2026-11-30T13:27:03.397Z","modified":"2026-11-30T14:18:04.510Z","severities":[],"cwes":[],"affected":[{"ranges":[{"type":"git","introduced":"3265d3db1f16395cfc6b8ea9b31b4001d98d05ef","fixed":"3eae9d491339330d15c5a99e701d09646fb6e85c","status":"affected"},{"type":"git","introduced":"3265d3db1f16395cfc6b8ea9b31b4001d98d05ef","fixed":"c25c023fb531baf5e8ca57f2211aff6292506210","status":"affected"},{"type":"git","introduced":"3265d3db1f16395cfc6b8ea9b31b4001d98d05ef","fixed":"9c7b917ffdf4be38d7074ddc23a39b4fe23dc1f7","status":"affected"},{"type":"git","introduced":"3265d3db1f16395cfc6b8ea9b31b4001d98d05ef","fixed":"06e413468900775563b4c87169e28912c1855d30","status":"affected"},{"type":"git","introduced":"3265d3db1f16395cfc6b8ea9b31b4001d98d05ef","fixed":"305021c93f4457c56d899e858742860df7bf0b8b","status":"affected"},{"type":"git","introduced":"3265d3db1f16395cfc6b8ea9b31b4001d98d05ef","fixed":"c0d77acef537dd3f0b1dcf94c9d0a265936d4ba6","status":"affected"},{"type":"git","introduced":"3265d3db1f16395cfc6b8ea9b31b4001d98d05ef","fixed":"3e82f85a40e71c0023408994f600fe862b83688d","status":"affected"},{"type":"git","introduced":"3265d3db1f16395cfc6b8ea9b31b4001d98d05ef","fixed":"c0337e331b065074ce20e4258a578e07dd7e4083","status":"affected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"version":"5.8","status":"affected"},{"type":"semver","introduced":"0","fixed":"5.8","status":"unaffected"},{"type":"semver","introduced":"5.10.275","lastAffected":"5.10.*","status":"unaffected"},{"type":"semver","introduced":"5.15.226","lastAffected":"5.15.*","status":"unaffected"},{"type":"semver","introduced":"6.1.193","lastAffected":"6.1.*","status":"unaffected"},{"type":"semver","introduced":"6.6.163","lastAffected":"6.6.*","status":"unaffected"},{"type":"semver","introduced":"6.12.117","lastAffected":"6.12.*","status":"unaffected"},{"type":"semver","introduced":"6.18.63","lastAffected":"6.18.*","status":"unaffected"},{"type":"semver","introduced":"7.3.4","lastAffected":"7.3.*","status":"unaffected"},{"type":"original_commit_for_fix","introduced":"7.4-rc1","lastAffected":"*","status":"unaffected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"}],"references":[{"url":"https://git.kernel.org/stable/c/3eae9d491339330d15c5a99e701d09646fb6e85c","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/c25c023fb531baf5e8ca57f2211aff6292506210","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/9c7b917ffdf4be38d7074ddc23a39b4fe23dc1f7","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/06e413468900775563b4c87169e28912c1855d30","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/305021c93f4457c56d899e858742860df7bf0b8b","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/c0d77acef537dd3f0b1dcf94c9d0a265936d4ba6","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/3e82f85a40e71c0023408994f600fe862b83688d","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/c0337e331b065074ce20e4258a578e07dd7e4083","tags":[],"sources":["cvelist","nvd"]}],"credits":[],"assigner":"Linux","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-139012","url":"https://www.cve.org/CVERecord?id=CVE-2026-139012","licence":"CVE Terms of Use","modified":"2026-11-30T13:27:03.397Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-139012","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-139012","licence":"Public domain","modified":"2026-11-30T14:18:04.510Z"}],"updatedAt":"2026-11-30T14:32:28.499Z","epss":{"score":0.00211,"percentile":0.12001,"date":"2026-12-01T12:00:22.000Z"}}