🇰🇷 한글 설명
Linux 커널의 F2FS 파일 시스템에서 원자적 쓰기(atomic write) 기능을 사용할 때 발생하는 Null 포인터 역참조 취약점입니다. 새로운 COW(Copy-on-Write) inode를 생성하는 과정에서 특정 플래그가 누락되어 데이터 쓰기 작업 중 시스템 충돌이 발생할 수 있습니다.
💡 쉬운 설명
파일을 안전하게 저장하는 기능이 작동할 때, 컴퓨터가 잘못된 메모리 주소를 참조하여 시스템이 멈추거나 오류가 발생하는 문제입니다. 이는 파일 시스템의 데이터 처리 방식에서 발생하는 논리적 오류입니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
f2fs: fix null-ptr-deref in f2fs_get_dnode_of_data
There is issue as follows when test f2fs atomic write:
F2FS-fs (loop0): Can't find valid F2FS filesystem in 2th superblock
F2FS-fs (loop0): invalid crc_offset: 0
F2FS-fs (loop0): f2fs_check_nid_range: out-of-range nid=1, run fsck to fix.
F2FS-fs (loop0): f2fs_check_nid_range: out-of-range nid=2, run fsck to fix.
==================================================================
BUG: KASAN: null-ptr-deref in f2fs_get_dnode_of_data+0xac/0x16d0
Read of size 8 at addr 0000000000000028 by task rep/1990
CPU: 4 PID: 1990 Comm: rep Not tainted 5.19.0-rc6-next-20220715 #266
Call Trace:
<TASK>
dump_stack_lvl+0x6e/0x91
print_report.cold+0x49a/0x6bb
kasan_report+0xa8/0x130
f2fs_get_dnode_of_data+0xac/0x16d0
f2fs_do_write_data_page+0x2a5/0x1030
move_data_page+0x3c5/0xdf0
do_garbage_collect+0x2015/0x36c0
f2fs_gc+0x554/0x1d30
f2fs_balance_fs+0x7f5/0xda0
f2fs_write_single_data_page+0xb66/0xdc0
f2fs_write_cache_pages+0x716/0x1420
f2fs_write_data_pages+0x84f/0x9a0
do_writepages+0x130/0x3a0
filemap_fdatawrite_wbc+0x87/0xa0
file_write_and_wait_range+0x157/0x1c0
f2fs_do_sync_file+0x206/0x12d0
f2fs_sync_file+0x99/0xc0
vfs_fsync_range+0x75/0x140
f2fs_file_write_iter+0xd7b/0x1850
vfs_write+0x645/0x780
ksys_write+0xf1/0x1e0
do_syscall_64+0x3b/0x90
entry_SYSCALL_64_after_hwframe+0x63/0xcd
As 3db1de0e582c commit changed atomic write way which new a cow_inode for
atomic write file, and also mark cow_inode as FI_ATOMIC_FILE.
When f2fs_do_write_data_page write cow_inode will use cow_inode's cow_inode
which is NULL. Then will trigger null-ptr-deref.
To solve above issue, introduce FI_COW_FILE flag for COW inode.
Fiexes: 3db1de0e582c("f2fs: change the current atomic write way")
📍 영향받는 시스템
Linux kernel (F2FS 파일 시스템을 사용하는 버전, 특히 5.19.0-rc6 이전 버전)
⚔️ 공격 벡터
로컬 사용자가 F2FS 파일 시스템 상에서 원자적 쓰기 기능을 유도하는 특정 파일 작업을 수행하여 발생
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트하거나, 해당 커밋(3db1de0e582c)이 포함된 버전으로 업그레이드
🔧 검증 코드
출력된 커널 버전을 확인하여 취약점이 해결된 패치 버전인지 확인