🇰🇷 한글 설명
Linux 커널의 RISC-V KVM 구현에서 PMU 이벤트 정보 배열 크기 계산 시 정수 오버플로가 발생합니다. 공격자가 제어 가능한 num_events 값이 32비트 정수 범위에서 잘리면서 실제 할당된 메모리보다 더 많은 데이터를 읽거나 쓰게 되어 메모리 손상이 발생합니다.
💡 쉬운 설명
컴퓨터가 메모리 공간을 준비할 때 계산 실수로 인해 실제 필요한 크기보다 훨씬 작은 공간만 만들게 되는 문제입니다. 이로 인해 준비된 공간을 넘어서는 데이터를 쓰게 되어 시스템이 고장 나거나 해킹될 위험이 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
RISC-V: KVM: Fix PMU event info array size overflow
SBI PMU EVENT_GET_INFO stores guest-controlled num_events * sizeof(*einfo)
in a 32-bit integer. On RV64, num_events = 0x10000001 makes 0x100000010
truncate to 16. KVM then allocates one entry but loops over the original
num_events, causing out-of-bounds reads and writes. A nested guest
triggered:
BUG: KASAN: slab-out-of-bounds in kvm_riscv_vcpu_pmu_event_info+0xa4/0x142
Read of size 4 at addr ff600000074d46b0 by task init/1
Call Trace:
[<ffffffff8006471c>] kvm_riscv_vcpu_pmu_event_info+0xa4/0x142
[<ffffffff800690c0>] kvm_sbi_ext_pmu_handler+0xca/0x268
[<ffffffff8006779e>] kvm_riscv_vcpu_sbi_ecall+0xec/0x1e6
[<ffffffff8006008c>] kvm_riscv_vcpu_exit+0x48c/0x540
[<ffffffff8005ea0a>] kvm_arch_vcpu_ioctl_run+0x37e/0xc80
Allocated by task 1:
__kmalloc_noprof+0x19e/0x4b0
kvm_riscv_vcpu_pmu_event_info+0x72/0x142
kvm_sbi_ext_pmu_handler+0xca/0x268
kvm_riscv_vcpu_sbi_ecall+0xec/0x1e6
kvm_riscv_vcpu_exit+0x48c/0x540
kvm_arch_vcpu_ioctl_run+0x37e/0xc80
The buggy address is located 0 bytes to the right of
allocated 16-byte region [ff600000074d46a0, ff600000074d46b0)
Store the shared-memory size in size_t and reject multiplication overflow.
Allocate the guest-driven array with GFP_KERNEL_ACCOUNT so it is charged
to kmemcg, and use __GFP_NOWARN to suppress allocation failure warnings.
Use kvcalloc() to allow vmalloc fallback and an unsigned long loop index
to match num_events.
📍 영향받는 시스템
RISC-V 아키텍처를 사용하는 Linux 커널 기반 KVM 환경
⚔️ 공격 벡터
중첩 게스트(Nested Guest) 환경에서 조작된 SBI PMU EVENT_GET_INFO 호출을 통한 공격
🛡️ 대응 방법
커널 패치를 통해 정수 오버플로 검증 로직을 추가하고, kvcalloc() 및 적절한 데이터 타입을 사용하여 메모리 할당 방식을 수정해야 합니다.
🔧 검증 코드
현재 커널 버전과 KVM 지원 여부를 확인하고, 배포판의 보안 공지를 통해 해당 CVE 패치가 적용된 커널 버전인지 대조하십시오.
uname -a && grep -i 'KVM' /boot/config-$(uname -r) 2>/dev/null