🇰🇷 한글 설명
Linux 커널 TLS 초기화 함수에서 메모리 배리어가 누락되어 발생하는 취약점입니다. 멀티코어 CPU 환경에서 메모리 쓰기 명령어 재정렬로 인해 NULL 포인터 역참조가 발생할 수 있습니다.
💡 쉬운 설명
Linux 커널의 보안 통신(TLS) 설정 중에 메모리 접근 순서가 뒤바뀌어 프로그램이 잘못된 주소에 접근하는 문제입니다. 멀티코어 프로세서에서 동시에 실행될 때 충돌이 발생할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
tls: fix missing memory barrier in tls_init
In tls_init(), a write memory barrier is missing, and store-store
reordering may cause NULL dereference in tls_{setsockopt,getsockopt}.
CPU0 CPU1
----- -----
// In tls_init()
// In tls_ctx_create()
ctx = kzalloc()
ctx->sk_proto = READ_ONCE(sk->sk_prot) -(1)
// In update_sk_prot()
WRITE_ONCE(sk->sk_prot, tls_prots) -(2)
// In sock_common_setsockopt()
READ_ONCE(sk->sk_prot)->setsockopt()
// In tls_{setsockopt,getsockopt}()
ctx->sk_proto->setsockopt() -(3)
In the above scenario, when (1) and (2) are reordered, (3) can observe
the NULL value of ctx->sk_proto, causing NULL dereference.
To fix it, we rely on rcu_assign_pointer() which implies the release
barrier semantic. By moving rcu_assign_pointer() after ctx->sk_proto is
initialized, we can ensure that ctx->sk_proto are visible when
changing sk->sk_prot.
📍 영향받는 시스템
Linux 커널 6.7 이전 버전 (rcu_assign_pointer 패치 미적용 버전)
⚔️ 공격 벡터
로컬 공격자가 TLS 소켓 옵션 설정(setsockopt/getsockopt) 호출 시 NULL 포인터 역참조 유도
🛡️ 대응 방법
Linux 커널을 최신 버전으로 업데이트하거나 해당 패치(rcu_assign_pointer 위치 변경)를 적용
🔧 검증 코드
현재 커널 버전이 6.7 이전이면 Vulnerable 출력, 이후 버전이면 Check kernel version 출력 (정확한 패치 여부는 distro 커널 브랜치 확인 필요)
uname -r | grep -qE '^[0-9]\.([0-6]\.[0-9]+|7\.[0-9]+-[0-9]+)' && echo 'Vulnerable' || echo 'Check kernel version'