🇰🇷 한글 설명
Linux 커널의 bpffs에서 inode 해제 시 RCU 지연 처리가 누락되어 발생하는 Use-After-Free(UAF) 취약점입니다. 특정 상황에서 inode가 즉시 해제됨으로써 RCU 경로 탐색 중인 다른 작업이 해제된 메모리에 접근하여 시스템 오류를 유발할 수 있습니다.
💡 쉬운 설명
컴퓨터가 파일을 정리하는 과정에서, 아직 사용 중인 파일을 너무 빨리 지워버려 발생하는 문제입니다. 이로 인해 시스템이 엉뚱한 메모리 주소를 읽으려다 멈추거나 보안 문제가 생길 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
bpf: fix UAF by restoring RCU-delayed inode freeing in bpffs
commit 4f375ade6aa9 ("bpf: Avoid RCU context warning when unpinning
htab with internal structs") moved inode cleanup from ->free_inode()
into ->destroy_inode() to avoid sleeping in RCU context when calling
bpf_any_put(). However this removed the RCU delay on freeing the
inode itself and the cached symlink body (i_link), both of which
can be accessed by RCU pathwalk (pick_link, may_lookup etc.).
This causes a use-after-free when a concurrent unlinkat() drops the
last inode reference and destroy_inode() frees the inode immediately,
while another task is still walking the path in RCU mode and reads
inode->i_opflags (offset +2) inside current_time() -> is_mgtime().
KASAN reports:
BUG: KASAN: slab-use-after-free in is_mgtime include/linux/fs.h:2313
Read of size 2 at addr ffff8880407e4282 (offset +2 = i_opflags)
The rules (per Al Viro):
->destroy_inode() called immediately, can sleep, use for blocking
cleanup e.g. bpf_any_put()
->free_inode() called after RCU grace period, use for freeing
inode and anything RCU-accessible e.g. i_link
Fix: split the two concerns properly:
- keep bpf_any_put() in bpf_destroy_inode() since it is blocking
and needs to run promptly
- introduce bpf_free_inode() to handle kfree(i_link) and
free_inode_nonrcu() with proper RCU delay, preventing the UAF
📍 영향받는 시스템
Linux kernel (BPF subsystem using bpffs)
⚔️ 공격 벡터
동시적인 unlinkat() 호출을 통해 inode 참조를 해제하고 RCU 경로 탐색을 유도하여 메모리 오류 유발
🛡️ 대응 방법
커널 패치(commit 4f375ade6aa9)를 적용하여 inode 해제 로직을 RCU 지연 방식(free_inode)으로 복구
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 수정된 패치 버전 이후인지 확인