🇰🇷 한글 설명
Linux 커널의 SUNRPC 구성 요소에서 TLS 연결 작업 중 rpc_clnt 객체의 참조 횟수를 적절히 유지하지 않아 발생하는 Use-After-Free 취약점입니다. TLS 핸드셰이크 실패 시 클라이언트 객체가 먼저 해제된 후 지연된 작업 스레드가 해제된 메모리에 접근하여 참조 횟수 언더플로우를 유발할 수 있습니다.
💡 쉬운 설명
네트워크 연결을 설정하는 과정에서 데이터가 저장된 메모리 공간이 먼저 삭제되었음에도 불구하고, 시스템이 이를 계속 사용하려고 시도하여 발생하는 오류입니다. 이로 인해 시스템이 충돌하거나 보안상 위험한 상태가 될 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
SUNRPC: pin upper rpc_clnt across the TLS connect_worker
The TLS connect path has a use-after-free: nothing pins the
upper rpc_clnt across the delayed connect_worker. xs_connect()
stores task->tk_client in sock_xprt::clnt as a raw pointer
and queues the worker; for TLS-secured transports that worker
is xs_tcp_tls_setup_socket(), which reads several fields out
of the saved pointer (cl_timeout, cl_program, cl_prog,
cl_vers, cl_cred, cl_stats) to construct the args for the
inner handshake rpc_clnt.
The xprt does not reference the rpc_clnt; the rpc_clnt
references the xprt. xs_destroy() does cancel the
connect_worker, but it runs only when the xprt's refcount
drops to zero, which cannot happen until the rpc_clnt
releases its cl_xprt reference in rpc_free_client_work().
When a TLS handshake fails fatally (for example, an mTLS
mount whose client cert does not match the server), the
connecting task is woken with -EACCES and exits, the mount
caller invokes rpc_shutdown_client(), and the upper rpc_clnt
is freed before the queued connect_worker fires.
xs_tcp_tls_setup_socket() then dereferences the freed clnt,
producing the refcount_t underflow Michael Nemanov reported.
Take a reference on the upper rpc_clnt in xs_connect() for
TLS transports via a new rpc_hold_client() helper, and drop
it in the connect_worker's exit path with rpc_release_client().
The xprt_lock_connect() / xprt_unlock_connect() pairing
already serialises xs_connect() with xs_tcp_tls_setup_socket(),
so the take and release are balanced one-for-one.
The non-TLS connect worker (xs_tcp_setup_socket) never reads
sock_xprt::clnt, so leave that path alone and avoid the
clnt-holds-xprt-holds-clnt cycle that would otherwise prevent
xprt destruction.
📍 영향받는 시스템
Linux Kernel (SUNRPC 및 TLS 지원 구성)
⚔️ 공격 벡터
TLS 인증 실패(예: 잘못된 mTLS 인증서 사용)를 유도하여 메모리 해제 후 접근(Use-After-Free) 상황을 발생시킴
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트하여 rpc_hold_client() 및 rpc_release_client() 로직을 적용해야 함
🔧 검증 코드
출력된 커널 버전을 확인하여 해당 취약점이 해결된 패치 버전인지 확인하십시오.