🇰🇷 한글 설명
Linux 커널의 KVM arm64 환경에서 중첩된(nested) 가상화의 페이지 테이블 해제 과정 중 레이스 컨디션이 발생합니다. 이로 인해 특정 상황에서 NULL 포인터 역참조가 발생하여 시스템 충돌이나 커널 패닉을 유발할 수 있습니다.
💡 쉬운 설명
가상 컴퓨터를 여러 겹으로 실행할 때, 메모리를 정리하는 과정에서 두 작업이 서로 충돌하여 시스템이 멈출 수 있는 문제입니다. 메모리 주소가 비어있는 상태에서 접근을 시도하기 때문에 발생합니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
KVM: arm64: nv: Fix null ptr deref on nested wp/unmap, teardown race
Commit 7270cc9157f4 ("KVM: arm64: nv: Handle VNCR_EL2 invalidation from MMU
notifiers") introduced VNCR_EL2 invalidation in both kvm_nested_s2_unmap()
and kvm_nested_s2_wp().
However at the point of this being performed concurrent stage 2 teardown of
a nested guest can cause kvm->arch.mmu.pgt to be set to NULL.
This happens in kvm_flush_shadow_all() -> kvm_arch_flush_shadow_all() ->
kvm_free_stage2_pgd() and is performed under the kvm->mmu_lock.
Commit ec14c272408a ("KVM: arm64: nv: Unmap/flush shadow stage 2 page
tables") introduced the teardown of the entire nested MMU range, which then
invokes stage2_apply_range() with resched=true:
mmu_notifier_invalidate_range_start()
-> ... -> kvm_mmu_notifier_invalidate_range_start()
-> kvm_mmu_unmap_gfn_range()
-> kvm_unmap_gfn_range()
-> kvm_nested_s2_unmap()
-> kvm_stage2_unmap_range()
-> __unmap_stage2_range()
-> stage2_apply_range()
This means that stage2_apply_range() can drop the kvm->mmu_lock and thus
concurrent progress can be made in lockstep with
kvm_arch_flush_shadow_all().
If kvm_arch_flush_shadow_all() advances ahead of stage2_apply_range() and
completes its operation it guarantees a NULL pointer deref.
Since kvm_free_stage2_pgd() is performed under the kvm->mmu_lock this will
either be observed NULL or not and serialised against
kvm_free_stage2_pgd().
Resolve the issue by abstracting the invalidation to a new function,
kvm_invalidate_vncr_ipa_all(), and check that the pgt is non-NULL before
dereferencing it.
📍 영향받는 시스템
Linux Kernel (KVM arm64 architecture)
⚔️ 공격 벡터
중첩 가상화 환경에서 특정 메모리 해제 및 페이지 테이블 정리 작업을 동시에 수행하여 레이스 컨디션 유도
🛡️ 대응 방법
커널 패치(Commit 7270cc9157f4 관련 수정 사항)를 적용하여 페이지 테이블 접근 전 NULL 여부를 확인하도록 업데이트
🔧 검증 코드
현재 실행 중인 커널 버전을 확인하여 해당 취약점이 해결된 패치 버전이 적용되었는지 확인합니다.