🇰🇷 한글 설명
Linux 커널의 net/tls 구성 요소에서 tls_do_encryption 함수가 -EBUSY 오류를 처리할 때 발생하는 Use-After-Free 취약점입니다. 암호화 요청이 대기 중인 상태에서 오류 경로가 중복으로 자원을 정리하면서 데이터 구조가 손상되어, 이미 해제된 메모리에 접근할 수 있게 됩니다.
💡 쉬운 설명
컴퓨터가 암호화 작업을 하던 중 오류가 발생했을 때, 이미 정리한 데이터를 한 번 더 정리하려고 시도하면서 발생하는 문제입니다. 이 과정에서 시스템이 엉뚱한 메모리 주소를 참조하게 되어 보안 사고로 이어질 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
net/tls: fix use-after-free in -EBUSY error path of tls_do_encryption
The -EBUSY handling in tls_do_encryption(), introduced by commit
859054147318 ("net: tls: handle backlogging of crypto requests"), has
a use-after-free due to double cleanup of encrypt_pending and the
scatterlist entry.
When crypto_aead_encrypt() returns -EBUSY, the request is enqueued to
the cryptd backlog and the async callback tls_encrypt_done() will be
invoked upon completion. That callback unconditionally restores the
scatterlist entry (sge->offset, sge->length) and decrements
ctx->encrypt_pending. However, if tls_encrypt_async_wait() returns an
error, the synchronous error path in tls_do_encryption() performs the
same cleanup again, double-decrementing encrypt_pending and
double-restoring the scatterlist.
The double-decrement corrupts the encrypt_pending sentinel (initialized
to 1), making tls_encrypt_async_wait() permanently skip the wait for
pending async callbacks. A subsequent sendmsg can then free the
tls_rec via bpf_exec_tx_verdict() while a cryptd callback is still
pending, resulting in a use-after-free when the callback fires on the
freed record.
Fix this by skipping the synchronous cleanup when the -EBUSY async
wait returns an error, since the callback has already handled
encrypt_pending and sge restoration.
📍 영향받는 시스템
Linux Kernel (net/tls 모듈을 사용하는 시스템)
⚔️ 공격 벡터
특수하게 조작된 TLS 네트워크 패킷을 전송하여 암호화 엔진의 -EBUSY 오류 경로를 유도함
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트하여 tls_do_encryption의 중복 정리 로직을 수정함
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 수정된 패치 버전 이후인지 확인합니다.