🇰🇷 한글 설명
Linux 커널의 ring-buffer 구성 요소에서 kthread_run_on_cpu() 실패 시 ERR_PTR이 rb_threads[]에 저장되는 취약점이 발견되었습니다. 기존의 NULL 체크 방식이 ERR_PTR을 걸러내지 못해 kthread_stop() 호출 시 잘못된 포인터를 참조하게 되며, 이로 인해 커널 패닉 및 시스템 충돌이 발생합니다.
💡 쉬운 설명
컴퓨터의 핵심 운영체제인 리눅스에서 특정 작업을 시작하려다 실패했을 때, 잘못된 메모리 주소를 처리하는 과정에서 시스템이 갑자기 멈추거나 꺼지는 오류가 발생할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
ring-buffer: Fix crash passing ERR_PTR to kthread_stop()
In test_ringbuffer()'s out_free cleanup loop, the check
`!rb_threads[cpu]` only catches NULL entries and misses entries that
hold an ERR_PTR.
rb_threads[] is static, so unassigned slots are NULL. But when
kthread_run_on_cpu() fails for a cpu, it stores ERR_PTR(-ENOMEM) (or
-EINTR) in rb_threads[cpu] before the creation loop jumps to out_free.
That entry is non-NULL, so the old `!ptr` check does not break, and the
cleanup proceeds to call kthread_stop() on the ERR_PTR. kthread_stop()
then dereferences the bogus pointer, crashing the kernel during the
late_initcall self-test.
crash logs:
BUG: kernel NULL pointer dereference, address: 000000000000001c
Oops: 0002 [#1] SMP NOPTI
CPU: 1 PID: 1 Comm: swapper/0 Not tainted 7.2.0-rc6-dirty #7 PREEMPT(lazy)
RIP: 0010:kthread_stop+0x2e/0x220
RBX: fffffffffffffff4
CR2: 000000000000001c
Call Trace:
<TASK>
test_ringbuffer+0x1ec/0x650
do_one_initcall+0x6c/0x2c0
kernel_init_freeable+0x21d/0x420
kernel_init+0x15/0x1c0
ret_from_fork+0x21b/0x320
</TASK>
Kernel panic - not syncing: Fatal exception
📍 영향받는 시스템
Linux kernel (특히 7.2.0-rc6 및 관련 ring-buffer 모듈 사용 버전)
⚔️ 공격 벡터
로컬 공격자가 시스템 자원 부족(ENOMEM) 등을 유도하여 커널 초기화 과정에서 충돌을 일으킬 수 있음
🛡️ 대응 방법
커널 패치 적용을 통해 rb_threads[]의 유효성을 검사할 때 NULL뿐만 아니라 ERR_PTR 여부도 확인하도록 업데이트해야 함
🔧 검증 코드
출력된 커널 버전이 취약점이 해결된 패치 버전인지 확인하십시오.