🇰🇷 한글 설명
Linux 커널 kprobes 서브시스템에서, ftrace 기반 프로브를 해제할 때 aggrprobe의 post_handler가 잘못 지워져 disarm 과정에서 경고 및 use-after-free가 발생할 수 있는 문제입니다. 패치는 kprobe-on-ftrace 경우에 post_handler를 유지하여 kprobe_ipmodify_ops로 armed된 프로브를 올바르게 disarm하도록 합니다.
💡 쉬운 설명
리눅스 커널의 디버깅 기능(kprobes)에서 특정 모듈을 제거할 때 내부 정리 절차가 잘못되어 시스템 경고나 메모리 오류가 생길 수 있습니다. 이를 수정하여 모듈 제거 시 커널이 안정적으로 동작하도록 고쳤습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
kprobes: Skip clearing aggrprobe's post_handler in kprobe-on-ftrace case
In __unregister_kprobe_top(), if the currently unregistered probe has
post_handler but other child probes of the aggrprobe do not have
post_handler, the post_handler of the aggrprobe is cleared. If this is
a ftrace-based probe, there is a problem. In later calls to
disarm_kprobe(), we will use kprobe_ftrace_ops because post_handler is
NULL. But we're armed with kprobe_ipmodify_ops. This triggers a WARN in
__disarm_kprobe_ftrace() and may even cause use-after-free:
Failed to disarm kprobe-ftrace at kernel_clone+0x0/0x3c0 (error -2)
WARNING: CPU: 5 PID: 137 at kernel/kprobes.c:1135 __disarm_kprobe_ftrace.isra.21+0xcf/0xe0
Modules linked in: testKprobe_007(-)
CPU: 5 PID: 137 Comm: rmmod Not tainted 6.1.0-rc4-dirty #18
[...]
Call Trace:
<TASK>
__disable_kprobe+0xcd/0xe0
__unregister_kprobe_top+0x12/0x150
? mutex_lock+0xe/0x30
unregister_kprobes.part.23+0x31/0xa0
unregister_kprobe+0x32/0x40
__x64_sys_delete_module+0x15e/0x260
? do_user_addr_fault+0x2cd/0x6b0
do_syscall_64+0x3a/0x90
entry_SYSCALL_64_after_hwframe+0x63/0xcd
[...]
For the kprobe-on-ftrace case, we keep the post_handler setting to
identify this aggrprobe armed with kprobe_ipmodify_ops. This way we
can disarm it correctly.
📍 영향받는 시스템
수정 전 Linux 커널 (kprobes를 ftrace 기반으로 사용하는 버전, 예: 6.1-rc 계열 및 해당 패치 이전 안정 버전)
⚔️ 공격 벡터
로컬 권한을 가진 사용자가 kprobe 기반 모듈을 로드·제거하는 과정에서 트리거될 수 있으며, 메모리 손상으로 이어질 가능성이 있습니다.
🛡️ 대응 방법
해당 커밋이 포함된 최신 커널 버전으로 업데이트하거나 배포판의 보안 커널 패키지를 설치하세요.
🔧 검증 코드
출력된 커널 버전을 배포판 보안 공지 또는 upstream 패치 정보와 대조하여, 해당 수정이 포함된 버전인지 확인합니다 (패치 이후 버전이면 취약하지 않음).