[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <4c498701b6e012a7d55b8da58dc2050f55090959.camel@intel.com>
Date: Tue, 22 Jul 2025 19:25:08 +0000
From: "Edgecombe, Rick P" <rick.p.edgecombe@...el.com>
To: "ackerleytng@...gle.com" <ackerleytng@...gle.com>,
"yilun.xu@...ux.intel.com" <yilun.xu@...ux.intel.com>, "Weiny, Ira"
<ira.weiny@...el.com>
CC: "palmer@...belt.com" <palmer@...belt.com>, "kvm@...r.kernel.org"
<kvm@...r.kernel.org>, "catalin.marinas@....com" <catalin.marinas@....com>,
"Miao, Jun" <jun.miao@...el.com>, "nsaenz@...zon.es" <nsaenz@...zon.es>,
"kirill.shutemov@...el.com" <kirill.shutemov@...el.com>,
"pdurrant@...zon.co.uk" <pdurrant@...zon.co.uk>, "peterx@...hat.com"
<peterx@...hat.com>, "x86@...nel.org" <x86@...nel.org>, "amoorthy@...gle.com"
<amoorthy@...gle.com>, "jack@...e.cz" <jack@...e.cz>, "maz@...nel.org"
<maz@...nel.org>, "tabba@...gle.com" <tabba@...gle.com>, "pvorel@...e.cz"
<pvorel@...e.cz>, "anthony.yznaga@...cle.com" <anthony.yznaga@...cle.com>,
"keirf@...gle.com" <keirf@...gle.com>, "Annapurve, Vishal"
<vannapurve@...gle.com>, "hughd@...gle.com" <hughd@...gle.com>,
"mail@...iej.szmigiero.name" <mail@...iej.szmigiero.name>, "Du, Fan"
<fan.du@...el.com>, "Wieczor-Retman, Maciej"
<maciej.wieczor-retman@...el.com>, "Zhao, Yan Y" <yan.y.zhao@...el.com>,
"ajones@...tanamicro.com" <ajones@...tanamicro.com>, "Hansen, Dave"
<dave.hansen@...el.com>, "paul.walmsley@...ive.com"
<paul.walmsley@...ive.com>, "quic_mnalajal@...cinc.com"
<quic_mnalajal@...cinc.com>, "aik@....com" <aik@....com>,
"steven.price@....com" <steven.price@....com>, "vkuznets@...hat.com"
<vkuznets@...hat.com>, "fvdl@...gle.com" <fvdl@...gle.com>, "rppt@...nel.org"
<rppt@...nel.org>, "bfoster@...hat.com" <bfoster@...hat.com>,
"quic_cvanscha@...cinc.com" <quic_cvanscha@...cinc.com>, "vbabka@...e.cz"
<vbabka@...e.cz>, "anup@...infault.org" <anup@...infault.org>,
"quic_eberman@...cinc.com" <quic_eberman@...cinc.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"thomas.lendacky@....com" <thomas.lendacky@....com>, "mic@...ikod.net"
<mic@...ikod.net>, "oliver.upton@...ux.dev" <oliver.upton@...ux.dev>,
"akpm@...ux-foundation.org" <akpm@...ux-foundation.org>,
"usama.arif@...edance.com" <usama.arif@...edance.com>,
"binbin.wu@...ux.intel.com" <binbin.wu@...ux.intel.com>,
"muchun.song@...ux.dev" <muchun.song@...ux.dev>, "Li, Zhiquan1"
<zhiquan1.li@...el.com>, "rientjes@...gle.com" <rientjes@...gle.com>, "Aktas,
Erdem" <erdemaktas@...gle.com>, "mpe@...erman.id.au" <mpe@...erman.id.au>,
"david@...hat.com" <david@...hat.com>, "jgg@...pe.ca" <jgg@...pe.ca>,
"willy@...radead.org" <willy@...radead.org>, "Xu, Haibo1"
<haibo1.xu@...el.com>, "jhubbard@...dia.com" <jhubbard@...dia.com>,
"quic_svaddagi@...cinc.com" <quic_svaddagi@...cinc.com>, "Yamahata, Isaku"
<isaku.yamahata@...el.com>, "jthoughton@...gle.com" <jthoughton@...gle.com>,
"will@...nel.org" <will@...nel.org>, "Wang, Wei W" <wei.w.wang@...el.com>,
"steven.sistare@...cle.com" <steven.sistare@...cle.com>, "jarkko@...nel.org"
<jarkko@...nel.org>, "quic_pheragu@...cinc.com" <quic_pheragu@...cinc.com>,
"chenhuacai@...nel.org" <chenhuacai@...nel.org>, "Huang, Kai"
<kai.huang@...el.com>, "shuah@...nel.org" <shuah@...nel.org>,
"dwmw@...zon.co.uk" <dwmw@...zon.co.uk>, "Peng, Chao P"
<chao.p.peng@...el.com>, "pankaj.gupta@....com" <pankaj.gupta@....com>,
"nikunj@....com" <nikunj@....com>, "Graf, Alexander" <graf@...zon.com>,
"viro@...iv.linux.org.uk" <viro@...iv.linux.org.uk>, "pbonzini@...hat.com"
<pbonzini@...hat.com>, "yuzenghui@...wei.com" <yuzenghui@...wei.com>,
"jroedel@...e.de" <jroedel@...e.de>, "suzuki.poulose@....com"
<suzuki.poulose@....com>, "jgowans@...zon.com" <jgowans@...zon.com>, "Xu,
Yilun" <yilun.xu@...el.com>, "liam.merwick@...cle.com"
<liam.merwick@...cle.com>, "michael.roth@....com" <michael.roth@....com>,
"quic_tsoni@...cinc.com" <quic_tsoni@...cinc.com>,
"richard.weiyang@...il.com" <richard.weiyang@...il.com>,
"aou@...s.berkeley.edu" <aou@...s.berkeley.edu>, "Li, Xiaoyao"
<xiaoyao.li@...el.com>, "kent.overstreet@...ux.dev"
<kent.overstreet@...ux.dev>, "qperret@...gle.com" <qperret@...gle.com>,
"dmatlack@...gle.com" <dmatlack@...gle.com>, "james.morse@....com"
<james.morse@....com>, "brauner@...nel.org" <brauner@...nel.org>,
"linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
"pgonda@...gle.com" <pgonda@...gle.com>, "quic_pderrin@...cinc.com"
<quic_pderrin@...cinc.com>, "hch@...radead.org" <hch@...radead.org>,
"linux-mm@...ck.org" <linux-mm@...ck.org>, "seanjc@...gle.com"
<seanjc@...gle.com>, "roypat@...zon.co.uk" <roypat@...zon.co.uk>
Subject: Re: [RFC PATCH v2 04/51] KVM: guest_memfd: Introduce
KVM_GMEM_CONVERT_SHARED/PRIVATE ioctls
On Tue, 2025-07-22 at 11:17 -0700, Ackerley Tng wrote:
> Sounds like a malicious guest could skip unpinning private memory, and
> guest_memfd's unmap will fail, leading to a KVM_BUG_ON() as Yan/Rick
> suggested here [1].
>
> Actually it seems like a legacy guest would also lead to unmap failures
> and the KVM_BUG_ON(), since when TDX connect is enabled, the pinning
> mode is enforced, even for non-IO private pages?
>
> I hope your team's investigations find a good way for the host to
> reclaim memory, at least from dead TDs! Otherwise this would be an open
> hole for guests to leak a host's memory.
>
> Circling back to the original topic [2], it sounds like we're okay for
> IOMMU to *not* take any refcounts on pages and can rely on guest_memfd
> to keep the page around on behalf of the VM?
>
> [1] https://lore.kernel.org/all/diqzcya13x2j.fsf@ackerleytng-ctop.c.googlers.com/
> [2] https://lore.kernel.org/all/CAGtprH_qh8sEY3s-JucW3n1Wvoq7jdVZDDokvG5HzPf0HV2=pg@mail.gmail.com/
Djbw, Yilun and I had a chat yesterday. We'll investigate a way to have an
operation that can't fail and will allow total cleanup and reclaim for the TD's
resources, as well as a per-TDX module scoped version.
If host userspace or the guest kernel does something wrong, the guest can be
destroyed in the normal VM case. So we can try to use these operations as a way
to save host kernel complexity for cases like that. But if an error condition
might come up in normal cases (i.e. rare races, non-bugs) we need to look to
other error handling solutions.
We were planning to investigate first and then share back to the list. It
probably deserves broader consideration beyond folks still reading deep down in
this thread.
Powered by blists - more mailing lists