From: sashiko-bot@kernel.org
To: "Bibo Mao" <maobibo@loongson.cn>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v4 3/4] LoongArch: KVM: Return directly when IPI address is not aligned
Date: Thu, 09 Jul 2026 08:44:07 +0000 [thread overview]
Message-ID: <20260709084407.DD00A1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260709082109.1361767-4-maobibo@loongson.cn>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] The early return path for unaligned accesses in `loongarch_ipi_readl` fails to populate the `val` output parameter, leaking stale data to the guest.
Pre-existing issues:
- [Critical] A malicious guest can trigger a host kernel panic by performing an unaligned MMIO access to the MIPS KVM IPI region.
--
--- Patch [3]: [PATCH v4 3/4] LoongArch: KVM: Return directly when IPI address is not aligned ---
commit 8225fc6b95e2b4712a3ffe27c14012171a25b47b
Author: Bibo Mao <maobibo@loongson.cn>
LoongArch: KVM: Return directly when IPI address is not aligned
This patch modifies KVM on LoongArch to return directly from IPI read and
write operations when the address is unaligned, rather than just printing a
warning.
> diff --git a/arch/loongarch/kvm/intc/ipi.c b/arch/loongarch/kvm/intc/ipi.c
> index bccdfd963e5b5..8ec40e09c5abb 100644
> --- a/arch/loongarch/kvm/intc/ipi.c
> +++ b/arch/loongarch/kvm/intc/ipi.c
> @@ -181,9 +181,12 @@ static int loongarch_ipi_readl(struct kvm_vcpu *vcpu, gpa_t addr, int len, void
> uint32_t offset;
> uint64_t res = 0;
>
> - offset = (uint32_t)(addr & 0x1ff);
> - WARN_ON_ONCE(offset & (len - 1));
> + if (addr & (len - 1)) {
> + kvm_pr_unimpl("%s: ipi not aligned addr %llx len %d\n", __func__, addr, len);
> + return 0;
> + }
[Severity: High]
Does this early return path in loongarch_ipi_readl() need to populate the val
output parameter before returning success (0)?
If a guest performs an unaligned read, kvm_io_bus_read() will see a successful
return, but val remains unmodified. Could this lead to stale data from
previous VM exits being copied into the guest's registers?
[ ... ]
[Severity: Critical]
This is a pre-existing issue and was not introduced by this patch, but while
reviewing unaligned IPI access handling, a guest-triggerable BUG_ON() was
noticed in the MIPS loongson_vipi_read() and loongson_vipi_write() paths:
arch/mips/kvm/loongson_ipi.c:loongson_vipi_read() {
...
BUG_ON(offset & (len - 1));
...
}
Could a malicious guest trigger a host kernel panic by performing an unaligned
MMIO read or write targeting the loongson_ipi region?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260709082109.1361767-1-maobibo@loongson.cn?part=3
next prev parent reply other threads:[~2026-07-09 8:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-09 8:21 [PATCH v4 0/4] LoongArch: KVM: Harden interrupt injection Bibo Mao
2026-07-09 8:21 ` [PATCH v4 1/4] LoongArch: KVM: Set default MAILBOX access size with 8 Bibo Mao
2026-07-09 8:41 ` sashiko-bot
2026-07-09 8:21 ` [PATCH v4 2/4] LoongArch: KVM: Replace kvm_err() with kvm_pr_unimpl() Bibo Mao
2026-07-09 8:21 ` [PATCH v4 3/4] LoongArch: KVM: Return directly when IPI address is not aligned Bibo Mao
2026-07-09 8:44 ` sashiko-bot [this message]
2026-07-09 8:21 ` [PATCH v4 4/4] LoongArch: KVM: Use internal API to deliver interrupt in kernel mode Bibo Mao
2026-07-09 8:38 ` sashiko-bot
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=20260709084407.DD00A1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=maobibo@loongson.cn \
--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