Re: [PATCH] swiotlb: clear read bounce buffers on confidential guests
From: Shukai Ni
Date: Mon Nov 23 2026 - 17:56:29 EST
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.
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