🇰🇷 한글 설명
Linux 커널의 resctrl 파일 시스템에서 unmount 과정 중 mon_data 구조체가 해제된 후에도 접근이 가능한 Use-After-Free 취약점이 발견되었습니다. 기본 리소스 그룹에 RDT_DELETED 플래그가 설정되지 않아, 동시성 상황에서 읽기 작업이 이미 해제된 메모리 영역을 참조할 수 있습니다.
💡 쉬운 설명
컴퓨터 시스템이 특정 기능을 종료하는 도중에 다른 프로그램이 해당 기능을 사용하려고 시도하여 발생하는 오류입니다. 이 과정에서 이미 삭제된 메모리 주소를 다시 참조하게 되어 시스템이 충돌하거나 보안 문제가 생길 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
fs/resctrl: Fix use-after-free during unmount
During unmount or failure teardown all mon_data structures that contain
monitoring event file private data are freed after which kernfs nodes are
removed. However, the RDT_DELETED flag is never set for the statically
allocated default resource group.
A concurrent reader of an event file associated with the default resource
group may, after dropping kernfs active protection, block on rdtgroup_mutex
while unmount proceeds to free the file private data and destroy the kernfs
node without waiting for the reader.
When the mutex is released, the reader wakes up, observes that RDT_DELETED
is not set for the default group, and dereferences the already-freed
file private data.
The scenario can be depicted as follows:
CPU0 CPU1
/*
* Default resource group's
* monitoring data accessible via
* kernfs file with kernfs_node::priv
* pointing to a struct mon_data.
* User opens the file for reading.
*/
rdtgroup_mondata_show() /* arch encounters fatal error */
rdtgroup_kn_lock_live() resctrl_exit()
atomic_inc(&rdtgroup_default.waitcount) cpus_read_lock()
kernfs_break_active_protection(kn) mutex_lock(&rdtgroup_mutex)
cpus_read_lock() resctrl_fs_teardown()
mutex_lock(&rdtgroup_mutex) rmdir_all_sub()
mon_put_kn_priv()
/* Delete all mon_data structures */
rdtgroup_destroy_root()
kernfs_destroy_root()
rdtgroup_default.kn = NULL
mutex_unlock(&rdtgroup_mutex)
/*
* rdtgroup_default.flags is empty so
* rdtgroup_kn_lock_live() returns
* &rdtgroup_default
*/
md = of->kn->priv;
/* md points to freed mon_data */
Set RDT_DELETED for the default group unconditionally since the flag does
not lead to the freeing of this statically allocated group.
Do not allow a new resctrl mount if there are any waiters on default group
of previous mount. A new mount will re-initialize the default group that
would appear to waiters from previous mount as though the default group is
accessible causing them to access the mon_data structures from the previous
mount that have been removed.
📍 영향받는 시스템
Linux kernel (resctrl 파일 시스템을 사용하는 버전)
⚔️ 공격 벡터
resctrl 파일 시스템의 기본 리소스 그룹 이벤트 파일을 읽는 과정에서 발생하는 경합 조건(Race Condition)을 이용한 로컬 공격
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트하여 RDT_DELETED 플래그 설정 및 마운트 로직을 수정해야 합니다.
🔧 검증 코드
출력된 커널 버전이 취약점이 해결된 최신 패치 버전인지 확인합니다.