🇰🇷 한글 설명
Linux 커널의 bpf_event_output 함수에서 선점(preemption)을 비활성화하지 않아 발생하는 취약점입니다. bpf_prog_run_array_cg 함수를 통해 실행되는 프로그램이 중첩 보호(nesting protection)를 사용하는 동안 다른 태스크에 의해 선점될 수 있으며, 이로 인해 동일한 perf_sample_data 버퍼를 두 태스크가 동시에 사용하여 커널 크래시(NULL 포인터 역참조)를 유발할 수 있습니다.
💡 쉬운 설명
리눅스 커널의 특정 기능이 작동하는 도중에 다른 작업이 끼어들 수 있어 시스템이 갑자기 멈추거나 오류가 발생하는 문제입니다. 이로 인해 컴퓨터의 핵심인 커널이 충돌하여 시스템이 다운될 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
bpf: Disable preemption in bpf_event_output
We received report [1] of kernel crash, which is caused by
using nesting protection without disabled preemption.
The bpf_event_output can be called by programs executed by
bpf_prog_run_array_cg function that disabled migration but
keeps preemption enabled.
This can cause task to be preempted by another one inside the
nesting protection and lead eventually to two tasks using same
perf_sample_data buffer and cause crashes like:
BUG: kernel NULL pointer dereference, address: 0000000000000001
#PF: supervisor instruction fetch in kernel mode
#PF: error_code(0x0010) - not-present page
...
? perf_output_sample+0x12a/0x9a0
? finish_task_switch.isra.0+0x81/0x280
? perf_event_output+0x66/0xa0
? bpf_event_output+0x13a/0x190
? bpf_event_output_data+0x22/0x40
? bpf_prog_dfc84bbde731b257_cil_sock4_connect+0x40a/0xacb
? xa_load+0x87/0xe0
? __cgroup_bpf_run_filter_sock_addr+0xc1/0x1a0
? release_sock+0x3e/0x90
? sk_setsockopt+0x1a1/0x12f0
? udp_pre_connect+0x36/0x50
? inet_dgram_connect+0x93/0xa0
? __sys_connect+0xb4/0xe0
? udp_setsockopt+0x27/0x40
? __pfx_udp_push_pending_frames+0x10/0x10
? __sys_setsockopt+0xdf/0x1a0
? __x64_sys_connect+0xf/0x20
? do_syscall_64+0x3a/0x90
? entry_SYSCALL_64_after_hwframe+0x72/0xdc
Fixing this by disabling preemption in bpf_event_output.
[1] https://github.com/cilium/cilium/issues/26756
📍 영향받는 시스템
bpf_event_output를 사용하는 취약한 버전의 Linux Kernel
⚔️ 공격 벡터
특정 BPF 프로그램을 실행하여 커널의 선점 메커니즘을 유도함으로써 커널 크래시를 발생시키는 방식
🛡️ 대응 방법
bpf_event_output 함수 내에서 선점(preemption)을 비활성화하도록 패치된 최신 Linux 커널로 업데이트
🔧 검증 코드
출력된 커널 버전을 확인하여 해당 취약점이 해결된 패치 버전인지 확인