From: sashiko-bot@kernel.org
To: "Tim Wiederhake" <twiederh@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 3/4] KVM: x86: Reject KVM_CREATE_IRQCHIP if APIC base is already mapped
Date: Mon, 06 Jul 2026 09:40:36 +0000 [thread overview]
Message-ID: <20260706094037.104AA1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260706092021.3625908-5-twiederh@redhat.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Calling `gfn_to_memslot()` in `KVM_CREATE_IRQCHIP` without holding the SRCU read lock (`kvm->srcu`) or the memslots update lock (`kvm->slots_lock`) leads to a Use-After-Free and triggers a lockdep warning.
--
commit 69e98e42c78858b7858a1956e233c569faf47ae1
Author: Tim Wiederhake <twiederh@redhat.com>
KVM: x86: Reject KVM_CREATE_IRQCHIP if APIC base is already mapped
User space must not map guest memory that covers the default APIC base
address when using an in-kernel irqchip. This commit adds an explicit
check to KVM_CREATE_IRQCHIP so the conflict is reported at the point
where the constraint takes effect.
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
[ ... ]
> @@ -4413,6 +4413,10 @@ int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)
> if (kvm->created_vcpus)
> goto create_irqchip_unlock;
>
> + r = -EEXIST;
> + if (gfn_to_memslot(kvm, gpa_to_gfn(APIC_DEFAULT_PHYS_BASE)))
> + goto create_irqchip_unlock;
> +
[Severity: High]
Is it safe to call gfn_to_memslot() in this KVM_CREATE_IRQCHIP path without
holding the kvm->srcu read lock?
Looking at kvm_arch_vm_ioctl() in arch/x86/kvm/x86.c, only kvm->lock is
held when KVM_CREATE_IRQCHIP is executed.
If another thread concurrently calls KVM_SET_USER_MEMORY_REGION, it replaces
the memslots array under kvm->slots_lock and calls synchronize_srcu().
Because KVM_CREATE_IRQCHIP does not take srcu_read_lock(),
synchronize_srcu() won't wait for it.
Could this traversal of the memslots array in gfn_to_memslot() encounter a
freed array and result in a use-after-free, as well as a suspicious RCU usage
lockdep warning?
> r = kvm_pic_init(kvm);
> if (r)
> goto create_irqchip_unlock;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706092021.3625908-2-twiederh@redhat.com?part=3
next prev parent reply other threads:[~2026-07-06 9:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 9:20 [PATCH 0/4] KVM: x86: Document and enforce APIC base memory hole Tim Wiederhake
2026-07-06 9:20 ` [PATCH 1/4] KVM: x86: Document that KVM_CREATE_IRQCHIP must precede vcpu creation Tim Wiederhake
2026-07-06 23:22 ` Sean Christopherson
2026-07-06 9:20 ` [PATCH 2/4] KVM: x86: Document APIC base address constraint for in-kernel irqchip Tim Wiederhake
2026-07-06 23:32 ` Sean Christopherson
2026-07-06 9:20 ` [PATCH 3/4] KVM: x86: Reject KVM_CREATE_IRQCHIP if APIC base is already mapped Tim Wiederhake
2026-07-06 9:40 ` sashiko-bot [this message]
2026-07-06 22:26 ` Sean Christopherson
2026-07-06 9:20 ` [PATCH 4/4] KVM: x86: Reject user memory regions covering the APIC base Tim Wiederhake
2026-07-06 10:00 ` sashiko-bot
2026-07-06 15:21 ` [syzbot ci] Re: KVM: x86: Document and enforce APIC base memory hole syzbot ci
2026-07-06 22:26 ` [PATCH 0/4] " 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=20260706094037.104AA1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=twiederh@redhat.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 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.