Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4478622imw; Tue, 19 Jul 2022 07:22:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t40Ssxawh5RPcDvOu/sqsOeZ2Hpk3iKruKA9GS1Xx+DUNNidAUvieuZgC9VvwbaRZ7Fptr X-Received: by 2002:a17:907:8a16:b0:72b:9196:f029 with SMTP id sc22-20020a1709078a1600b0072b9196f029mr31495149ejc.359.1658240525936; Tue, 19 Jul 2022 07:22:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658240525; cv=none; d=google.com; s=arc-20160816; b=0JmZ8RnsXCAl2Y0xGPbRpQx+JsKwc3EkBL+7Z+C3j+YWk9YCW+E//+V2YVZaQHMJnS OBlZ+ZzrEL74GfLVN9PMe3NjiHULCts5U4qqqyU86EOS2aiIpZqIBZiMyrya5FJFrhKM O/zlOfd/ObO2srmxzjSWVHM17gn9bYIMyphdsWbwJvZnJjeCky80NOS9O6AaZFH4ND7f 2xyZM2MBGEKH2rmAzo14qWtV4b/vprjOEzYCTL94Abyi1nMPvoDo5GrAFJmcovu4/X8Z gI+0xqjFncfZ6ghvM/I4M3VAWo2L+OpoYZ5YaPGgiVUzU0X2Qd5vF/goX5TVgE3sYRD1 R0Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bEm1dggsC9kpvWvXxsn3B/hrPDKbPm/9Ygv6XUOezOk=; b=GXUqE2HFcYzpI58FBQKdjsDBHm9fzSb06lrFCain1IWTKmCJO53IfxTlJISsE/GJzb VHWIlCV6TX2499aU3V0bOwmiB3CVQVzhiTn0lOb5Caf5OmQwfH27sOXKCw1zp0McupcE WW3VeyAB0c0z/dJkynEdE14+k5JEI+6SV2Bx+zC57geZ95D5/ZejYdthrnaD9XRV3RN+ Vd8ebxzphiflkP2ca1lBMetpvYNcDMtFqVeE4mpCOXpiW2B2IeMZTQx4/VpoxtKRXXxs FOeHKirAgXJreFecCU5Yb+QJrWQCZOgUB7z2WvETnf3eItmWTKmYZyHGu7gR4xhiRJc3 MbSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=u+cDasTG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r23-20020a170906549700b0072b3a923e6csi16617234ejo.974.2022.07.19.07.21.41; Tue, 19 Jul 2022 07:22:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=u+cDasTG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241191AbiGSMkR (ORCPT + 99 others); Tue, 19 Jul 2022 08:40:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240946AbiGSMi2 (ORCPT ); Tue, 19 Jul 2022 08:38:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0B8DF24; Tue, 19 Jul 2022 05:15:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A315F61632; Tue, 19 Jul 2022 12:15:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86D85C341CB; Tue, 19 Jul 2022 12:15:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232907; bh=WRZFURQp2P4iWzJqKxN+UbfLRSjqwOhOH+3mdvRdMQM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u+cDasTGC8UjB+a5Rht1Ikdbe3bqhrhHAWutiXjno85Q6usYEFaiRcOYFupwHezcW bRZluCbjVdpWB5XA1V0+yhsNDBHcdtHHn0NGV7DQ/9NwnpPcFaNNkOBqLMc/Mrjpcr AzJIY50+udAwPtbM40JgKFL/9fWXNscw54gpiWTU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+d6caa905917d353f0d07@syzkaller.appspotmail.com, Vitaly Kuznetsov , Sean Christopherson , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.15 107/167] KVM: x86: Fully initialize struct kvm_lapic_irq in kvm_pv_kick_cpu_op() Date: Tue, 19 Jul 2022 13:53:59 +0200 Message-Id: <20220719114706.816459660@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114656.750574879@linuxfoundation.org> References: <20220719114656.750574879@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vitaly Kuznetsov [ Upstream commit 8a414f943f8b5f94bbaafdec863d6f3dbef33f8a ] '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: a183b638b61c ("KVM: x86: make apic_accept_irq tracepoint more generic") Reported-by: syzbot+d6caa905917d353f0d07@syzkaller.appspotmail.com Signed-off-by: Vitaly Kuznetsov Reviewed-by: Sean Christopherson Message-Id: <20220708125147.593975-1-vkuznets@redhat.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- arch/x86/kvm/x86.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 8974884ef2ad..732c3f2f8ded 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -8713,15 +8713,17 @@ static int kvm_pv_clock_pairing(struct kvm_vcpu *vcpu, gpa_t paddr, */ static void kvm_pv_kick_cpu_op(struct kvm *kvm, unsigned long flags, int apicid) { - struct kvm_lapic_irq lapic_irq; - - lapic_irq.shorthand = APIC_DEST_NOSHORT; - lapic_irq.dest_mode = APIC_DEST_PHYSICAL; - lapic_irq.level = 0; - lapic_irq.dest_id = apicid; - lapic_irq.msi_redir_hint = false; + /* + * All other fields are unused for APIC_DM_REMRD, but may be consumed by + * common code, e.g. for tracing. Defer initialization to the compiler. + */ + struct kvm_lapic_irq lapic_irq = { + .delivery_mode = APIC_DM_REMRD, + .dest_mode = APIC_DEST_PHYSICAL, + .shorthand = APIC_DEST_NOSHORT, + .dest_id = apicid, + }; - lapic_irq.delivery_mode = APIC_DM_REMRD; kvm_irq_delivery_to_apic(kvm, NULL, &lapic_irq, NULL); } -- 2.35.1