🇰🇷 한글 설명
Linux 커널의 ext4 파일시스템 마운트 과정(__ext4_fill_super)에서, sysfs 등록이 ratelimit_state 락 초기화보다 먼저 이루어져 초기화되지 않은 락에 접근할 수 있는 문제가 수정되었습니다. 이를 해결하기 위해 모든 초기화가 끝난 후에 sysfs를 등록하도록 변경되었습니다.
💡 쉬운 설명
리눅스 파일시스템을 마운트하는 과정에서 아직 준비되지 않은 내부 잠금 장치를 사용하는 순서 문제가 있었습니다. 설정 순서를 바꿔 준비가 끝난 뒤에 관련 기능을 등록하도록 수정되었습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
ext4: fix uninitialized ratelimit_state->lock access in __ext4_fill_super()
In the following concurrency we will access the uninitialized rs->lock:
ext4_fill_super
ext4_register_sysfs
// sysfs registered msg_ratelimit_interval_ms
// Other processes modify rs->interval to
// non-zero via msg_ratelimit_interval_ms
ext4_orphan_cleanup
ext4_msg(sb, KERN_INFO, "Errors on filesystem, "
__ext4_msg
___ratelimit(&(EXT4_SB(sb)->s_msg_ratelimit_state)
if (!rs->interval) // do nothing if interval is 0
return 1;
raw_spin_trylock_irqsave(&rs->lock, flags)
raw_spin_trylock(lock)
_raw_spin_trylock
__raw_spin_trylock
spin_acquire(&lock->dep_map, 0, 1, _RET_IP_)
lock_acquire
__lock_acquire
register_lock_class
assign_lock_key
dump_stack();
ratelimit_state_init(&sbi->s_msg_ratelimit_state, 5 * HZ, 10);
raw_spin_lock_init(&rs->lock);
// init rs->lock here
and get the following dump_stack:
=========================================================
INFO: trying to register non-static key.
The code is fine but needs lockdep annotation, or maybe
you didn't initialize this object before use?
turning off the locking correctness validator.
CPU: 12 PID: 753 Comm: mount Tainted: G E 6.7.0-rc6-next-20231222 #504
[...]
Call Trace:
dump_stack_lvl+0xc5/0x170
dump_stack+0x18/0x30
register_lock_class+0x740/0x7c0
__lock_acquire+0x69/0x13a0
lock_acquire+0x120/0x450
_raw_spin_trylock+0x98/0xd0
___ratelimit+0xf6/0x220
__ext4_msg+0x7f/0x160 [ext4]
ext4_orphan_cleanup+0x665/0x740 [ext4]
__ext4_fill_super+0x21ea/0x2b10 [ext4]
ext4_fill_super+0x14d/0x360 [ext4]
[...]
=========================================================
Normally interval is 0 until s_msg_ratelimit_state is initialized, so
___ratelimit() does nothing. But registering sysfs precedes initializing
rs->lock, so it is possible to change rs->interval to a non-zero value
via the msg_ratelimit_interval_ms interface of sysfs while rs->lock is
uninitialized, and then a call to ext4_msg triggers the problem by
accessing an uninitialized rs->lock. Therefore register sysfs after all
initializations are complete to avoid such problems.
📍 영향받는 시스템
ext4 파일시스템을 사용하는 Linux 커널 (수정 이전의 6.x 계열 등 해당 패치 이전 버전)
⚔️ 공격 벡터
로컬 권한을 가진 사용자가 sysfs의 msg_ratelimit_interval_ms 값을 변경해 초기화되지 않은 락 접근을 유발할 수 있음
🛡️ 대응 방법
커널을 CVE-2024-40998 수정이 포함된 최신 안정 버전으로 업데이트하고 재부팅
🔧 검증 코드
출력된 커널 버전을 배포판 보안 공지 또는 커널 패치 목록과 비교하여, 해당 수정이 포함된 버전 이상인지 확인합니다 (수정 여부는 배포판 changelog에서 CVE-2024-40998 검색으로도 확인 가능).