🇰🇷 한글 설명
Linux 커널 ext4 파일시스템에서, 심볼릭 링크 경로 탐색(RCU pathwalk) 중인 스레드가 마운트의 마지막 참조가 해제되는 시점에 ext4_put_super()에서 이미 해제된 sbi 구조체나 s_fs_info(NULL)를 역참조하는 문제가 해결되었습니다. 해결책으로 sbi와 extent status 카운터를 RCU 유예 기간 이후에 해제하도록 변경되었습니다.
💡 쉬운 설명
리눅스 파일시스템이 언마운트되는 순간 아직 파일 경로를 찾고 있던 프로세스가 이미 지워진 메모리를 읽어 커널이 충돌(널 포인터 역참조)할 수 있었습니다. 이제 메모리 해제를 잠시 미뤄 이런 경쟁 상태를 막습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
ext4: free the sbi after a grace period
ext4_get_link() follows a symlink that keeps its target in a data block
in rcu pathwalk mode with ext4_getblk(EXT4_GET_BLOCKS_CACHED_NOWAIT).
That reads s_mount_state in the ASSERT() of ext4_getblk() and again in
ext4_es_lookup_extent(), and the lookup bumps the extent status hit or
miss counter, all through sb->s_fs_info.
ext4_put_super() destroys those counters, clears sb->s_fs_info and frees
the sbi without waiting for a grace period. A pathwalk that is still in
ext4_get_link() when the last reference to the mount goes away then
dereferences a NULL s_fs_info, the freed sbi or the destroyed percpu
counters.
With a pathwalk held up in ext4_get_link() while the last reference
goes away:
KASAN: null-ptr-deref in range [0x00000000000000a8-0x00000000000000af]
RIP: 0010:ext4_getblk+0xf0/0x640
Call Trace:
<TASK>
ext4_get_link+0x26c/0x410
pick_link+0xf96/0x1780
step_into_slowpath+0x9b8/0x1250
path_lookupat+0x484/0xb00
filename_lookup+0x1f1/0x5b0
vfs_statx+0xd7/0x3b0
vfs_fstatat+0x4d/0x90
__do_sys_newfstatat+0xa0/0x100
do_syscall_64+0x10e/0x5e0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
So far that has been hard to hit. umount(2) waits for a grace period in
namespace_unlock() before it drops the mount, so only a mount whose last
reference goes away elsewhere, like the close of a file or a chdir out of
a lazily unmounted directory, can race a walker.
Keep sb->s_fs_info and free the sbi together with the extent status
counters after a grace period. Split the counters out of
ext4_es_unregister_shrinker() for that. The shrinker still gets wasted
in ext4_put_super(), the counters go with the sbi.
📍 영향받는 시스템
수정 이전의 ext4 파일시스템을 사용하는 Linux 커널 (패치가 적용되지 않은 배포판 및 커널 버전)
⚔️ 공격 벡터
로컬 사용자가 심볼릭 링크를 탐색하는 동시에 마운트의 마지막 참조를 해제하도록 유도하여 커널 NULL 포인터 역참조 또는 해제된 메모리 접근을 일으켜 서비스 거부(커널 패닉)를 유발할 수 있음
🛡️ 대응 방법
배포판 제공 커널 보안 업데이트를 적용하거나 해당 upstream 커널 패치가 포함된 버전으로 업그레이드
🔧 검증 코드
커널 버전을 확인한 후 배포판 보안 공지 또는 changelog에서 해당 CVE 패치 포함 여부를 대조하며, 패치가 포함되지 않은 버전이면 취약한 것으로 판단
uname -r && grep -i ext4 /proc/filesystems