Re: [PATCH] swiotlb: clear read bounce buffers on confidential guests

From: Jason Gunthorpe

Date: Tue Nov 24 2026 - 10:36:24 EST


On Tue, Nov 24, 2026 at 04:17:20PM +0100, Marek Szyprowski wrote:
> Hi!
>
> CCed Jason and Aneesh.
>
> On 23.11.2026 21:53, Shukai Ni wrote:
> > On confidential guests (AMD SEV, Intel TDX) all device DMA is bounced
> > through swiotlb, whose pool is shared with and readable by the untrusted
> > host. swiotlb_tbl_map_single() copies the destination buffer's current
> > contents into the bounce buffer at map time even for DMA_FROM_DEVICE. For
> > a reused read buffer that still holds private data, the host can read
> > that data from the bounce buffer before the device overwrites it.
> >
> > For DMA_FROM_DEVICE into a host-shared pool, zero the bounce buffer
> > instead. Zeroing rather than skipping the copy keeps a short read from
> > returning a previous transfer's data.
> >
> > Fixes: ddbd89deb7d3 ("swiotlb: fix info leak with DMA_FROM_DEVICE")
> > Cc: stable@xxxxxxxxxxxxxxx
> > Co-developed-by: Jo Van Bulck <jo.vanbulck@xxxxxxxxxxxxxx>
> > Signed-off-by: Jo Van Bulck <jo.vanbulck@xxxxxxxxxxxxxx>
> > Signed-off-by: Shukai Ni <shukai.ni@xxxxxxxxxxx>
>
>
> I'm not sure if DMA-mapping or SWIOTLB is the right place for such fixups.
>
> Drivers should be aware that doing DMA from unsecure device to the given
> secure page might reveal its content to the host or other parties and
> prepare for that (like zeroing that page).

I think given the semantics we have to support partial write we don't
have a choice but to continue them as it is the DMA API.

The driver would have to opt out of partial write support somehow to
trigger this, and in that case it is more of an optimization and
shouldn't be linked to CC.

I'm curious if there is a real issue here with a definitive issue on a
driver or it is just speculation?

Jason