]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: arm64: Fix memory check in host_stage2_set_owner_locked()
authorMostafa Saleh <smostafa@google.com>
Thu, 1 May 2025 16:24:50 +0000 (16:24 +0000)
committerOliver Upton <oliver.upton@linux.dev>
Wed, 7 May 2025 07:17:05 +0000 (00:17 -0700)
I found this simple bug while preparing some patches for pKVM.
AFAICT, it should be harmless (besides crashing the kernel if it
was misbehaving)

Fixes: e94a7dea2972 ("KVM: arm64: Move host page ownership tracking to the hyp vmemmap")
Signed-off-by: Mostafa Saleh <smostafa@google.com>
Link: https://lore.kernel.org/r/20250501162450.2784043-1-smostafa@google.com
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
arch/arm64/kvm/hyp/nvhe/mem_protect.c

index 2a5284f749b427927791f0706f66542e90611df9..e80f3ebd3e2a262210614a84d7610c7e49282358 100644 (file)
@@ -503,7 +503,7 @@ int host_stage2_set_owner_locked(phys_addr_t addr, u64 size, u8 owner_id)
 {
        int ret;
 
-       if (!addr_is_memory(addr))
+       if (!range_is_memory(addr, addr + size))
                return -EPERM;
 
        ret = host_stage2_try(kvm_pgtable_stage2_set_owner, &host_mmu.pgt,