🇰🇷 한글 설명
리눅스 커널의 vsock vmci_transport_recv_dgram_cb() 함수에서 데이터그램 소켓 종료 중 백로그로 들어간 패킷이 수신 큐 정리 이후 되돌아오면서 메모리 누수가 발생합니다. 이 문제는 소켓 소멸자에 수신 큐 정리 로직을 추가하여 해결되었습니다.
💡 쉬운 설명
리눅스 커널에서 가상 머신 통신 소켓을 닫을 때 일부 데이터가 제대로 해제되지 않아 메모리가 계속 낭비되는 문제입니다. 패치를 적용하면 소켓 종료 시 남은 데이터가 정리되어 누수가 사라집니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
vsock: Fix memory leak in vmci_transport_recv_dgram_cb()
During the closure of a datagram socket, the vmci_transport_recv_dgram_cb()
function may be called, which will add the packets
to the socket's backlog; then, after the receive queue is cleared,
the __release_sock() function will move the packet back from the socket's
backlog to the receive queue, which will lead to a memory leak.
sock_close
__sock_release
__vsock_release
// take ownership by user-space
lock_sock_nested
sock_set_flag(sk, SOCK_DEAD)
vmci_transport_release
vmci_dispatch_dgs
vmci_datagram_invoke_guest_handler
vmci_transport_recv_dgram_cb
sk_receive_skb
if (!sock_owned_by_user(sk))
[...]
(!) else if sk_add_backlog()
[...]
(!) skb_queue_purge(&sk->sk_receive_queue)
release_sock
__release_sock
// move all packets from the backlog
// to the receive queue
(!) sk_backlog_rcv
vsock_queue_rcv_skb
[...]
__sock_queue_rcv_skb
if (!sock_flag(sk, SOCK_DEAD))
// Since the socket is "dead", the function will not
// be called
sk->sk_data_ready(sk)
sock_release_ownership(sk);
sock_put
Add a receive queue cleanup in the socket destructor to fix this.
syzkaller report:
unreferenced object 0xffff8880117bfb80 (size 240):
comm "irq/56-vmw_vmci", pid 205, jiffies 4295064448 (age 73.992s)
hex dump (first 32 bytes):
78 dc 26 1e 80 88 ff ff 78 dc 26 1e 80 88 ff ff x.&.....x.&.....
00 00 00 00 00 00 00 00 c0 da 26 1e 80 88 ff ff ..........&.....
backtrace:
[<ffffffff82be8d97>] __alloc_skb+0x287/0x330 net/core/skbuff.c:505
[<ffffffffa114bcbd>] vmci_transport_recv_dgram_cb+0xbd/0x210 [vmw_vsock_vmci_transport]
[<ffffffffa05072c6>] vmci_datagram_invoke_guest_handler+0x366/0x450 [vmw_vmci]
[<ffffffffa050ad75>] vmci_dispatch_dgs+0x235/0x490 [vmw_vmci]
[<ffffffffa050b025>] vmci_interrupt+0x55/0x290 [vmw_vmci]
[<ffffffff8137ad2b>] irq_thread_fn+0x8b/0x1a0 kernel/irq/manage.c:1205
[<ffffffff8137c7ae>] irq_thread+0x28e/0x530 kernel/irq/manage.c:1314
[<ffffffff81253dd6>] kthread+0x2e6/0x3a0 kernel/kthread.c:376
[<ffffffff81004392>] ret_from_fork+0x22/0x30 arch/x86/entry/entry_64.S:295
Found by InfoTeCS on behalf of Linux Verification Center
(linuxtesting.org) with Syzkaller.
📍 영향받는 시스템
vsock(VMCI 전송)을 사용하는 수정 이전의 리눅스 커널 버전 (CVSS 미정, 영향 버전 상세 정보 부족)
⚔️ 공격 벡터
로컬 사용자가 vsock 데이터그램 소켓을 반복적으로 열고 닫는 방식으로 커널 메모리를 점진적으로 소모시킬 수 있음
🛡️ 대응 방법
배포판 제공 최신 커널로 업데이트하여 소켓 소멸자의 수신 큐 정리 패치를 적용
🔧 검증 코드
커널 버전이 패치가 포함된 최신 배포판 커널인지 확인하고, 모듈이 로드되어 있지 않다면 해당 기능이 사용되지 않아 영향이 없음을 의미하며, 로드되어 있다면 업데이트 여부를 점검해야 합니다.
uname -r && lsmod | grep -E 'vmw_vsock_vmci_transport|vmw_vmci'