In the Linux kernel, the following vulnerability has been resolved:
f2fs: fix to account dirty data in _getsecs_required()
It will trigger system panic w/ testcase in [1]:
------------[ cut here ]------------ kernel BUG at fs/f2fs/segment.c:2752! RIP: 0010:newcurseg+0xc81/0x2110 Call Trace: f2fsallocatedatablock+0x1c91/0x4540 dowritepage+0x163/0xdf0 f2fsoutplacewritedata+0x1aa/0x340 f2fsdowritedatapage+0x797/0x2280 f2fswritesingledatapage+0x16cd/0x2190 f2fswritecachepages+0x994/0x1c80 f2fswritedatapages+0x9cc/0xea0 dowritepages+0x194/0x7a0 filemapfdatawritewbc+0x12b/0x1a0 _filemapfdatawriterange+0xbb/0xf0 filewriteandwaitrange+0xa1/0x110 f2fsdosyncfile+0x26f/0x1c50 f2fssyncfile+0x12b/0x1d0 vfsfsyncrange+0xfa/0x230 dofsync+0x3d/0x80 _x64sysfsync+0x37/0x50 x64syscall+0x1e88/0x20d0 dosyscall64+0x4b/0x110 entrySYSCALL64afterhwframe+0x76/0x7e
The root cause is if checkpointdisabling and lfsmode are both on, it will trigger OPU for all overwritten data, it may cost more free segment than expected, so f2fs must account those data correctly to calculate cosumed free segments later, and return ENOSPC earlier to avoid run out of free segment during block allocation.
[1] https://lore.kernel.org/fstests/20241015025106.3203676-1-chao@kernel.org/