🇰🇷 한글 설명
Linux 커널 BPF 소켓 맵(sockmap/sockhash)의 map_delete_elem 작업에서 발생하는 락 반전(lock inversion) 교착 상태 취약점이다. 인터럽트 비활성 상태의 컨텍스트에서 호출되면 하드 IRQ 안전하지 않은 락들이 데드락을 일으킬 수 있으며, 이를 방지하기 위해 커널은 그러한 호출을 감지하여 거부한다.
💡 쉬운 설명
Linux 커널에서 여러 프로세스가 공유 메모리 접근 시 사용하는 잠금 메커니즘이 특정 상황에서 교착 상태를 일으킬 수 있습니다. 커널이 이를 감지하여 위험한 상황에서 작업을 차단합니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
bpf, sockmap: Prevent lock inversion deadlock in map delete elem
syzkaller started using corpuses where a BPF tracing program deletes
elements from a sockmap/sockhash map. Because BPF tracing programs can be
invoked from any interrupt context, locks taken during a map_delete_elem
operation must be hardirq-safe. Otherwise a deadlock due to lock inversion
is possible, as reported by lockdep:
CPU0 CPU1
---- ----
lock(&htab->buckets[i].lock);
local_irq_disable();
lock(&host->lock);
lock(&htab->buckets[i].lock);
<Interrupt>
lock(&host->lock);
Locks in sockmap are hardirq-unsafe by design. We expects elements to be
deleted from sockmap/sockhash only in task (normal) context with interrupts
enabled, or in softirq context.
Detect when map_delete_elem operation is invoked from a context which is
_not_ hardirq-unsafe, that is interrupts are disabled, and bail out with an
error.
Note that map updates are not affected by this issue. BPF verifier does not
allow updating sockmap/sockhash from a BPF tracing program today.
📍 영향받는 시스템
Linux 커널 5.14 이상의 BPF sockmap/sockhash 기능 사용 시스템
⚔️ 공격 벡터
BPF tracing 프로그램에서 인터럽트가 비활성화된 컨텍스트에서 sockmap/sockhash 맵 요소 삭제 호출
🛡️ 대응 방법
Linux 커널을 최신 LTS 버전 이상으로 업그레이드 또는 보안 패치 적용
🔧 검증 코드
커널 버전이 5.14 이상이면 패치가 포함되어 있으며, 이하 버전은 취약점 존재 가능성이 있습니다.