mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Yan Zhao <yan.y.zhao@intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	David Hildenbrand <david@kernel.org>,
	kvm@vger.kernel.org,  linux-kernel@vger.kernel.org,
	Vishal Annapurve <vannapurve@google.com>
Subject: Re: [PATCH v2] KVM: guest_memfd: Elaborate on how release() vs. get_pfn() is safe against UAF
Date: Mon, 21 Sep 2026 06:43:52 -0700	[thread overview]
Message-ID: <arE0mEJaW44HA39e@google.com> (raw)
In-Reply-To: <arEzv8b2IMHYcHsZ@google.com>

On Mon, Sep 21, 2026, Sean Christopherson wrote:
> On Sun, Sep 20, 2026, Yan Zhao wrote:
> > On Wed, Aug 26, 2026 at 09:56:47AM -0700, Sean Christopherson wrote:
> > Do we need to update the code comment in __kvm_gmem_unbind() from
> > 	/*
> > 	 * synchronize_srcu(&kvm->srcu) ensured that kvm_gmem_get_pfn()
> > 	 * cannot see this memslot.
> > 	 */
> > to
> > 	/*
> > 	 * synchronize_srcu_expedited() in kvm_swap_active_memslots() ensured
> > 	 * that kvm_gmem_get_pfn() cannot see this memslot.
> > 	 */
> > 
> > to align with the above comment.
> 
> How about this?  Because the "rule" is that kvm_gmem_unbind() can only be called
> on a memslot that is unreachable, either by synchronizing SRCU after uninstalling
> the memslot *or* because the memslot was never installed.  Simply stating that
> synchronize_srcu_expedited() makes everything safe isn't the whole story, as it's
> specifically synchronzing after removing/deleting/deactivating the slot that
> makes this safe.
> 
> 	/*
> 	 * Note, the caller is responsible for ensuring the slot is unreachable
> 	 * before unbinding, e.g. by synchronizing SRCU after deleting the slot.
> 	 */

Hmm, though it's probably a good idea to preserve the connection to kvm_gmem_get_pfn():

	/*
	 * Note, the caller is responsible for ensuring the slot is unreachable
	 * before unbinding, e.g. by synchronizing SRCU after deleting the slot,
	 * to guarantee kvm_gmem_get_pfn() can't see the slot+file.
	 */

  reply	other threads:[~2026-09-21 13:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-26 16:56 Sean Christopherson
2026-09-20 12:55 ` Yan Zhao
2026-09-21 13:40   ` Sean Christopherson
2026-09-21 13:43     ` Sean Christopherson [this message]
2026-09-22  3:47       ` Yan Zhao
2026-09-22  3:45     ` Yan Zhao
2026-09-22 14:22       ` Sean Christopherson
2026-09-23  5:01         ` Yan Zhao

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=arE0mEJaW44HA39e@google.com \
    --to=seanjc@google.com \
    --cc=david@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=vannapurve@google.com \
    --cc=yan.y.zhao@intel.com \
    /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®