🇰🇷 한글 설명
리눅스 커널의 TCP 소켓 처리 과정에서 네트워크 네임스페이스(netns)가 해제된 후에도 타이머가 종료되지 않고 실행될 수 있는 취약점입니다. 커널 소켓은 네트워크 네임스페이스에 대한 참조를 유지하지 않기 때문에, 타이머가 완료되기 전에 네임스페이스가 먼저 해제되어 시스템 불안정이나 오류를 유발할 수 있습니다.
💡 쉬운 설명
네트워크 연결을 관리하는 타이머가 실제 연결이 끊긴 후에도 뒤늦게 작동하여 시스템에 혼란을 줄 수 있는 문제입니다. 특히 커널 내부에서 사용하는 연결의 경우, 관리 공간이 사라진 뒤에도 타이머가 작동하려다 오류가 발생할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
tcp: properly terminate timers for kernel sockets
We had various syzbot reports about tcp timers firing after
the corresponding netns has been dismantled.
Fortunately Josef Bacik could trigger the issue more often,
and could test a patch I wrote two years ago.
When TCP sockets are closed, we call inet_csk_clear_xmit_timers()
to 'stop' the timers.
inet_csk_clear_xmit_timers() can be called from any context,
including when socket lock is held.
This is the reason it uses sk_stop_timer(), aka del_timer().
This means that ongoing timers might finish much later.
For user sockets, this is fine because each running timer
holds a reference on the socket, and the user socket holds
a reference on the netns.
For kernel sockets, we risk that the netns is freed before
timer can complete, because kernel sockets do not hold
reference on the netns.
This patch adds inet_csk_clear_xmit_timers_sync() function
that using sk_stop_timer_sync() to make sure all timers
are terminated before the kernel socket is released.
Modules using kernel sockets close them in their netns exit()
handler.
Also add sock_not_owned_by_me() helper to get LOCKDEP
support : inet_csk_clear_xmit_timers_sync() must not be called
while socket lock is held.
It is very possible we can revert in the future commit
3a58f13a881e ("net: rds: acquire refcount on TCP sockets")
which attempted to solve the issue in rds only.
(net/smc/af_smc.c and net/mptcp/subflow.c have similar code)
We probably can remove the check_net() tests from
tcp_out_of_resources() and __tcp_close() in the future.
📍 영향받는 시스템
Linux Kernel (TCP stack 관련 모듈 사용 시스템)
⚔️ 공격 벡터
로컬 공격자가 특정 네트워크 네임스페이스를 빈번하게 생성 및 삭제하여 커널 타이머와 네임스페이스 간의 경합 상태(Race Condition)를 유도
🛡️ 대응 방법
커널 타이머를 동기적으로 종료하는 inet_csk_clear_xmit_timers_sync() 기능이 포함된 최신 리눅스 커널로 업데이트
🔧 검증 코드
출력된 커널 버전이 해당 패치가 적용된 최신 보안 업데이트 버전인지 확인