From: Sean Christopherson <seanjc@google.com>
To: sashiko-reviews@lists.linux.dev
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 1/2] KVM: guest_memfd: Gracefully handle xarray errors when binding a memslot
Date: Wed, 26 Aug 2026 10:17:08 -0700 [thread overview]
Message-ID: <ao8flASJQeE8iMKz@google.com> (raw)
In-Reply-To: <20260826170506.012231F000E9@smtp.kernel.org>
On Wed, Aug 26, 2026, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> > diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c
> > --- a/virt/kvm/guest_memfd.c
> > +++ b/virt/kvm/guest_memfd.c
>
> [ ... ]
>
> > @@ -654,7 +658,7 @@ int kvm_gmem_bind(struct kvm *kvm, struct kvm_memory_slot *slot,
> > if (kvm_gmem_supports_mmap(inode))
> > slot->flags |= KVM_MEMSLOT_GMEM_ONLY;
> >
> > - xa_store_range(&f->bindings, start, end - 1, slot, GFP_KERNEL);
> > + xar = xa_store_range(&f->bindings, start, end - 1, slot, GFP_KERNEL);
> > filemap_invalidate_unlock(inode->i_mapping);
> >
> > /*
> > @@ -662,7 +666,12 @@ int kvm_gmem_bind(struct kvm *kvm, struct kvm_memory_slot *slot,
> > * not the other way 'round. Active bindings are invalidated if the
> > * file is closed before memslots are destroyed.
> > */
> > - r = 0;
> > + r = xa_is_err(xar) ? xa_err(xar) : 0;
> > + if (r) {
> > + slot->gmem.file = NULL;
> > + slot->gmem.pgoff = 0;
> > + slot->flags &= ~KVM_MEMSLOT_GMEM_ONLY;
> > + }
>
> [Severity: High]
> If xa_store_range() encounters an error halfway through the range (for
> example, -ENOMEM), can it partially succeed and leave some entries pointing
> to the memslot in the f->bindings xarray?
Something tells me this isn't idle curiosity... Assuming Sashiko is correct,
this as fixup?
diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c
index 1d2de9a1bc3f..323159c9b5f3 100644
--- a/virt/kvm/guest_memfd.c
+++ b/virt/kvm/guest_memfd.c
@@ -668,6 +668,7 @@ int kvm_gmem_bind(struct kvm *kvm, struct kvm_memory_slot *slot,
*/
r = xa_is_err(xar) ? xa_err(xar) : 0;
if (r) {
+ xa_store_range(&f->bindings, start, end - 1, NULL, GFP_KERNEL);
slot->gmem.file = NULL;
slot->gmem.pgoff = 0;
slot->flags &= ~KVM_MEMSLOT_GMEM_ONLY;
next prev parent reply other threads:[~2026-08-26 17:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 16:51 [PATCH 0/2] KVM: guest_memfd: Handle xarray binding errors Sean Christopherson
2026-08-26 16:51 ` [PATCH 1/2] KVM: guest_memfd: Gracefully handle xarray errors when binding a memslot Sean Christopherson
2026-08-26 17:05 ` sashiko-bot
2026-08-26 17:17 ` Sean Christopherson [this message]
2026-08-26 16:51 ` [PATCH 2/2] KVM: guest_memfd: Drop superfluous WRITE_ONCE() " Sean Christopherson
2026-08-26 17:05 ` sashiko-bot
2026-08-26 18:36 ` 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=ao8flASJQeE8iMKz@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox