🇰🇷 한글 설명
Linux 커널의 KVM x86/MMU 구성 요소에서 벤더 모듈 재로드 시 Use-After-Free 취약점이 발생합니다. 모듈 언로드 시 캐시 포인터가 초기화되지 않아, 이후 모듈 재로드 중 오류가 발생하면 이미 해제된 메모리 주소에 접근하여 시스템 불안정성을 초래할 수 있습니다.
💡 쉬운 설명
컴퓨터의 가상화 기능을 담당하는 부품을 껐다 켤 때, 이미 삭제된 메모리 주소를 다시 사용하려고 시도하여 발생하는 오류입니다. 이로 인해 시스템이 멈추거나 예상치 못한 동작을 할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
KVM: x86/mmu: Fix use-after-free on vendor module reload
mmu_destroy_caches() destroys pte_list_desc_cache and
mmu_page_header_cache, but leaves both pointers unchanged. The pointers
live in kvm.ko, and therefore survive when a vendor module is unloaded
while kvm.ko remains loaded.
If creation of pte_list_desc_cache fails during a subsequent vendor
module load, its assignment sets pte_list_desc_cache to NULL and the
error path calls mmu_destroy_caches(). mmu_page_header_cache still
points to the cache destroyed during the preceding vendor module
unload. Passing that stale pointer to kmem_cache_destroy() causes a
slab use-after-free.
Reproduce the issue on a v7.1.3 kernel with CONFIG_KASAN=y,
CONFIG_KASAN_GENERIC=y, CONFIG_KVM=m, and CONFIG_KVM_INTEL=m. A
one-shot test hook forces pte_list_desc_cache to NULL on the second
invocation of kvm_mmu_vendor_module_init():
1. Load kvm.ko and kvm-intel.ko, creating both caches.
2. Unload only kvm_intel, leaving kvm.ko loaded.
3. Reload kvm_intel and force initialization through the -ENOMEM path.
KASAN reports:
BUG: KASAN: slab-use-after-free in
kvm_mmu_vendor_module_init+0x5b/0x170 [kvm]
...
kmem_cache_destroy+0x21/0x1d0
kvm_mmu_vendor_module_init+0x5b/0x170 [kvm]
...
Allocated by task 16817:
__kmem_cache_create_args+0x12c/0x3b0
__kmem_cache_create.constprop.0+0xb6/0xf0 [kvm]
kvm_mmu_vendor_module_init+0x13b/0x170 [kvm]
...
Freed by task 16820:
kmem_cache_destroy+0x117/0x1d0
kvm_mmu_vendor_module_exit+0x21/0x30 [kvm]
Clear both pointers immediately after destroying their caches so that
the stored state reflects the caches' lifetime and repeated cleanup is
safe.
With the fix applied, the same injected vendor module reload fails with
-ENOMEM as expected and produces no KASAN report.
📍 영향받는 시스템
Linux kernel v7.1.3 (CONFIG_KVM=m, CONFIG_KVM_INTEL=m 설정 시 영향 가능)
⚔️ 공격 벡터
로컬 공격자가 특정 벤더 모듈(예: kvm-intel)을 의도적으로 언로드한 후 다시 로드하는 과정을 통해 메모리 오류를 유도할 수 있음
🛡️ 대응 방법
커널 패치를 적용하여 캐시 파괴 후 관련 포인터를 즉시 NULL로 초기화해야 함
🔧 검증 코드
출력된 커널 버전이 취약점이 해결된 패치 버전인지 확인하십시오.