🇰🇷 한글 설명
Linux 커널의 bpf_sk_select_reuseport() 함수에서 TCP ESTABLISHED 소켓 참조가 올바르게 해제되지 않아 메모리 누수가 발생합니다. SO_ATTACH_REUSEPORT_EBPF가 설정된 소켓에서 에러 경로 시 참조 카운트를 감소시키지 않는 버그입니다.
💡 쉬운 설명
Linux 커널의 네트워크 기능에서 사용한 메모리를 제대로 돌려주지 않는 문제입니다. 반복되면 시스템 메모리가 부족해져 성능 저하나 시스템 중단이 발생할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
bpf: Fix bpf_sk_select_reuseport() memory leak
As pointed out in the original comment, lookup in sockmap can return a TCP
ESTABLISHED socket. Such TCP socket may have had SO_ATTACH_REUSEPORT_EBPF
set before it was ESTABLISHED. In other words, a non-NULL sk_reuseport_cb
does not imply a non-refcounted socket.
Drop sk's reference in both error paths.
unreferenced object 0xffff888101911800 (size 2048):
comm "test_progs", pid 44109, jiffies 4297131437
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
80 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace (crc 9336483b):
__kmalloc_noprof+0x3bf/0x560
__reuseport_alloc+0x1d/0x40
reuseport_alloc+0xca/0x150
reuseport_attach_prog+0x87/0x140
sk_reuseport_attach_bpf+0xc8/0x100
sk_setsockopt+0x1181/0x1990
do_sock_setsockopt+0x12b/0x160
__sys_setsockopt+0x7b/0xc0
__x64_sys_setsockopt+0x1b/0x30
do_syscall_64+0x93/0x180
entry_SYSCALL_64_after_hwframe+0x76/0x7e
📍 영향받는 시스템
Linux 커널 (BPF reuseport 기능 활성화된 시스템)
⚔️ 공격 벡터
로컬 사용자가 BPF 프로그램을 로드하고 SO_ATTACH_REUSEPORT_EBPF 옵션을 통해 메모리 누수 유발
🛡️ 대응 방법
영향받는 Linux 커널 버전에 대한 최신 보안 패치를 적용하여 메모리 해제 로직 수정
🔧 검증 코드
커널 버전 확인 후 BPF와 REUSEPORT가 활성화되어 있으면 해당 커널 버전의 패치 상태 확인 필요
uname -r && grep -E 'CONFIG_BPF=y|CONFIG_REUSEPORT' /boot/config-$(uname -r) 2>/dev/null