🇰🇷 한글 설명
Linux 커널의 af_unix 구성 요소에서 가비지 컬렉터(GC)와 connect() 함수 간의 레이스 컨디션 취약점이 발견되었습니다. 가비지 컬렉션 과정에서 SCM_RIGHTS를 포함한 소켓(embryo)이 큐에 추가될 때 inflight 카운트가 잘못 계산되어 gc_inflight_list 내에 댕글링 포인터가 발생할 수 있습니다.
💡 쉬운 설명
리눅스 시스템 내부에서 통신 통로를 정리하는 과정과 새로운 연결을 만드는 과정이 동시에 일어날 때 충돌이 발생합니다. 이로 인해 시스템이 잘못된 메모리 주소를 참조하게 되어 보안 문제가 생길 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
af_unix: Fix garbage collector racing against connect()
Garbage collector does not take into account the risk of embryo getting
enqueued during the garbage collection. If such embryo has a peer that
carries SCM_RIGHTS, two consecutive passes of scan_children() may see a
different set of children. Leading to an incorrectly elevated inflight
count, and then a dangling pointer within the gc_inflight_list.
sockets are AF_UNIX/SOCK_STREAM
S is an unconnected socket
L is a listening in-flight socket bound to addr, not in fdtable
V's fd will be passed via sendmsg(), gets inflight count bumped
connect(S, addr) sendmsg(S, [V]); close(V) __unix_gc()
---------------- ------------------------- -----------
NS = unix_create1()
skb1 = sock_wmalloc(NS)
L = unix_find_other(addr)
unix_state_lock(L)
unix_peer(S) = NS
// V count=1 inflight=0
NS = unix_peer(S)
skb2 = sock_alloc()
skb_queue_tail(NS, skb2[V])
// V became in-flight
// V count=2 inflight=1
close(V)
// V count=1 inflight=1
// GC candidate condition met
for u in gc_inflight_list:
if (total_refs == inflight_refs)
add u to gc_candidates
// gc_candidates={L, V}
for u in gc_candidates:
scan_children(u, dec_inflight)
// embryo (skb1) was not
// reachable from L yet, so V's
// inflight remains unchanged
__skb_queue_tail(L, skb1)
unix_state_unlock(L)
for u in gc_candidates:
if (u.inflight)
scan_children(u, inc_inflight_move_tail)
// V count=1 inflight=2 (!)
If there is a GC-candidate listening socket, lock/unlock its state. This
makes GC wait until the end of any ongoing connect() to that socket. After
flipping the lock, a possibly SCM-laden embryo is already enqueued. And if
there is another embryo coming, it can not possibly carry SCM_RIGHTS. At
this point, unix_inflight() can not happen because unix_gc_lock is already
taken. Inflight graph remains unaffected.
📍 영향받는 시스템
Linux Kernel (af_unix 관련 모듈을 사용하는 모든 버전)
⚔️ 공격 벡터
로컬 사용자가 AF_UNIX/SOCK_STREAM 소켓을 사용하여 특정 타이밍에 connect()와 sendmsg()를 정밀하게 조작하여 발생
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트하십시오.
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 수정된 패치 버전 이후인지 확인하십시오.