🇰🇷 한글 설명
Linux 커널의 CAN bcm 드라이버에서 RCU grace period와 타이머 해제 간의 경쟁 상태로 인해 Use-After-Free(UAF) 취약점이 발생합니다. 타이머가 해제되기 전에 메모리가 먼저 해제되어, 이후 타이머가 실행될 때 이미 해제된 메모리 주소를 참조하게 됩니다.
💡 쉬운 설명
컴퓨터가 사용 중인 메모리를 너무 빨리 지워버려서, 나중에 그 메모리를 다시 쓰려고 할 때 오류가 발생하는 문제입니다. 이로 인해 시스템이 멈추거나 보안 공격에 악용될 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
can: bcm: defer rx_op deallocation to workqueue to fix thrtimer UAF
Commit f1b4e32aca08 ("can: bcm: use call_rcu() instead of costly
synchronize_rcu()") replaced synchronize_rcu() in bcm_delete_rx_op()
with call_rcu() and introduced the RX_NO_AUTOTIMER flag.
However, this flag check was omitted for thrtimer in the packet rx
fast-path. During BCM RX operation teardown, a concurrent RCU reader
(bcm_rx_handler) can race and re-arm thrtimer via
bcm_rx_update_and_send() after call_rcu() has been scheduled. Once
the RCU grace period elapses, bcm_op is freed. The subsequently
firing thrtimer then dereferences the deallocated op, causing a UAF.
Adding flag checks to the rx fast-path (bcm_rx_update_and_send) does not
fully close the TOCTOU race and introduces latency for every CAN frame.
Conversely, calling hrtimer_cancel() directly inside the RCU callback
(softirq context) is fatal as hrtimer_cancel() can sleep, triggering
a "scheduling while atomic" panic.
Resolve this by deferring the timer cancellation and memory free to a
dedicated unbound workqueue (bcm_wq). The RCU callback now queues a
work item to bcm_wq, which safely cancels both timers and deallocates
memory in sleepable process context. A dedicated workqueue is used to
prevent system-wide WQ saturation and is cleanly flushed/destroyed
on module unload to avoid rmmod page faults.
Since the deferred work can now outlive the calling context by an
unbounded amount, also take a reference on op->sk when it is assigned
and drop it only once the deferred work has cancelled both timers, so a
socket can no longer be freed out from under a still-armed timer whose
callback (bcm_send_to_user()) dereferences op->sk.
📍 영향받는 시스템
Linux kernel (CAN bcm driver module)
⚔️ 공격 벡터
특정 CAN 프레임 처리 과정에서 타이머와 메모리 해제 간의 타이밍 차이를 이용한 경쟁 상태 유도
🛡️ 대응 방법
커널 패치를 적용하여 타이머 취소 및 메모리 해제 작업을 전용 워크큐(bcm_wq)로 지연 처리하도록 업데이트
🔧 검증 코드
현재 실행 중인 커널 버전을 확인하여 해당 취약점이 해결된 패치 버전인지 확인합니다.