🇰🇷 한글 설명
Linux 커널의 BPF sockmap 코드에서, 리스닝 소켓을 복제할 때 자식 소켓이 tcp_bpf_prots의 모든 변형을 올바르게 검사하지 않아 원래 프로토콜로 복원되지 않는 문제가 해결되었습니다. 이로 인해 close 시 무한 재귀가 발생할 수 있었습니다.
💡 쉬운 설명
리눅스 커널의 네트워크 기능에서 소켓을 복사하는 과정의 버그입니다. 이 버그로 인해 연결을 닫을 때 시스템이 끝없이 반복 호출되어 불안정해질 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
bpf, sockmap: Check for any of tcp_bpf_prots when cloning a listener
A listening socket linked to a sockmap has its sk_prot overridden. It
points to one of the struct proto variants in tcp_bpf_prots. The variant
depends on the socket's family and which sockmap programs are attached.
A child socket cloned from a TCP listener initially inherits their sk_prot.
But before cloning is finished, we restore the child's proto to the
listener's original non-tcp_bpf_prots one. This happens in
tcp_create_openreq_child -> tcp_bpf_clone.
Today, in tcp_bpf_clone we detect if the child's proto should be restored
by checking only for the TCP_BPF_BASE proto variant. This is not
correct. The sk_prot of listening socket linked to a sockmap can point to
to any variant in tcp_bpf_prots.
If the listeners sk_prot happens to be not the TCP_BPF_BASE variant, then
the child socket unintentionally is left if the inherited sk_prot by
tcp_bpf_clone.
This leads to issues like infinite recursion on close [1], because the
child state is otherwise not set up for use with tcp_bpf_prot operations.
Adjust the check in tcp_bpf_clone to detect all of tcp_bpf_prots variants.
Note that it wouldn't be sufficient to check the socket state when
overriding the sk_prot in tcp_bpf_update_proto in order to always use the
TCP_BPF_BASE variant for listening sockets. Since commit
b8b8315e39ff ("bpf, sockmap: Remove unhash handler for BPF sockmap usage")
it is possible for a socket to transition to TCP_LISTEN state while already
linked to a sockmap, e.g. connect() -> insert into map ->
connect(AF_UNSPEC) -> listen().
[1]: https://lore.kernel.org/all/
[email protected]/
📍 영향받는 시스템
BPF sockmap 기능을 사용하는 Linux 커널 (수정 커밋 이전의 여러 안정 버전)
⚔️ 공격 벡터
로컬 사용자가 sockmap과 리스닝 소켓을 특정 순서로 조작하여 커널 무한 재귀(서비스 거부)를 유발할 수 있음
🛡️ 대응 방법
배포판의 최신 커널 업데이트를 적용하고 재부팅하기
🔧 검증 코드
출력된 커널 버전을 배포판 보안 공지에서 해당 CVE 패치가 포함된 버전과 비교하고, 패치 이전 버전이면 업데이트가 필요합니다.