{"id":"CVE-2026-139508","state":"PUBLISHED","title":"ocfs2: defer suballocator block group reclaim to workqueue","description":"In the Linux kernel, the following vulnerability has been resolved:\n\nocfs2: defer suballocator block group reclaim to workqueue\n\nWhen the last bit in a suballocator block group is freed,\n_ocfs2_free_suballoc_bits() reclaims the group back to the global bitmap. \nThe reclaim takes inode_lock() on the global bitmap inode while running\ninside the freeing transaction, adding a lock dependency of\n\n  j_trans_barrier -> global bitmap inode i_rwsem\n\nThis forms a circular dependency with paths such as\nocfs2_shutdown_local_alloc(), which take the global bitmap inode lock\nbefore starting a transaction:\n\n  Task1 (dealloc):\n    ocfs2_run_deallocs\n      ocfs2_free_cached_blocks\n        ocfs2_start_trans\n          down_read(j_trans_barrier)\n        _ocfs2_free_suballoc_bits\n          _ocfs2_reclaim_suballoc_to_main\n            inode_lock(main_bm_inode)  <- wait on Task2\n\n  Task2 (dismount):\n    ocfs2_shutdown_local_alloc\n      inode_lock(main_bm_inode)\n      ocfs2_start_trans\n        down_read(j_trans_barrier)  <- wait on Task3\n\n  Task3 (ocfs2cmt):\n    ocfs2_commit_cache\n      down_write(j_trans_barrier)  <- wait on Task1's handle\n      jbd2_journal_flush\n\nTask1 waits for Task2's inode_lock(), Task2 waits for the j_trans_barrier\ndown_write() held by ocfs2cmt, and ocfs2cmt waits for Task1's running\ntransaction to commit - a real deadlock, observed with aio-stress direct\nIO writes racing dismount.\n\nFix it by deferring the reclaim to the per-superblock ocfs2_wq workqueue,\nso the freeing transaction no longer takes the global bitmap inode lock. \nThe worker re-checks under the suballocator locks that the block group is\nstill fully freed (it may have been allocated from again in the meantime),\ntakes the global bitmap inode locks before starting its own transaction,\nand performs the same suballocator cleanup and space return.  The inode\nlock order (suballocator inode -> global bitmap inode) is consistent with\nthe existing \"inode lock before transaction\" order, breaking the cycle.\n\nReclaim work can still be queued late in dismount, e.g.  when the truncate\nlog is flushed or orphan dir recovery frees inode bits, so both\nocfs2_dismount_volume() and the mount error path flush ocfs2_wq right\nbefore the system inodes are released, while the journal is still alive,\nto make sure no reclaim work is left running.  The worker also bails out\nif the journal is already gone.\n\nTested with the ocfs2 testsuite (including aio-stress direct IO) and\numount/mount cycles on a CONFIG_PROVE_LOCKING kernel: the circular locking\ndependency is gone and freed block groups are still returned to the global\nbitmap.","publishedAt":"2026-11-30T13:35:24.017Z","updatedAt":"2026-11-30T13:35:24.017Z","severity":null,"assigner":"Linux","products":["Linux Linux"],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"4a54331616b309934d46e255a9f1fdd890e77ebe","status":"affected","lessThan":"18098fed5b27427568087dc17a88d3295492bfb7","versionType":"git"},{"version":"4a54331616b309934d46e255a9f1fdd890e77ebe","status":"affected","lessThan":"b4cc0016f8ead77c823f2d55f4e0a0e61dd924b3","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["fs/ocfs2/ocfs2.h","fs/ocfs2/suballoc.c","fs/ocfs2/suballoc.h","fs/ocfs2/super.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"7.0","status":"affected"},{"version":"0","status":"unaffected","lessThan":"7.0","versionType":"semver"},{"version":"7.3.6","status":"unaffected","lessThanOrEqual":"7.3.*","versionType":"semver"},{"version":"7.4-rc1","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["fs/ocfs2/ocfs2.h","fs/ocfs2/suballoc.c","fs/ocfs2/suballoc.h","fs/ocfs2/super.c"]}],"references":["https://git.kernel.org/stable/c/18098fed5b27427568087dc17a88d3295492bfb7","https://git.kernel.org/stable/c/b4cc0016f8ead77c823f2d55f4e0a0e61dd924b3"],"weaknesses":[],"ingestedAt":"2026-11-30T13:50:04.417Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2026/139xxx/CVE-2026-139508.json","commit":"8c2c22940a0de21d18737df980299c0488d5dc73","baselineCommit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2026-139508","state":"PUBLISHED","datePublished":"2026-11-30T13:35:24.017Z","dateUpdated":"2026-11-30T13:35:24.017Z","assignerShortName":"Linux","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateReserved":"2026-11-30T13:22:15.937Z"},"containers":{"cna":{"title":"ocfs2: defer suballocator block group reclaim to workqueue","descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\nocfs2: defer suballocator block group reclaim to workqueue\n\nWhen the last bit in a suballocator block group is freed,\n_ocfs2_free_suballoc_bits() reclaims the group back to the global bitmap. \nThe reclaim takes inode_lock() on the global bitmap inode while running\ninside the freeing transaction, adding a lock dependency of\n\n  j_trans_barrier -> global bitmap inode i_rwsem\n\nThis forms a circular dependency with paths such as\nocfs2_shutdown_local_alloc(), which take the global bitmap inode lock\nbefore starting a transaction:\n\n  Task1 (dealloc):\n    ocfs2_run_deallocs\n      ocfs2_free_cached_blocks\n        ocfs2_start_trans\n          down_read(j_trans_barrier)\n        _ocfs2_free_suballoc_bits\n          _ocfs2_reclaim_suballoc_to_main\n            inode_lock(main_bm_inode)  <- wait on Task2\n\n  Task2 (dismount):\n    ocfs2_shutdown_local_alloc\n      inode_lock(main_bm_inode)\n      ocfs2_start_trans\n        down_read(j_trans_barrier)  <- wait on Task3\n\n  Task3 (ocfs2cmt):\n    ocfs2_commit_cache\n      down_write(j_trans_barrier)  <- wait on Task1's handle\n      jbd2_journal_flush\n\nTask1 waits for Task2's inode_lock(), Task2 waits for the j_trans_barrier\ndown_write() held by ocfs2cmt, and ocfs2cmt waits for Task1's running\ntransaction to commit - a real deadlock, observed with aio-stress direct\nIO writes racing dismount.\n\nFix it by deferring the reclaim to the per-superblock ocfs2_wq workqueue,\nso the freeing transaction no longer takes the global bitmap inode lock. \nThe worker re-checks under the suballocator locks that the block group is\nstill fully freed (it may have been allocated from again in the meantime),\ntakes the global bitmap inode locks before starting its own transaction,\nand performs the same suballocator cleanup and space return.  The inode\nlock order (suballocator inode -> global bitmap inode) is consistent with\nthe existing \"inode lock before transaction\" order, breaking the cycle.\n\nReclaim work can still be queued late in dismount, e.g.  when the truncate\nlog is flushed or orphan dir recovery frees inode bits, so both\nocfs2_dismount_volume() and the mount error path flush ocfs2_wq right\nbefore the system inodes are released, while the journal is still alive,\nto make sure no reclaim work is left running.  The worker also bails out\nif the journal is already gone.\n\nTested with the ocfs2 testsuite (including aio-stress direct IO) and\numount/mount cycles on a CONFIG_PROVE_LOCKING kernel: the circular locking\ndependency is gone and freed block groups are still returned to the global\nbitmap."}],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"4a54331616b309934d46e255a9f1fdd890e77ebe","status":"affected","lessThan":"18098fed5b27427568087dc17a88d3295492bfb7","versionType":"git"},{"version":"4a54331616b309934d46e255a9f1fdd890e77ebe","status":"affected","lessThan":"b4cc0016f8ead77c823f2d55f4e0a0e61dd924b3","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["fs/ocfs2/ocfs2.h","fs/ocfs2/suballoc.c","fs/ocfs2/suballoc.h","fs/ocfs2/super.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"7.0","status":"affected"},{"version":"0","status":"unaffected","lessThan":"7.0","versionType":"semver"},{"version":"7.3.6","status":"unaffected","lessThanOrEqual":"7.3.*","versionType":"semver"},{"version":"7.4-rc1","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["fs/ocfs2/ocfs2.h","fs/ocfs2/suballoc.c","fs/ocfs2/suballoc.h","fs/ocfs2/super.c"]}],"references":[{"url":"https://git.kernel.org/stable/c/18098fed5b27427568087dc17a88d3295492bfb7"},{"url":"https://git.kernel.org/stable/c/b4cc0016f8ead77c823f2d55f4e0a0e61dd924b3"}],"providerMetadata":{"shortName":"Linux","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateUpdated":"2026-11-30T13:35:24.017Z"},"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"7.0","versionEndExcluding":"7.3.6"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"7.0","versionEndExcluding":"7.4-rc1"}]}]}],"x_generator":{"engine":"bippy-1.2.0"}}}}}