🇰🇷 한글 설명
Linux 커널의 BPF 구현에서 bpf_link의 참조 횟수가 0이 되었을 때, 실행 중인 BPF 프로그램이 해당 링크 데이터에 여전히 접근할 수 있는 문제가 있었습니다. 이 취약점은 RCU grace period 이후로 bpf_link의 메모리 해제를 지연시키는 기능을 추가하여 해결되었습니다.
💡 쉬운 설명
프로그램이 사용 중인 데이터를 시스템이 너무 빨리 삭제해버려서 오류가 발생할 수 있는 문제입니다. 데이터가 더 이상 필요 없을 때까지 안전하게 기다렸다가 삭제하도록 수정되었습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
bpf: support deferring bpf_link dealloc to after RCU grace period
BPF link for some program types is passed as a "context" which can be
used by those BPF programs to look up additional information. E.g., for
multi-kprobes and multi-uprobes, link is used to fetch BPF cookie values.
Because of this runtime dependency, when bpf_link refcnt drops to zero
there could still be active BPF programs running accessing link data.
This patch adds generic support to defer bpf_link dealloc callback to
after RCU GP, if requested. This is done by exposing two different
deallocation callbacks, one synchronous and one deferred. If deferred
one is provided, bpf_link_free() will schedule dealloc_deferred()
callback to happen after RCU GP.
BPF is using two flavors of RCU: "classic" non-sleepable one and RCU
tasks trace one. The latter is used when sleepable BPF programs are
used. bpf_link_free() accommodates that by checking underlying BPF
program's sleepable flag, and goes either through normal RCU GP only for
non-sleepable, or through RCU tasks trace GP *and* then normal RCU GP
(taking into account rcu_trace_implies_rcu_gp() optimization), if BPF
program is sleepable.
We use this for multi-kprobe and multi-uprobe links, which dereference
link during program run. We also preventively switch raw_tp link to use
deferred dealloc callback, as upcoming changes in bpf-next tree expose
raw_tp link data (specifically, cookie value) to BPF program at runtime
as well.
📍 영향받는 시스템
Linux Kernel (BPF를 사용하는 버전)
⚔️ 공격 벡터
로컬 시스템에서 BPF 프로그램을 실행하여 메모리 해제 시점의 레이스 컨디션을 유도
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 해결된 패치 버전 이상인지 확인