CVE-2026-99570: f2fs: fix to invalidate curseg if change_curseg() fails

Published Nov 20, 2026
·
Updated

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---

Affected Software

5 affected componentsFixes available
linux/kernel>=5.4.75<5.5
5.5
linux/kernel>=5.9.5<5.10
5.10
linux/kernel>=5.10.0<6.12.118
6.12.118
linux/kernel>=6.13.0<6.18.64
6.18.64
linux/kernel>=6.19.0<7.3.5
7.3.5

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade linux/Kernel to a version that resolves this vulnerability.

    Fixed in 5.5
  2. Upgrade

    Upgrade linux/Kernel to a version that resolves this vulnerability.

    Fixed in 5.10
  3. Upgrade

    Upgrade linux/Kernel to a version that resolves this vulnerability.

    Fixed in 6.12.118
  4. Upgrade

    Upgrade linux/Kernel to a version that resolves this vulnerability.

    Fixed in 6.18.64
  5. Upgrade

    Upgrade linux/Kernel to a version that resolves this vulnerability.

    Fixed in 7.3.5

Frequently Asked Questions

1

What conditions are needed to trigger this issue?

The reported trigger is a race between atomic-write activity and an F2FS shutdown operation. The consistency stress test combined fsstress, fio, atomic write workers, and "f2fs_io shutdown 1".

2

What is the observed impact when the race occurs?

The filesystem is stopped and the kernel hits a BUG in f2fs_allocate_data_block() after curseg->next_blkoff reaches 512. The failure was observed in the writeback worker path during data-page writes.

3

Are systems using F2FS but not atomic writes or shutdown operations implicated by the reported trigger?

The provided report specifically attributes the issue to a race involving atomic writes and shutdown. It does not establish that ordinary F2FS use without those conditions triggers the BUG.

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