🇰🇷 한글 설명
Linux 커널의 ks8851 네트워크 드라이버에서 인터럽트 핸들러 실행 중 Bottom Halves(BH)가 비활성화되지 않아 발생하는 데드락 취약점입니다. 특정 조건에서 소프트인터럽트가 실행되면서 이미 점유된 스핀락을 다시 요청하게 되어 시스템이 멈출 수 있습니다.
💡 쉬운 설명
네트워크 장치를 처리하는 과정에서 컴퓨터가 서로의 작업이 끝나기를 기다리며 무한히 대기하는 상태에 빠지는 문제입니다. 이로 인해 시스템이 응답하지 않거나 멈추는 현상이 발생할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
net: ks8851: Reinstate disabling of BHs around IRQ handler
If the driver executes ks8851_irq() AND a TX packet has been sent, then
the driver enables TX queue via netif_wake_queue() which schedules TX
softirq to queue packets for this device.
If CONFIG_PREEMPT_RT=y is set AND a packet has also been received by
the MAC, then ks8851_rx_pkts() calls netdev_alloc_skb_ip_align() to
allocate SKBs for the received packets. If netdev_alloc_skb_ip_align()
is called with BH enabled, then local_bh_enable() at the end of
netdev_alloc_skb_ip_align() will trigger the pending softirq processing,
which may ultimately call the .xmit callback ks8851_start_xmit_par().
The ks8851_start_xmit_par() will try to lock struct ks8851_net_par
.lock spinlock, which is already locked by ks8851_irq() from which
ks8851_start_xmit_par() was called. This leads to a deadlock, which
is reported by the kernel, including a trace listed below.
If CONFIG_PREEMPT_RT is not set, then since commit 0913ec336a6c0
("net: ks8851: Fix deadlock with the SPI chip variant") the deadlock
can also be triggered without received packet in the RX FIFO. The
pending softirqs will be processed on return from
spin_unlock_bh(&ks->statelock) in ks8851_irq(), which triggers the
deadlock as well.
Fix the problem by disabling BH around critical sections, including the
IRQ handler, thus preventing the net_tx_action() softirq from triggering
during these critical sections. The net_tx_action() softirq is triggered
once BH are re-enabled and at the end of the IRQ handler, once all the
other IRQ handler actions have been completed.
__schedule from schedule_rtlock+0x1c/0x34
schedule_rtlock from rtlock_slowlock_locked+0x548/0x904
rtlock_slowlock_locked from rt_spin_lock+0x60/0x9c
rt_spin_lock from ks8851_start_xmit_par+0x74/0x1a8
ks8851_start_xmit_par from netdev_start_xmit+0x20/0x44
netdev_start_xmit from dev_hard_start_xmit+0xd0/0x188
dev_hard_start_xmit from sch_direct_xmit+0xb8/0x25c
sch_direct_xmit from __qdisc_run+0x1f8/0x4ec
__qdisc_run from qdisc_run+0x1c/0x28
qdisc_run from net_tx_action+0x1f0/0x268
net_tx_action from handle_softirqs+0x1a4/0x270
handle_softirqs from __local_bh_enable_ip+0xcc/0xe0
__local_bh_enable_ip from __alloc_skb+0xd8/0x128
__alloc_skb from __netdev_alloc_skb+0x3c/0x19c
__netdev_alloc_skb from ks8851_irq+0x388/0x4d4
ks8851_irq from irq_thread_fn+0x24/0x64
irq_thread_fn from irq_thread+0x178/0x28c
irq_thread from kthread+0x12c/0x138
kthread from ret_from_fork+0x14/0x28
📍 영향받는 시스템
ks8851 드라이버를 사용하는 Linux 커널 (특히 CONFIG_PREEMPT_RT 설정 시 위험)
⚔️ 공격 벡터
특정 네트워크 트래픽 패턴(TX/RX 동시 발생)을 유도하여 커널 데드락 유발
🛡️ 대응 방법
커널 패치를 적용하여 인터럽트 핸들러 주변의 임계 구역에서 Bottom Halves를 비활성화하도록 업데이트
🔧 검증 코드
현재 커널 버전과 ks8851 모듈의 정보를 확인하여 해당 드라이버 사용 여부를 파악합니다.
uname -r && modinfo ks8851 2>/dev/null