From: Sean Christopherson <seanjc@google.com>
To: sashiko-reviews@lists.linux.dev
Cc: Steffen Eiden <seiden@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
kvm@vger.kernel.org,
Christian Borntraeger <borntraeger@linux.ibm.vom>,
Vasily Gorbik <gor@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>,
linux-s390@vger.kernel.org
Subject: Re: [PATCH] vfio: Use file-based reference counting for KVM
Date: Wed, 12 Aug 2026 12:39:13 -0700 [thread overview]
Message-ID: <anzL4YiN7QozkrN9@google.com> (raw)
In-Reply-To: <20260812192319.BF41B1F000E9@smtp.kernel.org>
On Wed, Aug 12, 2026, sashiko-bot@kernel.org wrote:
> > diff --git a/arch/x86/kvm/mmu/page_track.c b/arch/x86/kvm/mmu/page_track.c
> > index 7e8195a311bb0..98f133e4f0b32 100644
> > --- a/arch/x86/kvm/mmu/page_track.c
> > +++ b/arch/x86/kvm/mmu/page_track.c
> > @@ -237,10 +237,11 @@ static int kvm_enable_external_write_tracking(struct kvm *kvm)
>
> [Severity: High]
> This is a pre-existing issue, but does kvm_enable_external_write_tracking()
> need to hold srcu_read_lock(&kvm->srcu) when iterating over the memslots
> array?
>
> Looking at the function, it retrieves and iterates over the memslots array
> while only holding the slots_arch_lock mutex:
>
> mutex_lock(&kvm->slots_arch_lock);
> ...
> for (i = 0; i < kvm_arch_nr_memslot_as_ids(kvm); i++) {
> slots = __kvm_memslots(kvm, i);
> kvm_for_each_memslot(slot, bkt, slots) {
> r = kvm_page_track_write_tracking_alloc(slot);
> if (r)
> goto out_unlock;
> }
> }
>
> Without holding srcu_read_lock(&kvm->srcu) or the writer-side slots_lock,
> could a concurrent memslot update swap and free the memslots array while
> the loop is traversing it, causing a use-after-free?
No, because the part of kvm_swap_active_memslots() that performs the actual swap
runs with slots_arch_lock held.
prev parent reply other threads:[~2026-08-12 19:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-12 18:55 [PATCH] vfio: Use file-based reference counting for KVM Steffen Eiden
2026-08-12 19:23 ` sashiko-bot
2026-08-12 19:39 ` Sean Christopherson [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=anzL4YiN7QozkrN9@google.com \
--to=seanjc@google.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.vom \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=seiden@linux.ibm.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