[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] xen/arm: ffa: Harden SEND2 against invented loads
- To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
- From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
- Date: Wed, 19 Aug 2026 06:39:03 +0000
- Accept-language: en-GB, en-US
- Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 4.158.2.129) smtp.rcpttodomain=citrix.com smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
- Arc-message-signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZacAcQDsE5OOl2iLFSsAvmPjBCOQWiDF5j/s9C5nOYA=; b=fzY43MG+SRdx005ZdPrnUqTMeJCuM1QFldpVU6w3XSjs85qipdhcM04Ecyp0fN1MkkkRUnHWRI4iAeYJ8lyf/93wZTiaOUo0nV3V1Didv1u5aFtyaBBuWaKR+5m3T/J3SS+1QUPUroIKUsIQdtZWv3DAU1F8iGYHF64Ga0lfUyWiClCxqwqHPqB63ycBBzSE+fxMETBcrVHxKNMAitVxKYwUixq47PjE15LyaltfCQZLuq0vL9VYeRcoKytrzC7Ldvq89rybqPqWlXoqKR8ZUd/kezBsYjj9eIzoWb2A6VqLuETHHGe3FPB0fgMQxt9Ay4UEJdpnW3th/H6/NVQMGA==
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZacAcQDsE5OOl2iLFSsAvmPjBCOQWiDF5j/s9C5nOYA=; b=k9CeA1KNHjwojVujJ1HPzTtcDb32S0B1UqLBMLwZOwPtxF2u/oMe3goLvbCsyPNAyn9mgToiNbZOUIo8J1jG8B6OZDQuJrYJMY9lDBEi8ksxLYAo3PMZcF+rEggJkVofoZPkLLEu4akHoZNHlQ1jKgLw0i3HxfQNxIt9rTARA4gRV1LuEhCx5JxPS39u5MZhyY3jmk7i/4YgBn+6QD+m+2qCwDmnuJUMt7Nc4L7VtjGJzBE/yozDniUFm0Lg2OjJbQeOqFh3SQHxedjmtSHz1CxQwtqowAcxB/QRJk7YaIO36R8ftIZ8Pi6/iT1lj2J5skXxbCLXM2RpXteKbX2/gA==
- Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=JVB+MhqXPF5c3iWwBFv2TER6uvLSHinvHUtyBFdYswfC4mx7HSyF7GYxXI1+KQ5eB7MdPNUtSCkftFgWBOS57WSUdbbsiM4kNu/mwRLL3mn/OmsYk7hjs5Nh4A3gv9JQs+oekByjSiyzDM43z4BAoiMGst88iL7/ZerwfaaCVAl5adkAW0jgYUVYK71gEMou3jDA7tKDjO/txrL5Oh2Xl+yv2zmMvHig8VFqOI0Z4fjKvB3H7oOwb6Fyh09GV8XafNl3j04dz8cDw8aFmTvshvqy3YGvGpd3+3xXCK0PY/FJnQ0OB4VRXS2nJBkSMh366ddc4H57sebabc2xy5ZQIQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cvP/PXRNniBKhf033xnWToOsjHXAdoMAiraWMLGOAo/oFFf2TiH2SlY/x342bSnWy7vt434xc3tDfem564ca9rtz20/JvtrSE93KvAi8DMIzkGjn0qkOOiiELFMp7M3vS5NmDZR5zeUeCrQ8/SydAAIioRwpR/CCpYGewdfgr/Z8qVFtOK/xqIKnbjgf/JigOpgQ2H4obFWSluFIALHRJEhKDywqYNsKeThsdFLoUK/6D9dUXlHubdEypSHI+AVpKX6J9Knnef1DniSPa0QXkCgo68/ScwrZ2EhRG4maTzf7W7V0wYKkWvoK6lFUgKx6xJjrbHBFqZJViqGgufUaEA==
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=arm.com header.i="@arm.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"; dkim=pass header.s=selector1 header.d=arm.com header.i="@arm.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
- Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
- Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>, Jens Wiklander <jenswi@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>
- Delivery-date: Wed, 19 Aug 2026 06:39:47 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Nodisclaimer: true
- Thread-index: AQHdLwt9ezGusG27iE6LBf89mJZswbajv3sAgAANaoCAABXGgIABCguA
- Thread-topic: [PATCH] xen/arm: ffa: Harden SEND2 against invented loads
Hi Andrew,
> On 18 Aug 2026, at 16:46, Andrew Cooper <andrew.cooper3@xxxxxxxxxx> wrote:
>
> On 18/08/2026 2:28 pm, Bertrand Marquis wrote:
>> Hi Andrew,
>>
>>> On 18 Aug 2026, at 14:40, Andrew Cooper <andrew.cooper3@xxxxxxxxxx> wrote:
>>>
>>> On 18/08/2026 1:16 pm, Bertrand Marquis wrote:
>>>> Research into compiler-invented loads has flagged FFA_MSG_SEND2 as a
>>>> possible vulnerability.
>>>>
>>>> ffa_handle_msg_send2() copies the message header from the guest-writable
>>>> TX buffer before validating and using its fields. A plain structure copy
>>>> does not prevent the compiler from re-deriving later field accesses from
>>>> the live TX mapping.
>>>>
>>>> For VM-to-VM messages, msg_offset and msg_size are validated against the
>>>> source and destination buffers, then used to copy the payload. If a
>>>> sibling vCPU changes the header and the compiler reloads either field,
>>>> the checked and used values can differ. This can cause an out-of-bounds
>>>> read from the sender's TX buffer or an out-of-bounds write into the
>>>> receiver's RX buffer.
>>>>
>>>> The cross-VM path is gated by CONFIG_FFA_VM_TO_VM, which is disabled by
>>>> default. The audit ranks the likelihood of such a reload as low, but the
>>>> C semantics do not guarantee that later accesses use the stack copy.
>>>>
>>>> Add a compiler barrier immediately after copying the header so that
>>>> validation and use consume the same snapshot.
>>>>
>>>> Link:
>>>> https://github.com/xoreaxeaxeax/schrodingers-toctou/blob/main/observer-effect/audits/audit-xen-tee-mediator-RELEASE-4.21.1.md#tm-2--ff-a-txrx-buffers-ffa_shmc-ffa_msgc
>>>> Fixes: 98af565b1e61 ("xen/arm: ffa: Add indirect message between VM")
>>>> Signed-off-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>
>>>> ---
>>>> xen/arch/arm/tee/ffa_msg.c | 5 +++++
>>>> 1 file changed, 5 insertions(+)
>>>>
>>>> diff --git a/xen/arch/arm/tee/ffa_msg.c b/xen/arch/arm/tee/ffa_msg.c
>>>> index 1eadc62870f2..39f561c8237f 100644
>>>> --- a/xen/arch/arm/tee/ffa_msg.c
>>>> +++ b/xen/arch/arm/tee/ffa_msg.c
>>>> @@ -257,6 +257,11 @@ int32_t ffa_handle_msg_send2(struct cpu_user_regs
>>>> *regs)
>>>>
>>>> /* create a copy of the message header */
>>>> memcpy(&src_msg, tx_buf, sizeof(src_msg));
>>>> + /*
>>>> + * Make sure that "tx_buf" which is shared with the guest isn't
>>>> accessed
>>>> + * again after this point.
>>>> + */
>>>> + barrier();
>>>>
>>>> src_id = src_msg.send_recv_id >> 16;
>>>> dst_id = src_msg.send_recv_id & GENMASK(15,0);
>>> This does look to be adequate to fix the potential issue, but you should
>>> drop the ACCESS_ONCE(src_ctx->guest_vers) a little lower down.
>>>
>>> With a safe copy on the stack, there's no need to further inhibit
>>> optimisations around it. In fact, it's unclear why e040b94d0fff added
>>> the ACCESS_ONCE() in the first place, seeing as it was already an
>>> on-stack object at the time.
>> the ACCESS_ONCE is protecting the access to guest_vers which is not on the
>> stack
>> but a value on an internal context accessed by all VMs.
>>
>> You probably mixed src_MSG with src_CTX ?
> Oh, maybe. Those really ought to have more distinct names.
No worries.
Would you consider renaming them a requirement for this patch?
If not, I would prefer to keep this fix focused on adding the barrier and avoid
unrelated churn.
Cheers
Bertrand
>
> ~Andrew
|