🇰🇷 한글 설명
Linux 커널 i40e 드라이버에서 RX 링 버퍼 재할당 시 이미 매핑된 DMA 매핑이 해제되지 않고 누수되는 문제가 있습니다. 이로 인해 ethtool로 링 크기를 반복 변경하면 메모리 할당 실패와 커널 경고(WARNING) 및 드라이버 오류가 발생합니다. 수정으로 BPF 프로그램 로드/언로드 시 ZC용 rx_bi_zc 구조체로 올바르게 재할당하도록 변경되었습니다.
💡 쉬운 설명
네트워크 카드 드라이버가 버퍼 크기를 바꿀 때 사용 중인 메모리 주소를 정리하지 못해 메모리가 조금씩 새어 나갑니다. 이 때문에 시스템이 경고를 띄우거나 네트워크 장치가 제대로 동작하지 않을 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
i40e: Fix DMA mappings leak
During reallocation of RX buffers, new DMA mappings are created for
those buffers.
steps for reproduction:
while :
do
for ((i=0; i<=8160; i=i+32))
do
ethtool -G enp130s0f0 rx $i tx $i
sleep 0.5
ethtool -g enp130s0f0
done
done
This resulted in crash:
i40e 0000:01:00.1: Unable to allocate memory for the Rx descriptor ring, size=65536
Driver BUG
WARNING: CPU: 0 PID: 4300 at net/core/xdp.c:141 xdp_rxq_info_unreg+0x43/0x50
Call Trace:
i40e_free_rx_resources+0x70/0x80 [i40e]
i40e_set_ringparam+0x27c/0x800 [i40e]
ethnl_set_rings+0x1b2/0x290
genl_family_rcv_msg_doit.isra.15+0x10f/0x150
genl_family_rcv_msg+0xb3/0x160
? rings_fill_reply+0x1a0/0x1a0
genl_rcv_msg+0x47/0x90
? genl_family_rcv_msg+0x160/0x160
netlink_rcv_skb+0x4c/0x120
genl_rcv+0x24/0x40
netlink_unicast+0x196/0x230
netlink_sendmsg+0x204/0x3d0
sock_sendmsg+0x4c/0x50
__sys_sendto+0xee/0x160
? handle_mm_fault+0xbe/0x1e0
? syscall_trace_enter+0x1d3/0x2c0
__x64_sys_sendto+0x24/0x30
do_syscall_64+0x5b/0x1a0
entry_SYSCALL_64_after_hwframe+0x65/0xca
RIP: 0033:0x7f5eac8b035b
Missing register, driver bug
WARNING: CPU: 0 PID: 4300 at net/core/xdp.c:119 xdp_rxq_info_unreg_mem_model+0x69/0x140
Call Trace:
xdp_rxq_info_unreg+0x1e/0x50
i40e_free_rx_resources+0x70/0x80 [i40e]
i40e_set_ringparam+0x27c/0x800 [i40e]
ethnl_set_rings+0x1b2/0x290
genl_family_rcv_msg_doit.isra.15+0x10f/0x150
genl_family_rcv_msg+0xb3/0x160
? rings_fill_reply+0x1a0/0x1a0
genl_rcv_msg+0x47/0x90
? genl_family_rcv_msg+0x160/0x160
netlink_rcv_skb+0x4c/0x120
genl_rcv+0x24/0x40
netlink_unicast+0x196/0x230
netlink_sendmsg+0x204/0x3d0
sock_sendmsg+0x4c/0x50
__sys_sendto+0xee/0x160
? handle_mm_fault+0xbe/0x1e0
? syscall_trace_enter+0x1d3/0x2c0
__x64_sys_sendto+0x24/0x30
do_syscall_64+0x5b/0x1a0
entry_SYSCALL_64_after_hwframe+0x65/0xca
RIP: 0033:0x7f5eac8b035b
This was caused because of new buffers with different RX ring count should
substitute older ones, but those buffers were freed in
i40e_configure_rx_ring and reallocated again with i40e_alloc_rx_bi,
thus kfree on rx_bi caused leak of already mapped DMA.
Fix this by reallocating ZC with rx_bi_zc struct when BPF program loads. Additionally
reallocate back to rx_bi when BPF program unloads.
If BPF program is loaded/unloaded and XSK pools are created, reallocate
RX queues accordingly in XSP_SETUP_XSK_POOL handler.
📍 영향받는 시스템
Linux 커널 i40e 드라이버를 사용하는 Intel 이더넷 장치 환경 (수정 전 커널 버전)
⚔️ 공격 벡터
로컬 권한을 가진 사용자가 ethtool로 RX/TX 링 크기를 반복 변경해 메모리 누수와 커널 경고를 유발하는 방식 (서비스 거부 가능성)
🛡️ 대응 방법
패치된 Linux 커널 버전으로 업데이트하여 i40e 드라이버의 DMA 매핑 누수 수정을 적용
🔧 검증 코드
커널 버전과 i40e 모듈 정보를 확인한 뒤, 배포판 보안 공지에서 해당 커널이 이 수정을 포함하는지 대조하며, 모듈 정보가 없으면 i40e 드라이버를 사용하지 않는 시스템입니다.
uname -r && modinfo i40e 2>/dev/null | grep -E '^(version|srcversion|filename)'