From: Robin Murphy <robin.murphy@arm.com>
To: Shukai Ni <shukai.ni@kuleuven.be>,
"Edgecombe, Rick P" <rick.p.edgecombe@intel.com>,
"m.szyprowski@samsung.com" <m.szyprowski@samsung.com>,
"joro@8bytes.org" <joro@8bytes.org>,
"will@kernel.org" <will@kernel.org>
Cc: "jo.vanbulck@cs.kuleuven.be" <jo.vanbulck@cs.kuleuven.be>,
"Reshetova, Elena" <elena.reshetova@intel.com>,
"pasic@linux.ibm.com" <pasic@linux.ibm.com>,
"kas@kernel.org" <kas@kernel.org>,
"carlos.bilbao@kernel.org" <carlos.bilbao@kernel.org>,
"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"thomas.lendacky@amd.com" <thomas.lendacky@amd.com>,
"linux-coco@lists.linux.dev" <linux-coco@lists.linux.dev>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH] swiotlb: clear read bounce buffers on confidential guests
Date: Tue, 24 Nov 2026 16:13:52 +0000 [thread overview]
Message-ID: <d5dfd9a2-4ac6-415c-b719-699b264fa39d@arm.com> (raw)
In-Reply-To: <9bc0d7ed-0799-45dc-8d74-25ed66851a20@kuleuven.be>
On 23/11/2026 10:56 pm, Shukai Ni wrote:
>
>
> On 2026/11/23 23:18, Edgecombe, Rick P wrote:
>> There is an existing usptream position around coco driver hardening,
>> that the
>> drivers should be fixed. In some ways this another thing that could be
>> fixed in
>> a driver? The driver could zero memory before sharing it for
>> DMA_FROM_DEVICE.
>>
>> But the swiotlb was supposed to be sort of a generic solution to the
>> problem of
>> not inadvertently sharing private memory. Instead of marking an entire
>> page as
>> shared (which might have private contents elsewhere on the page), the
>> bounce
>> buffer allows for only sharing the minimum specified.
>>
>> So you could maybe look at this issue as fitting into the general
>> problem of not
>> inadvertently sharing the private data inside the buffer. But also
>> that is
>> covering for driver gaps.
>
> Thanks for looking at this, and we had very similar thoughts when
> writing the patch. Our impression was that in many cases the driver
> doesn't own the buffer (page cache, dm-crypt, O_DIRECT), so fixing it
> there seemed hard, which is why we tried swiotlb instead. But we may be
> missing something.
>
>> It seems like the fixes commit was arguing that copying the contents
>> to the
>> swiotlb buffer was more transparent. So this patch kind of goes back
>> against
>> that argument. That seems to be another point that the drivers should
>> be fixed.
>> If this is essentially more of a potentially behavior altering kernel
>> hardening,
>> then I wonder about putting it behind some kind of hardening config like
>> CONFIG_INIT_ON_ALLOC_DEFAULT_ON.
>
> As far as we can tell, keeping the old contents for DMA_FROM_DEVICE
> was never really promised. Before ddbd89deb7d3, swiotlb
> didn't do it. That commit was mainly about not returning stale bounce
> data to the caller, which zeroing should still prevent.
SWIOTLB is an implementation detail of the DMA API. If some future CoCo
environment happens to be able to share a buffer in-place with less
overhead than bouncing then it will be free to do so, and drivers which
do not sanitise DMA_FROM_DEVICE or DMA_BIDIRECTIONAL buffers will
continue to leak data...
Note in particular the case of DMA_BIDIRECTIONAL, which means the caller
expects the buffer to either be written and read, or read and written,
or read, or written, or any or all of the above. How is the DMA layer
going to know whether the initial buffer contents are meaningful and
must be preserved, or stale and potentially leaking something?
Also how is the DMA layer to know if a driver is intentionally making
DMA_TO_DEVICE mappings of random (or targeted) kernel memory for the
sole purpose of malicious sharing? If people want to use device drivers
in CoCo environments then the onus being on auditing and hardening the
individual drivers themselves doesn't seem too unreasonable.
Thanks,
Robin.
> In case it helps, we have a PoC on SEV-SNP that leaks MariaDB data from
> a LUKS-encrypted disk through this path, and we're happy to share it.
>
>> Ohh, but I guess the problem is the buffer getting copied could have
>> come from
>> userspace? So then you would have to fix userspace... But then this
>> patch could
>> also potentially break userspace if there is any partial write
>> assumptions. Oh
>> boy.
>
> Yes, a short read into a pre-filled user buffer would now see zeros. We
> did a pass over the drivers commonly used in CVMs and didn't find any
> that rely on the old contents being kept, but we'd be glad to hear if
> someone knows of a case.
>
> Thanks,
> Shukai
>
next prev parent reply other threads:[~2026-11-24 16:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20261123205317eucas1p2f96032281e0f5e9f17acc7ec343acced@eucas1p2.samsung.com>
2026-11-23 20:53 ` Shukai Ni
2026-11-23 22:18 ` Edgecombe, Rick P
2026-11-23 22:56 ` Shukai Ni
2026-11-24 16:13 ` Robin Murphy [this message]
2026-11-24 15:17 ` Marek Szyprowski
2026-11-24 15:36 ` Jason Gunthorpe
2026-11-24 16:11 ` Marek Szyprowski
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=d5dfd9a2-4ac6-415c-b719-699b264fa39d@arm.com \
--to=robin.murphy@arm.com \
--cc=carlos.bilbao@kernel.org \
--cc=elena.reshetova@intel.com \
--cc=iommu@lists.linux.dev \
--cc=jo.vanbulck@cs.kuleuven.be \
--cc=joro@8bytes.org \
--cc=kas@kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=pasic@linux.ibm.com \
--cc=rick.p.edgecombe@intel.com \
--cc=shukai.ni@kuleuven.be \
--cc=stable@vger.kernel.org \
--cc=thomas.lendacky@amd.com \
--cc=will@kernel.org \
/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
all inboxes | Powered by JetHome®