From: Vincent Donnefort <vdonnefort@google.com>
To: Sebastian Ene <sebastianene@google.com>
Cc: catalin.marinas@arm.com, oupton@kernel.org,
sudeep.holla@kernel.org, will@kernel.org,
jens.wiklander@linaro.org, joey.gouly@arm.com,
kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, android-kvm@google.com,
maz@kernel.org, mrigendra.chaubey@gmail.com,
op-tee@lists.trustedfirmware.org, perlarsen@google.com,
seiden@linux.ibm.com, smostafa@google.com, sumit.garg@kernel.org,
suzuki.poulose@arm.com, yuzenghui@huawei.com
Subject: Re: [PATCH v9 4/6] KVM: arm64: Validate the offset to the mem access descriptor
Date: Fri, 3 Jul 2026 11:35:08 +0100 [thread overview]
Message-ID: <akeQXIY_7Z0v9ouR@google.com> (raw)
In-Reply-To: <20260702103848.1647249-5-sebastianene@google.com>
On Thu, Jul 02, 2026 at 10:38:41AM +0000, Sebastian Ene wrote:
> Prevent the pKVM hypervisor from making assumptions that the
> endpoint memory access descriptor (EMAD) comes right after the
> FF-A memory region header.
> Prior to FF-A version 1.1 the header of the memory region
> didn't contain an offset to the endpoint memory access descriptor.
> The layout of a memory transaction looks like this from 1.1 onward:
> Type | Field name | Offset
> [ Header | ffa_mem_region | 0
> EMAD 1 | ffa_mem_region_attributes) | ffa_mem_region.ep_mem_offset
> ]
> Verify that the offset to the first endpoint memory access descriptor
> is within the mailbox buffer bounds.
>
> Also, fix one hardcoded sizeof(struct ffa_mem_region_attributes) that
> should be replaced ffa_emad_size_get() for compatibility with FFA v1.0.
>
> Fixes: 42fb33dde42b ("KVM: arm64: Use FF-A 1.1 with pKVM")
> Signed-off-by: Mostafa Saleh <smostafa@google.com>
> Signed-off-by: Sebastian Ene <sebastianene@google.com>
Reviewed-by: Vincent Donnefort <vdonnefort@google.com>
> ---
> arch/arm64/kvm/hyp/nvhe/ffa.c | 27 +++++++++++++++++++--------
> include/linux/arm_ffa.h | 7 +++++++
> 2 files changed, 26 insertions(+), 8 deletions(-)
>
[...]
> diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
> index 033c630b271b..e71d83ee0aef 100644
> --- a/include/linux/arm_ffa.h
> +++ b/include/linux/arm_ffa.h
> @@ -421,6 +421,13 @@ struct ffa_mem_region {
> #define FFA_EMAD_HAS_IMPDEF_FIELD(version) ((version) >= FFA_VERSION_1_2)
> #define FFA_MEM_REGION_HAS_EP_MEM_OFFSET(version) ((version) > FFA_VERSION_1_0)
>
> +/* The layout changed from FFA_VERSION_1_0 and the region includes an
> + * ep_mem_offset.
> + */
nit: Coding-style.
> +#define FFA_MEM_REGION_SZ(version) (!FFA_MEM_REGION_HAS_EP_MEM_OFFSET((version)) ?\
> + offsetof(struct ffa_mem_region, ep_mem_offset) :\
> + sizeof(struct ffa_mem_region))
nit: Could avoid the ! by just swapping the two expressions.
> +
> static inline u32 ffa_emad_size_get(u32 ffa_version)
> {
> u32 sz;
> --
> 2.55.0.rc0.799.gd6f94ed593-goog
>
next prev parent reply other threads:[~2026-07-03 10:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-02 10:38 [PATCH v9 0/6] arm_ffa, KVM: Fix FF-A emad offset calculations Sebastian Ene
2026-07-02 10:38 ` [PATCH v9 1/6] firmware: arm_ffa: Fix out-of-bound writes in ffa_setup_and_transmit() Sebastian Ene
2026-07-02 10:38 ` [PATCH v9 2/6] firmware: arm_ffa: Fix Endpoint Memory Access Descriptor offset calculation Sebastian Ene
2026-07-02 10:38 ` [PATCH v9 3/6] KVM: arm64: Fix bounds checking in do_ffa_mem_reclaim() Sebastian Ene
2026-07-02 10:38 ` [PATCH v9 4/6] KVM: arm64: Validate the offset to the mem access descriptor Sebastian Ene
2026-07-03 10:35 ` Vincent Donnefort [this message]
2026-07-02 10:38 ` [PATCH v9 5/6] KVM: arm64: Ensure FFA ranges are page aligned Sebastian Ene
2026-07-02 10:38 ` [PATCH v9 6/6] KVM: arm64: Zero out the stack initialized data in the FFA handler Sebastian Ene
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=akeQXIY_7Z0v9ouR@google.com \
--to=vdonnefort@google.com \
--cc=android-kvm@google.com \
--cc=catalin.marinas@arm.com \
--cc=jens.wiklander@linaro.org \
--cc=joey.gouly@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=mrigendra.chaubey@gmail.com \
--cc=op-tee@lists.trustedfirmware.org \
--cc=oupton@kernel.org \
--cc=perlarsen@google.com \
--cc=sebastianene@google.com \
--cc=seiden@linux.ibm.com \
--cc=smostafa@google.com \
--cc=sudeep.holla@kernel.org \
--cc=sumit.garg@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox