[PATCH] KVM: arm64: Validate the FF-A memory access descriptor placement

M.samet Duman dumanmehmetsamet at icloud.com
Mon Apr 27 05:48:29 PDT 2026


I haven't tested this, but the change looks reasonable to me.

Samet

> 2026. 4. 22. 오후 1:27, Sebastian Ene <sebastianene at google.com> 작성:
> 
> Prevent the pKVM hypervisor from making assumptions that the
> endpoint memory access descriptor (EMAD) comes right after the
> FF-A memory region header and enforce a strict placement for it
> when validating an FF-A memory lend/share transaction.
> 
> 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:
> 
>  Field name                | Offset
>                     -- 0
> [ Header (ffa_mem_region)               |__ ep_mem_offset
>  EMAD 1 (ffa_mem_region_attributes)    |
> ]
> 
> Reject the host from specifying a memory access descriptor offset
> that is different than the size of the memory region header.
> 
> Cc: stable at vger.kernel.org
> Fixes: 42fb33dde42b ("KVM: arm64: Use FF-A 1.1 with pKVM")
> Signed-off-by: Sebastian Ene <sebastianene at google.com>
> ---
> arch/arm64/kvm/hyp/nvhe/ffa.c | 6 ++++++
> 1 file changed, 6 insertions(+)
> 
> diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c
> index 94161ea1cd60..0703c0ad8dff 100644
> --- a/arch/arm64/kvm/hyp/nvhe/ffa.c
> +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c
> @@ -508,6 +508,12 @@ static void __do_ffa_mem_xfer(const u64 func_id,
>    buf = hyp_buffers.tx;
>    memcpy(buf, host_buffers.tx, fraglen);
> 
> +    if (FFA_MEM_REGION_HAS_EP_MEM_OFFSET(hyp_ffa_version) &&
> +        buf->ep_mem_offset != sizeof(struct ffa_mem_region)) {
> +        ret = FFA_RET_INVALID_PARAMETERS;
> +        goto out_unlock;
> +    }
> +
>    ep_mem_access = (void *)buf +
>            ffa_mem_desc_offset(buf, 0, hyp_ffa_version);
>    offset = ep_mem_access->composite_off;
> --
> 2.54.0.rc1.555.g9c883467ad-goog
> 
> 



More information about the linux-arm-kernel mailing list