🇰🇷 한글 설명
Linux 커널의 BPF 및 skmsg 구성 요소에서 ktls RX 처리 중 발생하는 레이스 컨디션 취약점입니다. TLS RX 컨텍스트가 있는 상태에서 sk_psock_verdict_data_ready가 적절한 보호 없이 호출되어 수신 큐를 비우게 되며, 이로 인해 Use-After-Free(UAF) 취약점이 발생합니다.
💡 쉬운 설명
네트워크 데이터를 암호화 해제하는 과정에서 데이터 처리 순서가 꼬여 이미 사용된 메모리에 접근하는 보안 결함입니다. 공격자가 이를 악용하면 시스템 권한을 탈취하거나 프로그램을 강제로 종료시킬 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
bpf, skmsg: fix verdict sk_data_ready racing with ktls rx
sk_psock_strp_data_ready() already checks tls_sw_has_ctx_rx() and
defers to psock->saved_data_ready when a TLS RX context is present,
avoiding a conflict with the TLS strparser's ownership of the receive
queue (commit e91de6afa81c, "bpf: Fix running sk_skb program types
with ktls").
sk_psock_verdict_data_ready() has no equivalent guard. When a socket
is inserted into a sockmap (BPF_SK_SKB_VERDICT) before TLS RX is
configured, tls_sw_strparser_arm() saves sk_psock_verdict_data_ready
as rx_ctx->saved_data_ready. On data arrival:
tls_data_ready -> tls_strp_data_ready -> tls_rx_msg_ready
-> saved_data_ready() = sk_psock_verdict_data_ready()
-> tcp_read_skb() drains sk_receive_queue via __skb_unlink()
without calling tcp_eat_skb(), so copied_seq is not advanced.
tls_strp_msg_load() then finds tcp_inq() >= full_len (stale), calls
tcp_recv_skb() on the now-empty queue, hits WARN_ON_ONCE(!first), and
returns with rx_ctx->strp.anchor.frag_list pointing at a psock-owned
(potentially freed) skb. tls_decrypt_sg() subsequently walks that
frag_list: use-after-free.
Apply the same fix as sk_psock_strp_data_ready(): if a TLS RX context
is present, call psock->saved_data_ready (sock_def_readable) to wake
recv() waiters and return immediately, leaving the receive queue
untouched. TLS retains sole ownership of the queue and decrypts the
record normally through tls_sw_recvmsg().
📍 영향받는 시스템
Linux Kernel (BPF, skmsg, ktls 관련 모듈 사용 환경)
⚔️ 공격 벡터
특수하게 조작된 네트워크 패킷을 전송하여 TLS 수신 과정 중 메모리 레이스 컨디션을 유발
🛡️ 대응 방법
커널 패치를 적용하여 sk_psock_verdict_data_ready에 TLS RX 컨텍스트 존재 여부를 확인하는 가드 로직을 추가
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 수정된 패치 버전 이후인지 확인