🇰🇷 한글 설명
Linux 커널의 BPF_PROG_QUERY 과정에서 사용자 공간의 구조체 크기가 작을 경우, 'query.revision' 필드를 조건 없이 기록하여 발생하는 Out-of-Bounds(OOB) 쓰기 취약점입니다. 이 문제는 특히 하위 호환성을 유지해야 하는 cgroup 관련 쿼리 처리 시 발생할 수 있습니다.
💡 쉬운 설명
프로그램이 정보를 요청할 때 준비된 메모리 공간보다 더 많은 정보를 강제로 적어 넣으려다 발생하는 오류입니다. 이로 인해 시스템의 중요한 메모리 영역이 잘못된 값으로 덮어씌워질 위험이 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
bpf: fix BPF_PROG_QUERY OOB write and cgroup backward compat
BPF_PROG_QUERY writes back the 'query.revision' field unconditionally to
userspace. If userspace passes a smaller 'bpf_attr' structure (e.g. 40
bytes, which was the layout before the addition of 'query.revision'),
the kernel performs an out-of-bounds write.
Fix this by propagating the user-provided attribute size 'uattr_size'
down to the cgroup query handlers, and conditionally skipping writing
the revision field to userspace when the provided buffer size is
insufficient.
query.revision in bpf_mprog_query is structurally identical to the
cgroup case: a late tail field, written unconditionally.
But the backward-compat hazard is not the same.
The min-historical-size test is per command, and bpf_mprog_query only
serves attach types that were born with revision in the struct:
- tcx_prog_query -> BPF_TCX_INGRESS/EGRESS
- netkit_prog_query -> BPF_NETKIT_PRIMARY/PEER
tcx, netkit, the revision field, and bpf_mprog_query itself all landed in
the same v6.6 merge window (053c8e1f235d added the mprog query API +
revision; tcx in e420bed02507, netkit in 35dfaad7188c). There has never
been a tcx/netkit BPF_PROG_QUERY userspace that doesn't know about
revision. So for these commands the minimum legitimate struct already
covers offset 56-64 — no old binary can be broken here.
Contrast with cgroup: BPF_PROG_QUERY on cgroup attach types shipped in
2017; revision write-back was bolted on years later (120933984460). That
path has a real population of pre-revision callers.
📍 영향받는 시스템
Linux Kernel (BPF subsystem 사용 시스템)
⚔️ 공격 벡터
작은 크기의 bpf_attr 구조체를 사용하는 사용자 공간 애플리케이션을 통한 메모리 오버라이트
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트하여 BPF 쿼리 핸들러의 크기 검증 로직을 적용해야 합니다.
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 수정된 패치 버전 이후인지 확인합니다.