🇰🇷 한글 설명
리눅스 커널의 BPF 구현에서 읽기 전용(read-only)으로 설정된 맵에 데이터를 쓸 수 있는 취약점이 발견되었습니다. 특정 헬퍼 함수가 인자를 처리할 때 메모리 접근 권한을 제대로 검증하지 않아, 동결된 BPF 맵의 내용을 수정할 수 있는 문제가 있었습니다.
💡 쉬운 설명
컴퓨터의 중요한 정보를 담고 있는 '읽기 전용' 메모리 영역에 몰래 글을 쓸 수 있는 보안 구멍이 발견되었습니다. 이를 통해 공격자가 시스템의 보호된 데이터를 변조할 위험이 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
bpf: Fix helper writes to read-only maps
Lonial found an issue that despite user- and BPF-side frozen BPF map
(like in case of .rodata), it was still possible to write into it from
a BPF program side through specific helpers having ARG_PTR_TO_{LONG,INT}
as arguments.
In check_func_arg() when the argument is as mentioned, the meta->raw_mode
is never set. Later, check_helper_mem_access(), under the case of
PTR_TO_MAP_VALUE as register base type, it assumes BPF_READ for the
subsequent call to check_map_access_type() and given the BPF map is
read-only it succeeds.
The helpers really need to be annotated as ARG_PTR_TO_{LONG,INT} | MEM_UNINIT
when results are written into them as opposed to read out of them. The
latter indicates that it's okay to pass a pointer to uninitialized memory
as the memory is written to anyway.
However, ARG_PTR_TO_{LONG,INT} is a special case of ARG_PTR_TO_FIXED_SIZE_MEM
just with additional alignment requirement. So it is better to just get
rid of the ARG_PTR_TO_{LONG,INT} special cases altogether and reuse the
fixed size memory types. For this, add MEM_ALIGNED to additionally ensure
alignment given these helpers write directly into the args via *<ptr> = val.
The .arg*_size has been initialized reflecting the actual sizeof(*<ptr>).
MEM_ALIGNED can only be used in combination with MEM_FIXED_SIZE annotated
argument types, since in !MEM_FIXED_SIZE cases the verifier does not know
the buffer size a priori and therefore cannot blindly write *<ptr> = val.
📍 영향받는 시스템
Linux Kernel (BPF 기능이 활성화된 버전)
⚔️ 공격 벡터
특정 인자를 사용하는 BPF 헬퍼 함수를 통해 읽기 전용으로 설정된 BPF 맵에 쓰기 작업을 시도
🛡️ 대응 방법
리눅스 커널을 최신 보안 패치가 적용된 버전으로 업데이트
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 해결된 최신 패치 버전인지 확인