🇰🇷 한글 설명
Linux 커널의 L2TP 프로토콜 구현 중 l2tp_session_get_by_ifname 함수에서 참조 횟수(refcount)를 부적절하게 처리하는 취약점이 발견되었습니다. 이로 인해 참조 횟수가 0이 된 세션에 대해 잘못된 참조 증가가 발생할 수 있으며, 이는 메모리 해제 후 재사용되는 Use-After-Free(UAF) 취약점으로 이어질 수 있습니다.
💡 쉬운 설명
컴퓨터가 사용 중인 데이터의 사용 횟수를 잘못 계산하여, 이미 삭제된 데이터를 다시 사용하려고 시도할 때 발생하는 오류입니다. 이 오류를 이용하면 시스템이 멈추거나 해커가 시스템 권한을 탈취할 위험이 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
l2tp: use refcount_inc_not_zero in l2tp_session_get_by_ifname
A reader in l2tp_session_get_by_ifname() can return a pointer to a
session whose refcount has reached zero. The getter takes its
reference with plain refcount_inc(), but every other session getter
in the same file (l2tp_v2_session_get, l2tp_v3_session_get, and the
corresponding _get_next variants) uses refcount_inc_not_zero()
because the IDR/RCU lookup can race with refcount_dec_and_test() ->
l2tp_session_free() -> kfree_rcu(). The ifname getter is the only
outlier; the inconsistency was raised on-list after 979c017803c4
("l2tp: use list_del_rcu in l2tp_session_unhash").
A reader inside rcu_read_lock_bh() that matches session->ifname can
be preempted between the strcmp() and the refcount_inc(). If the
last reference drops on another CPU in that window, the reader's
refcount_inc() runs on a counter that has reached zero. refcount_t
catches the addition-on-zero, prints "refcount_t: addition on 0;
use-after-free", saturates the counter, and returns the saturated
pointer to the caller. Session memory is held live by the in-flight
RCU read section, but the kfree_rcu() callback queued from
l2tp_session_free() will free it once the grace period closes; a
caller that dereferences the returned session past that point hits
a slab-use-after-free. On PREEMPT_RT local_bh_disable() is a per-CPU
sleeping lock and the preemption window is real; on stock PREEMPT
kernels local_bh_disable() is a preempt_count increment that closes
the cross-CPU race in practice (see below).
Use refcount_inc_not_zero() and continue the list walk on failure,
matching the other session getters in the file. The ifname getter
is the only session getter in net/l2tp/ that still uses the bare
refcount_inc() pattern; this change restores file-internal
consistency. The success path is unchanged.
📍 영향받는 시스템
L2TP 기능을 사용하는 Linux 커널 버전 (패치 적용 전 버전)
⚔️ 공격 벡터
특정 네트워크 인터페이스 이름을 이용한 L2TP 세션 조회 과정에서 발생하는 레이스 컨디션(Race Condition) 유도
🛡️ 대응 방법
refcount_inc_not_zero()를 사용하는 최신 Linux 커널로 업데이트하여 참조 횟수 관리 로직을 수정해야 합니다.
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 해결된 최신 보안 패치 버전인지 확인합니다.