Skip to content

Commit def9238

Browse files
Sebastian Ottsmb49
authored andcommitted
KVM: arm64: Fix uninitialized memcache pointer in user_mem_abort()
BugLink: https://bugs.launchpad.net/bugs/2115252 commit 157dbc4 upstream. Commit fce886a ("KVM: arm64: Plumb the pKVM MMU in KVM") made the initialization of the local memcache variable in user_mem_abort() conditional, leaving a codepath where it is used uninitialized via kvm_pgtable_stage2_map(). This can fail on any path that requires a stage-2 allocation without transition via a permission fault or dirty logging. Fix this by making sure that memcache is always valid. Fixes: fce886a ("KVM: arm64: Plumb the pKVM MMU in KVM") Signed-off-by: Sebastian Ott <[email protected]> Reviewed-by: Marc Zyngier <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/kvmarm/[email protected]/ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> CVE-2025-37996 Signed-off-by: Manuel Diewald <[email protected]> Signed-off-by: Stefan Bader <[email protected]>
1 parent 061cb76 commit def9238

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

arch/arm64/kvm/mmu.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,6 +1489,11 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
14891489
return -EFAULT;
14901490
}
14911491

1492+
if (!is_protected_kvm_enabled())
1493+
memcache = &vcpu->arch.mmu_page_cache;
1494+
else
1495+
memcache = &vcpu->arch.pkvm_memcache;
1496+
14921497
/*
14931498
* Permission faults just need to update the existing leaf entry,
14941499
* and so normally don't require allocations from the memcache. The
@@ -1498,13 +1503,11 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
14981503
if (!fault_is_perm || (logging_active && write_fault)) {
14991504
int min_pages = kvm_mmu_cache_min_pages(vcpu->arch.hw_mmu);
15001505

1501-
if (!is_protected_kvm_enabled()) {
1502-
memcache = &vcpu->arch.mmu_page_cache;
1506+
if (!is_protected_kvm_enabled())
15031507
ret = kvm_mmu_topup_memory_cache(memcache, min_pages);
1504-
} else {
1505-
memcache = &vcpu->arch.pkvm_memcache;
1508+
else
15061509
ret = topup_hyp_memcache(memcache, min_pages);
1507-
}
1510+
15081511
if (ret)
15091512
return ret;
15101513
}

0 commit comments

Comments
 (0)