AZL-115294: CVE-2026-99570 affecting package kernel 6.6.161.1-1
In the Linux kernel, the following vulnerability has been resolved:
f2fs: fix to invalidate curseg if changecurseg() fails
Our consistency stress test (fsstress + fio + atomic write workers + "f2fsio shutdown 1") triggers below kernel BUG:
F2FS-fs (vdd): Stopped filesystem due to reason: 0 ------------[ cut here ]------------ kernel BUG at fs/f2fs/segment.c:3989! Oops: invalid opcode: 0000 [#1] SMP KASAN PTI Workqueue: writeback wbworkfn (flush-253:48) RIP: 0010:f2fsallocatedatablock+0x257a/0x38e0 Call Trace: <TASK> dowriteblock+0x155/0xc10 f2fsoutplacewritedata+0x192/0x340 f2fsdowritedatapage+0xc57/0x1880 f2fswritesingledatapage+0xda9/0x15a0 f2fswritecachepages+0x973/0x1f20 f2fswritedatapages+0x6c4/0x1890 dowritepages+0x21e/0x560 writebacksingleinode+0x119/0x11b0 writebacksbinodes+0x67d/0x17a0 wbwriteback+0x207/0x820 wbworkfn+0x128/0xc30 processonework+0x925/0x1600 workerthread+0x60a/0xff0 kthread+0x35f/0x460 retfromfork+0x474/0x7e0 retfromforkasm+0x1a/0x30 </TASK>
The BUG is f2fsbugon(sbi, curseg->nextblkoff >= BLKSPERSEG(sbi)) in f2fsallocatedatablock(), nextblkoff was 512.
The root cause is a race in between atomic write commit and shutdown as below:
Thread A (commit atomic write) Thread B (shutdown) Thread C (writeback) - f2fsioccommitatomicwrite - f2fscommitatomicwrite - f2fscommitatomicwrite - replaceatomicwriteblock - f2fsreplaceblock - f2fsreplaceblock - f2fsiocshutdown - f2fsdoshutdown : F2FSGOINGDOWNMETASYNC - f2fssyncfs - f2fswritesingledatapage : pass f2fscperror() check - f2fsstopcheckpoint : set CPERRORFLAG - changecurseg - resetcurseg : curseg->segno = newsegno : curseg->alloctype = SSR : curseg->nextblkoff = nextfreeblkoff() which is BLKSPERSEG if there is no free slot in newsegno - f2fsgetsumcache : return -EIO due to f2fscperror() : return error w/o restoring curseg : goto outunlock, skip restoring old segno, blkoff and alloctype - f2fsdowritedatapage - f2fsoutplacewritedata - dowriteblock - f2fsallocatedatablock : curseg->segno is valid : f2fsbugon(nextblkoff >= BLKSPERSEG)
Since commit 86f33603f8c5 ("f2fs: handle errors of f2fsgetmetapagenofail"), changecurseg() can fail after the curseg has already been switched to the new segment, then the curseg is left in an inconsistent state: it points to a segment which may have no free slot, its summary block is zeroed, and the caller can not restore it. Subsequent block allocation on the curseg will trigger the BUG. Moreover, the writeback thread dies with curseglock, cursegmutex and sentrylock held, so the commit, shutdown and other I/O threads hang in D state.
Since changecurseg() only fails once CPERRORFLAG is set, no checkpoint will be committed afterward, let's invalidate the curseg via resetcursegfields() on failure, as newcurseg() does for -ENOSPC, then f2fsallocatedatablock() will fail with -ENOSPC on the curseg instead of triggering BUG, and dowriteblock() can handle the error since CPERRORFLA ---truncated---