🇰🇷 한글 설명
Linux 커널의 BPF 구현에서 BPF_F_CPU 플래그 검증 로직이 잘못되어 발생한 취약점입니다. CPU ID를 검증할 때 가능한 CPU의 총 개수와 비교하는 오류로 인해, 유효하지 않은 CPU ID가 허용되어 커널 페이지 폴트 및 시스템 충돌을 유발할 수 있습니다.
💡 쉬운 설명
컴퓨터의 두뇌 역할을 하는 CPU 번호를 확인하는 과정에서 실수로 잘못된 번호를 허용하는 버그가 있었습니다. 이로 인해 공격자가 특수한 명령을 보내면 컴퓨터 시스템이 갑자기 멈추거나 오류가 발생할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
bpf: Fix BPF_F_CPU validation for sparse CPU IDs
BPF_F_CPU stores the target CPU ID in the upper 32 bits of the map
operation flags. bpf_map_check_op_flags() currently compares that ID
with num_possible_cpus(), which is the number of possible CPUs rather
than a bound on CPU IDs.
On an arm64 QEMU guest with a CPU device-tree hole, the possible CPU
mask was 0,2-3. A userspace program using raw bpf() syscalls creates
a BPF_MAP_TYPE_PERCPU_ARRAY and performs update and lookup operations
for each CPU by setting BPF_F_CPU and the CPU ID in the flags.
With the old check, CPU 1 is incorrectly accepted while valid CPU 3 is
rejected with -ERANGE. The CPU 1 update then reaches the per-CPU map
access path and triggers:
Unable to handle kernel paging request at virtual address ...
pc : __pi_memcpy_generic+0x5c/0x22c
lr : bpf_percpu_array_update+0x2dc/0x2e8
Call trace:
__pi_memcpy_generic
bpf_map_update_value
map_update_elem
__sys_bpf
Check the CPU ID against nr_cpu_ids and cpu_possible() instead. This
rejects CPU IDs outside the valid range and CPUs absent from the
possible mask, while allowing valid sparse CPU IDs.
📍 영향받는 시스템
Linux kernel (arm64 QEMU guest 환경에서 특히 취약)
⚔️ 공격 벡터
사용자 공간 프로그램에서 raw bpf() 시스템 콜을 사용하여 잘못된 CPU ID가 포함된 BPF_MAP_TYPE_PERCPU_ARRAY 업데이트 요청을 보냄
🛡️ 대응 방법
CPU ID 검증 시 num_possible_cpus() 대신 nr_cpu_ids 및 cpu_possible()을 사용하도록 커널을 최신 버전으로 업데이트
🔧 검증 코드
커널 버전을 확인하고 BPF 설정 활성화 여부를 점검하여 최신 보안 패치가 적용된 커널인지 확인합니다.
uname -a && grep -i 'bpf' /proc/config.gz 2>/dev/null || grep -i 'CONFIG_BPF' /boot/config-$(uname -r)