[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <86ikmegmw9.wl-maz@kernel.org>
Date: Tue, 06 May 2025 09:32:22 +0100
From: Marc Zyngier <maz@...nel.org>
To: Mostafa Saleh <smostafa@...gle.com>
Cc: linux-kernel@...r.kernel.org,
kvmarm@...ts.linux.dev,
linux-arm-kernel@...ts.infradead.org,
oliver.upton@...ux.dev,
joey.gouly@....com,
suzuki.poulose@....com,
yuzenghui@...wei.com,
catalin.marinas@....com,
will@...nel.org,
qperret@...gle.com
Subject: Re: [PATCH] KVM: arm64: Fix memory check in host_stage2_set_owner_locked()
On Thu, 01 May 2025 17:24:50 +0100,
Mostafa Saleh <smostafa@...gle.com> wrote:
>
> 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@...gle.com>
> ---
> arch/arm64/kvm/hyp/nvhe/mem_protect.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c b/arch/arm64/kvm/hyp/nvhe/mem_protect.c
> index 2a5284f749b4..e80f3ebd3e2a 100644
> --- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c
> +++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c
> @@ -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,
I vaguely seem to remember that there was an assumption around
addr/size representing a single page, and therefore addr_is_memory()
was doing the right thing.
Has this assumption changed? Or is this only a figment of my imagination?
Thanks,
M.
--
Without deviation from the norm, progress is not possible.
Powered by blists - more mailing lists