🇰🇷 한글 설명
Linux 커널의 KVM 구성 요소에서 kvm_reset_dirty_gfn() 함수가 u64 오프셋의 정수 오버플로우를 적절히 검사하지 않아 발생하는 취약점입니다. 공격자가 조작된 엔트리를 통해 경계 검사를 우회하면, 커널 메모리의 범위를 벗어난 영역에 접근하여 잘못된 메모리 로드 및 쓰기 권한 조작이 가능해집니다.
💡 쉬운 설명
가상 머신을 관리하는 리눅스 커널의 계산 오류를 이용해, 허용되지 않은 메모리 영역을 건드릴 수 있는 보안 약점입니다. 이를 통해 공격자는 시스템의 중요한 정보를 읽거나 메모리 설정을 임의로 바꿀 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
KVM: Reject wrapped offset in kvm_reset_dirty_gfn()
kvm_reset_dirty_gfn() guards the gfn range with
if (!memslot || (offset + __fls(mask)) >= memslot->npages)
return;
but offset is u64 and the addition is unchecked. The check can be
silently bypassed by a u64 wrap.
The dirty ring backing those entries is MAP_SHARED at
KVM_DIRTY_LOG_PAGE_OFFSET of the vcpu fd, so the VMM can rewrite the
slot and offset fields of any entry between when the kernel pushes
them and when KVM_RESET_DIRTY_RINGS consumes them. On reset,
kvm_dirty_ring_reset() re-reads the values via READ_ONCE() and feeds
them straight back into this check; only the flags handshake is
treated as the handover, the slot/offset payload is taken on trust.
Crafting two entries
entry[i].offset = 0xffffffffffffffc1
entry[i+1].offset = 0
makes the coalescing loop in kvm_dirty_ring_reset() compute
delta = (s64)(0 - 0xffffffffffffffc1) = 63
which falls in [0, BITS_PER_LONG), so it folds entry[i+1] into the
existing mask by setting bit 63. The trailing kvm_reset_dirty_gfn()
call then sees offset = 0xffffffffffffffc1 and __fls(mask) = 63;
the sum is 0 in u64 and the bounds check passes.
That offset propagates into kvm_arch_mmu_enable_log_dirty_pt_masked()
unchanged. On the legacy MMU path -- kvm_memslots_have_rmaps() ==
true, i.e. shadow paging, any VM that has allocated shadow roots, or
a write-tracked slot -- it reaches gfn_to_rmap(), which indexes
slot->arch.rmap[0][] with a near-U64_MAX gfn. That is an
out-of-bounds load of a kvm_rmap_head, followed by a conditional
clear of PT_WRITABLE_MASK in whatever the loaded pointer points at.
The path is reachable from any process holding /dev/kvm.
Range-check offset on its own first, so the addition cannot wrap.
memslot->npages is bounded well below U64_MAX, so once offset <
npages holds, offset + __fls(mask) (with __fls(mask) < BITS_PER_LONG)
stays in range.
📍 영향받는 시스템
Linux Kernel (KVM 모듈을 사용하는 시스템)
⚔️ 공격 벡터
/dev/kvm 장치에 접근 권한이 있는 프로세스를 통한 조작된 dirty ring 엔트리 주입
🛡️ 대응 방법
kvm_reset_dirty_gfn() 함수 내에서 오프셋 합산 전 개별 범위를 검사하도록 커널 패치 적용
🔧 검증 코드
출력된 커널 버전을 확인하여 해당 취약점이 해결된 최신 보안 패치 버전인지 확인합니다.