🇰🇷 한글 설명
Linux 커널의 netfilter cttimeout 모듈에서 모듈 언로드 시 Use-After-Free(UAF) 취약점이 발견되었습니다. cttimeout_exit() 함수가 훅을 해제하기 전에 per-net 작업을 먼저 해제하여, 다른 CPU에서 이미 해제된 메모리 영역에 접근할 수 있는 레이스 컨디션이 발생합니다.
💡 쉬운 설명
컴퓨터의 핵심 기능인 커널에서 특정 모듈을 끌 때, 메모리를 먼저 지워버리고 나중에 사용하려는 문제가 있습니다. 이로 인해 시스템이 충돌하거나 해커가 메모리에 잘못된 접근을 할 수 있는 위험이 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
netfilter: cttimeout: prevent UAF during module unload
nf_ct_set_timeout() protects the timeout hook dereference and policy lookup
with rcu_read_lock(). cttimeout_exit(), however, unregisters the per-net
operations before it clears the hook.
This allows the following interleaving:
CPU 0 CPU 1
cttimeout_exit() nf_ct_set_timeout()
unregister_pernet_subsys() rcu_read_lock()
kfree(pernet) h = nf_ct_timeout_hook
h->timeout_find_get()
nfct_timeout_pernet()
The hook still points to ctnl_timeout_find_get() when CPU 1 looks up the
already freed per-net timeout list. KASAN reported:
BUG: KASAN: slab-use-after-free in ctnl_timeout_find_get
Read of size 8 by task poc/90
Call Trace:
ctnl_timeout_find_get+0x271/0x2a0 [nfnetlink_cttimeout]
nf_ct_set_timeout+0x7b/0x3c0
xt_ct_tg_check+0x724/0xb20
xt_check_target+0x234/0xa90
do_ipt_set_ctl+0x570/0x1270
Allocated by task 89:
__kmalloc_noprof+0x16e/0x460
ops_init+0x6d/0x420
register_pernet_operations+0x2f6/0x670
Freed by task 91:
kfree+0x131/0x390
ops_undo_list+0x3d4/0x730
unregister_pernet_operations+0x232/0x490
unregister_pernet_subsys+0x1c/0x30
cttimeout_exit+0x52/0x970 [nfnetlink_cttimeout]
Clear the hook and wait for existing readers before unregistering the
per-net operations. This blocks new policy lookups and ensures readers that
observed the hook finish before the per-net storage is freed.
📍 영향받는 시스템
Linux kernel (netfilter cttimeout 모듈 사용 환경)
⚔️ 공격 벡터
모듈 언로드와 동시에 특정 네트워크 함수를 호출하는 레이스 컨디션 유도
🛡️ 대응 방법
커널 패치를 적용하여 훅을 먼저 해제하고 RCU를 통해 기존 읽기 작업이 완료된 후 메모리를 해제하도록 업데이트
🔧 검증 코드
출력된 커널 버전이 취약점이 해결된 최신 패치 버전인지 확인