CVE-2025-22123 Information
Description
In the Linux kernel the following vulnerability has been resolved:
f2fs: fix to avoid accessing uninitialized curseg
syzbot reports a f2fs bug as below:
F2FS-fs (loop3): Stopped filesystem due to reason: 7
kworker/u8:7: attempt to access beyond end of device
BUG: unable to handle page fault for address: ffffed1604ea3dfa
RIP: 0010:get_ckpt_valid_blocks fs/f2fs/segment.h:361 [inline]
RIP: 0010:has_curseg_enough_space fs/f2fs/segment.h:570 [inline]
RIP: 0010:__get_secs_required fs/f2fs/segment.h:620 [inline]
RIP: 0010:has_not_enough_free_secs fs/f2fs/segment.h:633 [inline]
RIP: 0010:has_enough_free_secs+0x575/0x1660 fs/f2fs/segment.h:649
Commit 8b10d3653735 (2fs: introduce FAULT_NO_SEGMENT) allows to trigger no free segment fault in allocator then it will update curseg->segno to NULL_SEGNO though CP_ERROR_FLAG has been set f2fs_write_inode() missed to check the flag and access invalid curseg->segno directly in below call path then resulting in panic:
- f2fs_write_inode
- f2fs_is_checkpoint_ready
- has_enough_free_secs
- has_not_enough_free_secs
- __get_secs_required
- has_curseg_enough_space
- get_ckpt_valid_blocks : access invalid curseg->segno
To avoid this issue let’s:
- check CP_ERROR_FLAG flag in prior to f2fs_is_checkpoint_ready() in f2fs_write_inode().
- in has_curseg_enough_space() save curseg->segno into a temp variable and verify its validation before use.
Reference
https://git.kernel.org/stable/c/7f90e5d423cd2d4c74b2abb527872f335108637f https://git.kernel.org/stable/c/986c50f6bca109c6cf362b4e2babcb85aba958f6
Share on: