🇰🇷 한글 설명
Linux 커널 f2fs 파일시스템에서 extent_cache 트리 할당 시 동적 조건을 초기 조건과 분리하지 않아, 압축 플래그가 설정된 파일의 압축을 해제한 뒤 extent_cache 갱신 중 NULL 포인터 역참조가 발생할 수 있습니다. 이로 인해 커널 패닉이 일어날 수 있습니다. 확인된 사례는 fallocate 호출 중 발생하는 KASAN null-ptr-deref입니다.
💡 쉬운 설명
리눅스 저장장치 파일시스템(f2fs)의 내부 캐시 설정에 빠진 조건이 있어, 특정 순서로 파일을 조작하면 시스템이 갑자기 멈출 수 있습니다. 공격자가 이를 악용해 서비스 거부 상태를 만들 가능성이 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
f2fs: split initial and dynamic conditions for extent_cache
Let's allocate the extent_cache tree without dynamic conditions to avoid a
missing condition causing a panic as below.
# create a file w/ a compressed flag
# disable the compression
# panic while updating extent_cache
F2FS-fs (dm-64): Swapfile: last extent is not aligned to section
F2FS-fs (dm-64): Swapfile (3) is not align to section: 1) creat(), 2) ioctl(F2FS_IOC_SET_PIN_FILE), 3) fallocate(2097152 * N)
Adding 124996k swap on ./swap-file. Priority:0 extents:2 across:17179494468k
==================================================================
BUG: KASAN: null-ptr-deref in instrument_atomic_read_write out/common/include/linux/instrumented.h:101 [inline]
BUG: KASAN: null-ptr-deref in atomic_try_cmpxchg_acquire out/common/include/asm-generic/atomic-instrumented.h:705 [inline]
BUG: KASAN: null-ptr-deref in queued_write_lock out/common/include/asm-generic/qrwlock.h:92 [inline]
BUG: KASAN: null-ptr-deref in __raw_write_lock out/common/include/linux/rwlock_api_smp.h:211 [inline]
BUG: KASAN: null-ptr-deref in _raw_write_lock+0x5a/0x110 out/common/kernel/locking/spinlock.c:295
Write of size 4 at addr 0000000000000030 by task syz-executor154/3327
CPU: 0 PID: 3327 Comm: syz-executor154 Tainted: G O 5.10.185 #1
Hardware name: emulation qemu-x86/qemu-x86, BIOS 2023.01-21885-gb3cc1cd24d 01/01/2023
Call Trace:
__dump_stack out/common/lib/dump_stack.c:77 [inline]
dump_stack_lvl+0x17e/0x1c4 out/common/lib/dump_stack.c:118
__kasan_report+0x16c/0x260 out/common/mm/kasan/report.c:415
kasan_report+0x51/0x70 out/common/mm/kasan/report.c:428
kasan_check_range+0x2f3/0x340 out/common/mm/kasan/generic.c:186
__kasan_check_write+0x14/0x20 out/common/mm/kasan/shadow.c:37
instrument_atomic_read_write out/common/include/linux/instrumented.h:101 [inline]
atomic_try_cmpxchg_acquire out/common/include/asm-generic/atomic-instrumented.h:705 [inline]
queued_write_lock out/common/include/asm-generic/qrwlock.h:92 [inline]
__raw_write_lock out/common/include/linux/rwlock_api_smp.h:211 [inline]
_raw_write_lock+0x5a/0x110 out/common/kernel/locking/spinlock.c:295
__drop_extent_tree+0xdf/0x2f0 out/common/fs/f2fs/extent_cache.c:1155
f2fs_drop_extent_tree+0x17/0x30 out/common/fs/f2fs/extent_cache.c:1172
f2fs_insert_range out/common/fs/f2fs/file.c:1600 [inline]
f2fs_fallocate+0x19fd/0x1f40 out/common/fs/f2fs/file.c:1764
vfs_fallocate+0x514/0x9b0 out/common/fs/open.c:310
ksys_fallocate out/common/fs/open.c:333 [inline]
__do_sys_fallocate out/common/fs/open.c:341 [inline]
__se_sys_fallocate out/common/fs/open.c:339 [inline]
__x64_sys_fallocate+0xb8/0x100 out/common/fs/open.c:339
do_syscall_64+0x35/0x50 out/common/arch/x86/entry/common.c:46
📍 영향받는 시스템
f2fs 파일시스템을 사용하는 Linux 커널 (수정 커밋 이전 버전, 예: 5.10.x 계열 일부)
⚔️ 공격 벡터
로컬 사용자가 f2fs 파일에 압축 플래그를 설정한 뒤 압축을 끄고 fallocate 등을 호출하여 커널 패닉을 유발
🛡️ 대응 방법
배포판 커널을 CVE-2023-52770 수정이 포함된 최신 보안 업데이트 커널로 업그레이드하고 재부팅
🔧 검증 코드
커널 버전이 배포판의 CVE 수정 패치 버전 이상인지 확인하고, f2fs가 출력되면 해당 파일시스템이 지원되는 환경이므로 배포판 보안 공지에서 패치 여부를 대조합니다.
uname -r; grep -w f2fs /proc/filesystems 2>/dev/null