🇰🇷 한글 설명
Linux 커널의 TIPC UDP 미디어 베어러 정리 과정에서 발생하는 Use-After-Free(UAF) 취약점입니다. dst_cache_destroy()가 RCU 동기화(synchronize_net) 이전에 호출되어, 다른 CPU에서 실행 중인 전송 프로세스가 이미 해제된 메모리에 접근함으로써 시스템 충돌이나 참조 횟수 불균형을 유발할 수 있습니다.
💡 쉬운 설명
데이터를 주고받는 통로를 닫는 과정에서, 아직 사용 중인 데이터를 먼저 삭제해버려 발생하는 오류입니다. 이로 인해 컴퓨터 시스템이 갑자기 멈추거나 예상치 못한 동작을 할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
tipc: fix UAF in cleanup_bearer() due to premature dst_cache_destroy()
TIPC UDP media bearer teardown calls dst_cache_destroy() on its
replicast caches before calling synchronize_net() to wait for
concurrent RCU readers (transmitters) to finish:
static void cleanup_bearer(struct work_struct *work)
{
...
list_for_each_entry_safe(rcast, tmp, &ub->rcast.list, list) {
dst_cache_destroy(&rcast->dst_cache);
list_del_rcu(&rcast->list);
kfree_rcu(rcast, rcu);
}
...
dst_cache_destroy(&ub->rcast.dst_cache);
udp_tunnel_sock_release(ub->sk);
synchronize_net();
...
}
This is highly buggy because dst_cache_destroy() immediately frees the
per-CPU cache memory (free_percpu()) and releases the cached dst
entries without any synchronization.
If a concurrent transmitter (e.g., tipc_udp_xmit()) is running on another
CPU under RCU protection, it can call dst_cache_get() concurrently,
leading to:
1. Use-After-Free on the per-CPU cache pointer itself (crash).
2. "rcuref - imbalanced put()" warning if it attempts to release a
dst that was concurrently released by dst_cache_destroy().
Furthermore, calling kfree(ub) immediately after synchronize_net() without
closing the socket first (or waiting after closing it) leaves a window
where a concurrent receiver (tipc_udp_recv()) could start after
synchronize_net(), access ub, and suffer a UAF when kfree(ub) runs.
To fix this, we must defer dst_cache_destroy() and kfree(ub) until after
we have ensured that no more readers can see the bearer/socket and all
existing readers have finished:
1. Defer rcast entry destruction (both dst_cache_destroy() and kfree())
to an RCU callback using call_rcu_hurry().
Using call_rcu_hurry() ensures the dst entries are released quickly.
2. Release the bearer socket using udp_tunnel_sock_release() (stops
new receive readers).
3. Call synchronize_net() to wait for all outstanding RCU readers
(both transmit and receive) to finish.
4. Now that it is safe, call dst_cache_destroy() on the main bearer
cache, and free ub.
Note: 3) and 4) can be changed later in net-next to also use
call_rcu_hurry() and get rid of the synchronize_net() latency.
📍 영향받는 시스템
TIPC(Transparent Inter-Process Communication) 모듈을 사용하는 Linux 커널 버전
⚔️ 공격 벡터
특정 네트워크 트래픽을 유도하여 커널 내의 RCU 읽기 프로세스와 베어러 정리 프로세스 간의 타이밍 충돌 유도
🛡️ 대응 방법
커널 패치를 통해 dst_cache_destroy()와 메모리 해제 시점을 RCU 동기화 이후로 지연시켜 수정
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 수정된 최신 보안 패치 버전인지 확인