All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: sashiko-reviews@lists.linux.dev
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v2] KVM: guest_memfd: Elaborate on how release() vs. get_pfn() is safe against UAF
Date: Wed, 26 Aug 2026 11:39:37 -0700	[thread overview]
Message-ID: <ao8y6d5gMN1wG_C0@google.com> (raw)
In-Reply-To: <20260826171151.959AC1F000E9@smtp.kernel.org>

On Wed, Aug 26, 2026, sashiko-bot@kernel.org wrote:
> > diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c
> > index b596486d184ca..7f1c6a0f8039d 100644
> > --- a/virt/kvm/guest_memfd.c
> > +++ b/virt/kvm/guest_memfd.c
> [ ... ]
> > @@ -300,17 +300,55 @@ static int kvm_gmem_release(struct inode *inode, struct file *file)
> >  	 * dereferencing the slot for existing bindings needs to be protected
> >  	 * against memslot updates, specifically so that unbind doesn't race
> >  	 * and free the memslot (kvm_gmem_get_file() will return NULL).
> >  	 */
> >  	mutex_lock(&kvm->slots_lock);
> >  
> >  	filemap_invalidate_lock(inode->i_mapping);
> >  
> > +	/*
> > +	 * Note!  synchronize_srcu() is _not_ needed after nullifying memslot
> [ ... ]
> > +	 * Obviously KVM would be broken in many places if the synchronization
> > +	 * were omitted, but it's important to note that get_file_active() does
> > +	 * NOT guarantee a reference to the correct file was obtained, only
> > +	 * that the file doesn't point at a reallocated object.
> > +	 */
> >  	xa_for_each(&f->bindings, index, slot)
> >  		WRITE_ONCE(slot->gmem.file, NULL);
> >  
> 
> [Severity: Critical]
> This is a pre-existing issue, but could bypassing filemap_invalidate_lock in
> kvm_gmem_unbind() when the file is dying allow concurrent xarray modifications
> that result in a use-after-free?

Yep, already reported by Sashiko and being fixed:
https://lore.kernel.org/all/20260823-shivank-gmem-fix-split-v1-1-512a29fb8e86@amd.com

  reply	other threads:[~2026-08-26 18:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-26 16:56 [PATCH v2] KVM: guest_memfd: Elaborate on how release() vs. get_pfn() is safe against UAF Sean Christopherson
2026-08-26 17:11 ` sashiko-bot
2026-08-26 18:39   ` Sean Christopherson [this message]
2026-09-20 12:55 ` Yan Zhao
2026-09-21 13:40   ` Sean Christopherson
2026-09-21 13:43     ` Sean Christopherson
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
2026-09-24 21:51 ` Sean Christopherson

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=ao8y6d5gMN1wG_C0@google.com \
    --to=seanjc@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.