From: sashiko-bot@kernel.org
To: "Zeng Chi" <zeng_chi911@163.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH] LoongArch: KVM: Validate MSI data before routing it to EIOINTC
Date: Fri, 28 Aug 2026 10:02:04 +0000 [thread overview]
Message-ID: <20260828100204.CC38D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260828093604.56622-1-zeng_chi911@163.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Preexisting NULL pointer dereference in pch_pic_update_irq() when EIOINTC is not instantiated.
--
commit 2e412c04f647995bc67015a157c68cab104e2514
Author: Zeng Chi <zengchi@kylinos.cn>
LoongArch: KVM: Validate MSI data before routing it to EIOINTC
pch_msi_set_irq() passes e->msi.data straight into eiointc_set_irq() as
the irq number. The MSI data comes from userspace and is never checked
against EIOINTC_IRQS, which can corrupt kernel memory. This patch
rejects MSI data that doesn't fit in the EIOINTC irq space.
> diff --git a/arch/loongarch/kvm/intc/pch_pic.c b/arch/loongarch/kvm/intc/pch_pic.c
> index e7b77705c516a..81fb534ce8dd5 100644
> --- a/arch/loongarch/kvm/intc/pch_pic.c
> +++ b/arch/loongarch/kvm/intc/pch_pic.c
> @@ -78,6 +78,9 @@ int pch_msi_set_irq(struct kvm *kvm, struct kvm_kernel_irq_routing_entry *e, int
> return dmsintc_set_irq(kvm, msg_addr, e->msi.data, level);
> }
>
> + if (e->msi.data >= EIOINTC_IRQS)
> + return -EINVAL;
> +
> eiointc_set_irq(kvm->arch.eiointc, e->msi.data, level);
[Severity: Critical]
This isn't a bug introduced by this patch, but is it possible for
s->kvm->arch.eiointc to be unconditionally dereferenced as a NULL pointer
in pch_pic_update_irq() when the EIOINTC device is not instantiated?
A KVM userspace process can create a KVM_DEV_TYPE_LOONGARCH_PCHPIC device
via ioctl without creating the KVM_DEV_TYPE_LOONGARCH_EIOINTC device.
If the process pre-populates the irr (Interrupt Request Register) of the
PCHPIC device using the KVM_SET_DEVICE_ATTR ioctl, and then runs a guest
VCPU to perform an MMIO write to PCH_PIC_MASK_START to unmask the pending
interrupt, it bypasses standard KVM IRQ injection checks.
This results in the following path:
loongarch_pch_pic_write() -> pch_pic_update_batch_irqs() -> pch_pic_update_irq()
arch/loongarch/kvm/intc/pch_pic.c:pch_pic_update_irq() {
...
if (level) {
if (mask & s->irr & ~s->mask) {
s->isr |= mask;
irq = s->htmsi_vector[irq];
eiointc_set_irq(s->kvm->arch.eiointc, irq, level);
...
}
Because EIOINTC was never created, the pointer is NULL. Because
eiointc_set_irq() unconditionally dereferences it via s->isr, can this
malicious guest action trigger an immediate host kernel panic?
>
> return 0;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260828093604.56622-1-zeng_chi911@163.com?part=1
prev parent reply other threads:[~2026-08-28 10:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-28 9:36 [PATCH] LoongArch: KVM: Validate MSI data before routing it to EIOINTC Zeng Chi
2026-08-28 10:02 ` sashiko-bot [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=20260828100204.CC38D1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=zeng_chi911@163.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.