Skip to content

Commit 37b5440

Browse files
Ard Biesheuvelchazy
authored andcommitted
arm/arm64: KVM: fix potential NULL dereference in user_mem_abort()
Handle the potential NULL return value of find_vma_intersection() before dereferencing it. Acked-by: Marc Zyngier <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]> Signed-off-by: Christoffer Dall <[email protected]>
1 parent e9e8578 commit 37b5440

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

arch/arm/kvm/mmu.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,12 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
776776
/* Let's check if we will get back a huge page backed by hugetlbfs */
777777
down_read(&current->mm->mmap_sem);
778778
vma = find_vma_intersection(current->mm, hva, hva + 1);
779+
if (unlikely(!vma)) {
780+
kvm_err("Failed to find VMA for hva 0x%lx\n", hva);
781+
up_read(&current->mm->mmap_sem);
782+
return -EFAULT;
783+
}
784+
779785
if (is_vm_hugetlb_page(vma)) {
780786
hugetlb = true;
781787
gfn = (fault_ipa & PMD_MASK) >> PAGE_SHIFT;

0 commit comments

Comments
 (0)