🇰🇷 한글 설명
f2fs 파일 시스템에서 f2fs_write_end_io() 콜백과 f2fs_put_super() 함수가 동시에 실행될 때, 이미 NULL로 설정된 sbi->node_inode 포인터를 역참조하여 발생하는 use-after-free 취약점입니다. 체크포인트 쓰기 완료 처리와 언마운트 작업의 경합 조건으로 인해 NULL 포인터 역참조 패닉이 발생합니다. f2fs_in_warm_node_list() 호출을 sbi->nr_pages 감소 전에 수행함으로써 수정되었습니다.
💡 쉬운 설명
리눅스 f2fs 파일 시스템에서 파일 쓰기 완료와 시스템 종료가 동시에 발생할 때 이미 제거된 메모리에 접근하려고 해서 시스템이 충돌합니다. 작업 순서를 조정하여 제거된 메모리 접근을 방지하도록 수정되었습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
f2fs: fix UAF caused by decrementing sbi->nr_pages[] in f2fs_write_end_io()
The xfstests case "generic/107" and syzbot have both reported a NULL
pointer dereference.
The concurrent scenario that triggers the panic is as follows:
F2FS_WB_CP_DATA write callback umount
- f2fs_write_checkpoint
- f2fs_wait_on_all_pages(sbi, F2FS_WB_CP_DATA)
- blk_mq_end_request
- bio_endio
- f2fs_write_end_io
: dec_page_count(sbi, F2FS_WB_CP_DATA)
: wake_up(&sbi->cp_wait)
- kill_f2fs_super
- kill_block_super
- f2fs_put_super
: iput(sbi->node_inode)
: sbi->node_inode = NULL
: f2fs_in_warm_node_list
- is_node_folio // sbi->node_inode is NULL and panic
The root cause is that f2fs_put_super() calls iput(sbi->node_inode) and
sets sbi->node_inode to NULL after sbi->nr_pages[F2FS_WB_CP_DATA] is
decremented to zero. As a result, f2fs_in_warm_node_list() may
dereference a NULL node_inode when checking whether a folio belongs to
the node inode, leading to a panic.
This patch fixes the issue by calling f2fs_in_warm_node_list() before
decrementing sbi->nr_pages[F2FS_WB_CP_DATA], thus preventing the
use-after-free condition.
📍 영향받는 시스템
Linux kernel f2fs 파일 시스템 지원 버전 (특히 고병렬 I/O 환경에서 xfstests generic/107 테스트 케이스 실행 시)
⚔️ 공격 벡터
로컬 공격자가 f2fs 마운트된 파일 시스템에서 동시에 파일 쓰기와 언마운트를 수행하여 경합 조건 유발
🛡️ 대응 방법
커널을 CVE 패치가 포함된 최신 버전으로 업그레이드하거나 f2fs 파일 시스템 대신 ext4 등 안정화된 파일 시스템 사용
🔧 검증 코드
f2fs가 enabled되면 취약한 파일 시스템이 활성화된 상태이고, uname -r의 커널 버전을 확인하여 패치 적용 여부를 검증합니다.
grep 'f2fs' /proc/filesystems > /dev/null && echo 'f2fs enabled' && uname -r