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 --- 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