All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sebastian Ene" <sebastianene@google.com>
Cc: "Marc Zyngier" <maz@kernel.org>,
	kvmarm@lists.linux.dev, "Oliver Upton" <oupton@kernel.org>
Subject: Re: [PATCH v8 5/6] KVM: arm64: Ensure FFA ranges are page aligned
Date: Tue, 30 Jun 2026 11:08:58 +0000	[thread overview]
Message-ID: <20260630110858.BDA0F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260630102058.3219867-7-sebastianene@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Host-controlled invalid handles in FFA_MEM_FRAG_TX trigger a fatal hypervisor panic via WARN_ON.
--

commit b0b1c44dd777f162d56e942a3bb04410af9b98a8
Author: Mostafa Saleh <smostafa@google.com>

    KVM: arm64: Ensure FFA ranges are page aligned
    
    Harden the check for the constituent memory region page alignment
    to prevent over-sharing when the negotiated FFA_PAGE_SIZE size is
    smaller than the system PAGE_SIZE.
    At the moment we only check that the size of the range is page
    aligned, and truncate the address to the page boundary which can
    annotate more memory than needed as being used by the FF-A.

> diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c
> index 14aa37846059a..bb01d8f830561 100644
> --- a/arch/arm64/kvm/hyp/nvhe/ffa.c
> +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c
> @@ -352,7 +352,7 @@ static u32 __ffa_host_share_ranges(struct ffa_mem_region_addr_range *ranges,
>  		u64 sz = (u64)range->pg_cnt * FFA_PAGE_SIZE;
>  		u64 pfn = hyp_phys_to_pfn(range->address);
>  
> -		if (!PAGE_ALIGNED(sz))
> +		if (!PAGE_ALIGNED(sz | range->address))
>  			break;

[Severity: High]
This isn't a bug introduced by this patch, but I have a question about the
error handling when ffa_host_share_ranges() fails due to these alignment
checks.

If the host kernel issues an FFA_MEM_FRAG_TX SMC with a valid fraglen but an
invalid handle_lo or handle_hi, and a fragment whose descriptor contains an
unaligned address, ffa_host_share_ranges() will fail.

Looking at do_ffa_mem_frag_tx() in arch/arm64/kvm/hyp/nvhe/ffa.c:

do_ffa_mem_frag_tx() {
    ...
	ret = ffa_host_share_ranges(buf, nr_ranges);
	if (ret) {
		/*
		 * We're effectively aborting the transaction, so we need
		 * to restore the global state back to what it was prior to
		 * transmission of the first fragment.
		 */
		ffa_mem_reclaim(res, handle_lo, handle_hi, 0);
		WARN_ON(res->a0 != FFA_SUCCESS);
		goto out_unlock;
	}
    ...
}

Because the host provided a bogus handle, the SPMD firmware will reject this
reclaim and return an error (e.g., FFA_INVALID_PARAMETERS). Doesn't this cause
the WARN_ON() to fire, leading to a fatal hypervisor panic triggered by
untrusted host input?

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260630102058.3219867-2-sebastianene@google.com?part=5

  reply	other threads:[~2026-06-30 11:08 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-30 10:20 [PATCH v8 0/6] arm_ffa, KVM: Fix FF-A emad offset calculations Sebastian Ene
2026-06-30 10:20 ` Sebastian Ene via OP-TEE
2026-06-30 10:20 ` [PATCH v8 1/6] firmware: arm_ffa: Fix out-of-bound writes in ffa_setup_and_transmit() Sebastian Ene
2026-06-30 10:20   ` Sebastian Ene via OP-TEE
2026-06-30 10:20 ` [PATCH v8 2/6] firmware: arm_ffa: Fix Endpoint Memory Access Descriptor offset calculation Sebastian Ene
2026-06-30 10:20   ` Sebastian Ene via OP-TEE
2026-06-30 10:20 ` [PATCH v8 3/6] KVM: arm64: Fix bounds checking in do_ffa_mem_reclaim() Sebastian Ene
2026-06-30 10:20   ` Sebastian Ene via OP-TEE
2026-06-30 10:53   ` sashiko-bot
2026-06-30 10:20 ` [PATCH v8 4/6] KVM: arm64: Validate the offset to the mem access descriptor Sebastian Ene
2026-06-30 10:20   ` Sebastian Ene via OP-TEE
2026-06-30 10:20 ` [PATCH v8 5/6] KVM: arm64: Ensure FFA ranges are page aligned Sebastian Ene
2026-06-30 10:20   ` Sebastian Ene via OP-TEE
2026-06-30 11:08   ` sashiko-bot [this message]
2026-06-30 10:20 ` [PATCH v8 6/6] KVM: arm64: Zero out the stack initialized data in the FFA handler Sebastian Ene
2026-06-30 10:20   ` Sebastian Ene via OP-TEE
2026-06-30 11:19   ` sashiko-bot

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=20260630110858.BDA0F1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sebastianene@google.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.