Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Halil Pasic <pasic@linux.ibm.com>
To: Robin Murphy <robin.murphy@arm.com>
Cc: 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>,
	"jo.vanbulck@cs.kuleuven.be" <jo.vanbulck@cs.kuleuven.be>,
	"Reshetova, Elena" <elena.reshetova@intel.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>,
	Halil Pasic <pasic@linux.ibm.com>
Subject: Re: [PATCH] swiotlb: clear read bounce buffers on confidential guests
Date: Thu, 26 Nov 2026 02:19:08 +0100	[thread overview]
Message-ID: <20261126021908.59b2105f.pasic@linux.ibm.com> (raw)
In-Reply-To: <d5dfd9a2-4ac6-415c-b719-699b264fa39d@arm.com>

On Tue, 24 Nov 2026 16:13:52 +0000
Robin Murphy <robin.murphy@arm.com> wrote:

> > 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.

I'm 100% with Robin on this one! Reusing a buffer is not a problem
in itself. Exposing private data is. And the only clean way I see is
prevent that from happening is to not DMA map buffers containing private
stuff. Not even as DMA_FROM_DEVICE. The blamed patch is about
propagating the sanitation done on the original buffer to the swiotlb
buffer to which the access is granted to the untrusted host.

I wonder what type of reuse are we talking about here? If the
buffer contains data from an old co-co IO might be acceptable,
as the assumption there is that co-co IO has to be cryptographically
protected anyway (from the non-trusted host).

Another thought: My understanding is that an actual IOMMU may or may not
support "write only".  I think, the swiotlb is not the right place to
address this. But if we allow for IOMMUs may not supporting "write only"
DMA API in general may be. The thing is, if the conceptual IOMMU actually
guarantees that write only is indeed write only and then there is no
harm per se in not sanitizing as, we can be sure that there is not leak
with respect to the conceptual device at least. If however the
conceptual IOMMU is not capable of doing so, then one could argue
that this constitutes a leak even without co-co. And for non-trusted
devices and co-co (i.e. with swtiotlb) the conceptual IOMMU would
never be able to guarantee "write only": because even if the IOMMU of the
platform does, the host can still access the shared buffer, so
we have a leak (an we would consider the host a par of the conceptual
device as it is effectively capable of doing conceptual DMA). I admit
something like this still feels a little hacky, but I hope worth
discussing nevertheless.

Regards,
Halil


  reply	other threads:[~2026-11-26  1:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20261123205317eucas1p2f96032281e0f5e9f17acc7ec343acced@eucas1p2.samsung.com>
2026-11-23 20:53 ` [PATCH] swiotlb: clear read bounce buffers on confidential guests Shukai Ni
2026-11-23 22:18   ` Edgecombe, Rick P
2026-11-23 22:56     ` Shukai Ni
2026-11-24 16:13       ` Robin Murphy
2026-11-26  1:19         ` Halil Pasic [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=20261126021908.59b2105f.pasic@linux.ibm.com \
    --to=pasic@linux.ibm.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=rick.p.edgecombe@intel.com \
    --cc=robin.murphy@arm.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