mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] LoongArch: KVM: Fix uninitialized stack read in dmsintc_inject_irq()
@ 2026-11-17  2:03 Daolong Zhang
  2026-11-17  2:24 ` Tao Cui
  0 siblings, 1 reply; 2+ messages in thread
From: Daolong Zhang @ 2026-11-17  2:03 UTC (permalink / raw)
  To: Tianrui Zhao, Bibo Mao, Huacai Chen
  Cc: WANG Xuerui, Song Gao, kvm, loongarch, linux-kernel, Daolong Zhang

In dmsintc_inject_irq(), the local array 'vector[4]' is declared on the
stack without initialization, and each element 'vector[i]' is only
assigned when atomic64_read(&ds->vector_map[i]) is non-zero.

Whenever any of the four 64-bit words in ds->vector_map[] is zero (for
example, when an MSI interrupt targets a single word, or when INT_AVEC
is injected via KVM_INTERRUPT with an empty vector_map), the remaining
elements of 'vector[]' retain uninitialized kernel stack contents. The
subsequent checks on vector[0..3] then OR those uninitialized stack
values into the guest's hardware LOONGARCH_CSR_ISR0..3 registers,
injecting spurious interrupt vectors into the guest and leaking host
kernel stack data into guest-visible CSRs.

Zero-initialize 'vector[4]' on declaration to prevent reading
uninitialized stack memory.

Fixes: 03de5eecb0f0 ("LoongArch: KVM: Add DMSINTC inject msi to vCPU")
Signed-off-by: Daolong Zhang <dlzhangak@isoftstone.com>
---
 arch/loongarch/kvm/intc/dmsintc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/loongarch/kvm/intc/dmsintc.c b/arch/loongarch/kvm/intc/dmsintc.c
index de25735ce039..ef6c064e52f1 100644
--- a/arch/loongarch/kvm/intc/dmsintc.c
+++ b/arch/loongarch/kvm/intc/dmsintc.c
@@ -11,7 +11,7 @@
 void dmsintc_inject_irq(struct kvm_vcpu *vcpu)
 {
 	unsigned int i;
-	unsigned long vector[4], old;
+	unsigned long vector[4] = {}, old;
 	struct dmsintc_state *ds = &vcpu->arch.dmsintc_state;
 
 	if (!ds)
-- 
2.48.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-17  2:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17  2:03 [PATCH] LoongArch: KVM: Fix uninitialized stack read in dmsintc_inject_irq() Daolong Zhang
2026-11-17  2:24 ` Tao Cui

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®