🇰🇷 한글 설명
Linux 커널의 bpf_core_parse_spec() 함수에서 CO-RE accessor 인덱스를 처리할 때 음수 값을 적절히 검증하지 못하는 취약점입니다. 음수 인덱스가 입력될 경우 정수 프로모션 오류로 인해 경계 검사를 우회하며, 결과적으로 커널 메모리의 범위를 벗어난 읽기(Out-of-bounds read)를 유발하여 시스템 충돌을 일으킵니다.
💡 쉬운 설명
리눅스 커널의 특정 기능을 사용할 때 잘못된 숫자(음수)를 입력하면 컴퓨터가 계산을 잘못하여 시스템이 갑자기 멈추거나 꺼질 수 있는 문제입니다. 공격자가 특수하게 제작된 프로그램을 실행하면 시스템을 강제로 다운시킬 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
bpf: reject negative CO-RE accessor indices in bpf_core_parse_spec()
CO-RE accessor strings are colon-separated indices that describe a path
from a root BTF type to a target field, e.g. "0:1:2" walks through
nested struct members. bpf_core_parse_spec() parses each component with
sscanf("%d"), so negative values like -1 are silently accepted. The
subsequent bounds checks (access_idx >= btf_vlen(t)) only guard the
upper bound and always pass for negative values because C integer
promotion converts the __u16 btf_vlen result to int, making the
comparison (int)(-1) >= (int)(N) false for any positive N.
When -1 reaches btf_member_bit_offset() it gets cast to u32 0xffffffff,
producing an out-of-bounds read far past the members array. A crafted
BPF program with a negative CO-RE accessor on any struct that exists in
vmlinux BTF (e.g. task_struct) crashes the kernel deterministically
during BPF_PROG_LOAD on any system with CONFIG_DEBUG_INFO_BTF=y
(default on major distributions). The bug is reachable with CAP_BPF:
BUG: unable to handle page fault for address: ffffed11818b6626
#PF: supervisor read access in kernel mode
#PF: error_code(0x0000) - not-present page
Oops: Oops: 0000 [#1] SMP KASAN NOPTI
CPU: 0 UID: 0 PID: 85 Comm: poc Not tainted 7.0.0-rc6 #18 PREEMPT(full)
RIP: 0010:bpf_core_parse_spec (tools/lib/bpf/relo_core.c:354)
RAX: 00000000ffffffff
Call Trace:
<TASK>
bpf_core_calc_relo_insn (tools/lib/bpf/relo_core.c:1321)
bpf_core_apply (kernel/bpf/btf.c:9507)
check_core_relo (kernel/bpf/verifier.c:19475)
bpf_check (kernel/bpf/verifier.c:26031)
bpf_prog_load (kernel/bpf/syscall.c:3089)
__sys_bpf (kernel/bpf/syscall.c:6228)
</TASK>
CO-RE accessor indices are inherently non-negative (struct member index,
array element index, or enumerator index), so reject them immediately
after parsing.
📍 영향받는 시스템
CONFIG_DEBUG_INFO_BTF=y 설정이 활성화된 Linux 커널 (주요 배포판 기본값)
⚔️ 공격 벡터
CAP_BPF 권한을 가진 사용자가 음수 인덱스를 포함한 조작된 BPF 프로그램을 로드하여 커널을 충돌시킴
🛡️ 대응 방법
해당 취약점이 해결된 최신 버전의 Linux 커널로 업데이트
🔧 검증 코드
출력된 커널 버전이 취약점이 패치된 최신 릴리스 버전인지 확인