All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Mostafa Saleh <smostafa@google.com>
Cc: linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org, oliver.upton@linux.dev,
	joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com,
	catalin.marinas@arm.com, will@kernel.org, qperret@google.com
Subject: Re: [PATCH] KVM: arm64: Fix memory check in host_stage2_set_owner_locked()
Date: Tue, 06 May 2025 09:32:22 +0100	[thread overview]
Message-ID: <86ikmegmw9.wl-maz@kernel.org> (raw)
In-Reply-To: <20250501162450.2784043-1-smostafa@google.com>

On Thu, 01 May 2025 17:24:50 +0100,
Mostafa Saleh <smostafa@google.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@google.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.

  reply	other threads:[~2025-05-06  8:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-01 16:24 [PATCH] KVM: arm64: Fix memory check in host_stage2_set_owner_locked() Mostafa Saleh
2025-05-06  8:32 ` Marc Zyngier [this message]
2025-05-06  9:22   ` Mostafa Saleh
2025-05-07  7:56 ` Oliver Upton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86ikmegmw9.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=joey.gouly@arm.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oliver.upton@linux.dev \
    --cc=qperret@google.com \
    --cc=smostafa@google.com \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.