Skip to content

Commit 219072c

Browse files
Ryan RobertsMarc Zyngier
authored andcommitted
KVM: arm64: Fix benign bug with incorrect use of VA_BITS
get_user_mapping_size() uses kvm's pgtable library to walk a user space page table created by the kernel, and in doing so, passes metadata that the library needs, including ia_bits, which defines the size of the input address. For the case where the kernel is compiled for 52 VA bits but runs on HW that does not support LVA, it will fall back to 48 VA bits at runtime. Therefore we must use vabits_actual rather than VA_BITS to get the true address size. This is benign in the current code base because the pgtable library only uses it for error checking. Fixes: 6011cf6 ("KVM: arm64: Walk userspace page tables to compute the THP mapping size") Signed-off-by: Ryan Roberts <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent a0d3778 commit 219072c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/arm64/kvm/mmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ static int get_user_mapping_size(struct kvm *kvm, u64 addr)
641641
{
642642
struct kvm_pgtable pgt = {
643643
.pgd = (kvm_pte_t *)kvm->mm->pgd,
644-
.ia_bits = VA_BITS,
644+
.ia_bits = vabits_actual,
645645
.start_level = (KVM_PGTABLE_MAX_LEVELS -
646646
CONFIG_PGTABLE_LEVELS),
647647
.mm_ops = &kvm_user_mm_ops,

0 commit comments

Comments
 (0)