🇰🇷 한글 설명
Linux 커널의 perf 서브시스템에서 mmap() 재활성화와 munmap() 호출 간의 경쟁 상태로 인해 Use-After-Free 취약점이 발생합니다. 이로 인해 권한이 없는 로컬 사용자가 루트 권한을 획득할 수 있는 로컬 권한 상승(LPE) 공격이 가능합니다.
💡 쉬운 설명
컴퓨터의 성능을 측정하는 기능에서 메모리를 정리하는 과정과 다시 사용하는 과정이 동시에 일어나면서, 이미 삭제된 메모리 영역을 다시 사용하게 되는 오류입니다. 이를 이용해 해커가 일반 사용자에서 관리자 권한을 뺏을 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
perf: Fix use-after-free when perf mmap() revival races with the last munmap()
perf_mmap_close() drops rb->mmap_count *without* holding
event->mmap_mutex (the refcount_dec_and_test() right before the
refcount_dec_and_mutex_lock() of event->mmap_count). A concurrent
perf_mmap_rb() can slot its entire "revival" path into that window
(perf_mmap holds event->mmap_mutex for its whole duration, including
rb_alloc):
munmap side (perf_mmap_close) mmap side (perf_mmap_rb)
----------------------------------- --------------------------------
rb->mmap_count 1 -> 0 (no lock) (holds event->mmap_mutex)
inc_not_zero(rb->mmap_count) fails
ring_buffer_attach(event, NULL)
rb_alloc() + attach new rb
refcount_set(&event->mmap_count, 1)
lock; event->mmap_count 1 -> 0
ring_buffer_attach(event, NULL)
ring_buffer_put() -> frees the *new* rb
The revival's refcount_set(&event->mmap_count, 1) is an invisible
1 -> 1 write: the close frees the just-revived buffer although the
other process still has it mapped -- a page-level use-after-free
allowing local privilege escalation to root by any unprivileged user
(default kernel.perf_event_paranoid=2).
Swap the order of the two counter updates: event->mmap_count is
dropped first via refcount_dec_and_mutex_lock(), so its 1 -> 0
transition and the ring_buffer_attach() stay serialized with
perf_mmap(). rb->mmap_count == 0 then implies every event using the
buffer is detached already, so the result of the rb->mmap_count drop
can gate the remaining teardown directly and detach_rest is no longer
needed.
An earlier fix for this race from Kyle Zeng and David Lee takes
event->mmap_mutex around both counter updates [0]; here the not-last
close stays lockless.
📍 영향받는 시스템
Linux Kernel (perf 서브시스템 포함 버전)
⚔️ 공격 벡터
로컬 사용자가 특수하게 조작된 perf 이벤트 mmap/munmap 호출을 통해 메모리 경쟁 상태 유도
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 해결된 패치 버전 이후인지 확인