🇰🇷 한글 설명
리눅스 커널의 fs/proc 구성 요소에서 proc_readdir_de() 함수 호출 시 Use-After-Free(UAF) 취약점이 발생합니다. rbtree에서 노드를 삭제할 때 노드를 EMPTY 상태로 설정하지 않아, 삭제된 메모리 영역에 다시 접근하게 되어 시스템 불안정성이나 권한 상승을 초래할 수 있습니다.
💡 쉬운 설명
컴퓨터가 파일 목록을 읽는 도중에 특정 네트워크 장치가 갑자기 사라지면, 이미 삭제된 메모리 주소를 다시 참조하려고 시도하는 오류가 발생합니다. 이 과정에서 시스템이 충돌하거나 해커가 시스템 제어권을 얻을 위험이 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
fs/proc: fix uaf in proc_readdir_de()
Pde is erased from subdir rbtree through rb_erase(), but not set the node
to EMPTY, which may result in uaf access. We should use RB_CLEAR_NODE()
set the erased node to EMPTY, then pde_subdir_next() will return NULL to
avoid uaf access.
We found an uaf issue while using stress-ng testing, need to run testcase
getdent and tun in the same time. The steps of the issue is as follows:
1) use getdent to traverse dir /proc/pid/net/dev_snmp6/, and current
pde is tun3;
2) in the [time windows] unregister netdevice tun3 and tun2, and erase
them from rbtree. erase tun3 first, and then erase tun2. the
pde(tun2) will be released to slab;
3) continue to getdent process, then pde_subdir_next() will return
pde(tun2) which is released, it will case uaf access.
CPU 0 | CPU 1
-------------------------------------------------------------------------
traverse dir /proc/pid/net/dev_snmp6/ | unregister_netdevice(tun->dev) //tun3 tun2
sys_getdents64() |
iterate_dir() |
proc_readdir() |
proc_readdir_de() | snmp6_unregister_dev()
pde_get(de); | proc_remove()
read_unlock(&proc_subdir_lock); | remove_proc_subtree()
| write_lock(&proc_subdir_lock);
[time window] | rb_erase(&root->subdir_node, &parent->subdir);
| write_unlock(&proc_subdir_lock);
read_lock(&proc_subdir_lock); |
next = pde_subdir_next(de); |
pde_put(de); |
de = next; //UAF |
rbtree of dev_snmp6
|
pde(tun3)
/ \
NULL pde(tun2)
📍 영향받는 시스템
Linux Kernel (proc_readdir_de 관련 모듈을 사용하는 버전)
⚔️ 공격 벡터
특정 네트워크 장치(tun 등)를 등록/해제하는 과정과 /proc 디렉토리를 탐색하는 과정을 동시에 수행하여 메모리 오류 유도
🛡️ 대응 방법
RB_CLEAR_NODE()를 사용하여 삭제된 노드를 EMPTY로 설정하는 최신 리눅스 커널 패치 적용
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 수정된 최신 패치 버전인지 확인