mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Edgecombe, Rick P" <rick.p.edgecombe@intel.com>
To: "robin.murphy@arm.com" <robin.murphy@arm.com>,
	"m.szyprowski@samsung.com" <m.szyprowski@samsung.com>,
	"shukai.ni@kuleuven.be" <shukai.ni@kuleuven.be>,
	"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: Mon, 23 Nov 2026 22:18:49 +0000	[thread overview]
Message-ID: <3a70a26adccc47b1bae3a22e4907174271703a10.camel@intel.com> (raw)
In-Reply-To: <20261123205302.1034348-1-shukai.ni@kuleuven.be>

On Mon, 2026-11-23 at 21:53 +0100, 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@vger.kernel.org
> Co-developed-by: Jo Van Bulck <jo.vanbulck@cs.kuleuven.be>
> Signed-off-by: Jo Van Bulck <jo.vanbulck@cs.kuleuven.be>
> Signed-off-by: Shukai Ni <shukai.ni@kuleuven.be>
> ---
> 
> Notes:
>     We are open to discussing a different approach: e.g. clearing the
>     residual when read back, scrubbing slots on free, or extending zeroing
>     for bidirectional DMA.

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.

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.

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.

      reply	other threads:[~2026-11-23 22:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 20:53 Shukai Ni
2026-11-23 22:18 ` Edgecombe, Rick P [this message]

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=3a70a26adccc47b1bae3a22e4907174271703a10.camel@intel.com \
    --to=rick.p.edgecombe@intel.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=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

all inboxes | Powered by JetHome®