Skip to content

Commit 8a414f9

Browse files
vittyvkbonzini
authored andcommitted
KVM: x86: Fully initialize 'struct kvm_lapic_irq' in kvm_pv_kick_cpu_op()
'vector' and 'trig_mode' fields of 'struct kvm_lapic_irq' are left uninitialized in kvm_pv_kick_cpu_op(). While these fields are normally not needed for APIC_DM_REMRD, they're still referenced by __apic_accept_irq() for trace_kvm_apic_accept_irq(). Fully initialize the structure to avoid consuming random stack memory. Fixes: a183b63 ("KVM: x86: make apic_accept_irq tracepoint more generic") Reported-by: [email protected] Signed-off-by: Vitaly Kuznetsov <[email protected]> Reviewed-by: Sean Christopherson <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent cca3f33 commit 8a414f9

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

arch/x86/kvm/x86.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9143,15 +9143,17 @@ static int kvm_pv_clock_pairing(struct kvm_vcpu *vcpu, gpa_t paddr,
91439143
*/
91449144
static void kvm_pv_kick_cpu_op(struct kvm *kvm, int apicid)
91459145
{
9146-
struct kvm_lapic_irq lapic_irq;
9147-
9148-
lapic_irq.shorthand = APIC_DEST_NOSHORT;
9149-
lapic_irq.dest_mode = APIC_DEST_PHYSICAL;
9150-
lapic_irq.level = 0;
9151-
lapic_irq.dest_id = apicid;
9152-
lapic_irq.msi_redir_hint = false;
9146+
/*
9147+
* All other fields are unused for APIC_DM_REMRD, but may be consumed by
9148+
* common code, e.g. for tracing. Defer initialization to the compiler.
9149+
*/
9150+
struct kvm_lapic_irq lapic_irq = {
9151+
.delivery_mode = APIC_DM_REMRD,
9152+
.dest_mode = APIC_DEST_PHYSICAL,
9153+
.shorthand = APIC_DEST_NOSHORT,
9154+
.dest_id = apicid,
9155+
};
91539156

9154-
lapic_irq.delivery_mode = APIC_DM_REMRD;
91559157
kvm_irq_delivery_to_apic(kvm, NULL, &lapic_irq, NULL);
91569158
}
91579159

0 commit comments

Comments
 (0)