Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4373440imw; Tue, 19 Jul 2022 05:34:11 -0700 (PDT) X-Google-Smtp-Source: AGRyM1un8614N2C6avBmeoYD3PlWlEjsKJIGoOHzEZAf0XD6JwcOZ4quC1qLoOCKNrG1l167IhPu X-Received: by 2002:a17:907:2ccc:b0:72b:6907:fce6 with SMTP id hg12-20020a1709072ccc00b0072b6907fce6mr30298696ejc.115.1658234051707; Tue, 19 Jul 2022 05:34:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658234051; cv=none; d=google.com; s=arc-20160816; b=CDl4mmmBzW2OKfU09PiCzAlYSXkaM1ohPS4Oqc/61iW2PomI8SiHhYynpeqlf0ikmE FFhUMW3sq5TKta99mIzrT2OC8syt0+7eA1ilmNbqdaM1lfTA8DXr8O/Xtn1rzpui4pc6 RvR5GuocjnIFk8jr0hAI/52zpQsCg560JfAO//AfAoPhv/rOsz+VugKUm9O5z9A4zmvc EHS6WdhVUT66bVHQYja0S1jzruzgTVMPBHN1YyTBBRN/BZHoRCJXrJeP4JTXUaqzdmht QJcWiUu2g2/tAujUlG+sOmevwjA2wlHlrkrFrVQMlAO7NpdQf5rYw3sJLUi0kFqWI4Dl rROA== 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=/2rc55QA9WxrvrisxrNaVIIoTuZZghS40pD48Gizzns=; b=xnochuoGToLcyeF/jp4a8wbKHxRArfEV5P71W2Yhsssi6ZkZNowD4lVMNYgDrQXbJy W4orKzfajQYKYm2811eAMYg0hItlmjJqljmwxvFIKnTQNiESfLoIAEDK4qg8/RjuOcLO 6QXb01dtSbWzYwyP/1iNyhhhfmockvXSS5v6bvkviLqOmQANp7ZpB3BGZsz8Kn+/ua9t cEx7F+fgDa4FGgFChWCDyWtZ1gCfIS8tCmLWv8WvHw9YvbPwYDUoqzE25WZL1ty3LSne cguaQ5EMPHBoTyJLIFNn+NUdawbRxhelwLEJGtVX9S7FoRCEVtYaoCf96Aqk00lGQQn2 0vyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NNs258Ad; 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 di22-20020a170906731600b00726bea57aacsi16518469ejc.716.2022.07.19.05.33.45; Tue, 19 Jul 2022 05:34:11 -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=NNs258Ad; 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 S237973AbiGSMY5 (ORCPT + 99 others); Tue, 19 Jul 2022 08:24:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239579AbiGSMXo (ORCPT ); Tue, 19 Jul 2022 08:23:44 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72E7C4F66E; Tue, 19 Jul 2022 05:08:47 -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 sin.source.kernel.org (Postfix) with ESMTPS id AF7EDCE1BE5; Tue, 19 Jul 2022 12:08:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF4B4C341C6; Tue, 19 Jul 2022 12:08:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232485; bh=cgi4QBxYoFAxqmZ5tuqyrbT7QX+IIZ4oBUA/TsSEn3I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NNs258AdlIdsgCPf3V3QNb2Y5TtsZTEUSWttPR+MPoyUmOBQ0UBPfubYXGLcu3S2o 7QebLfAyQq0STfoeurmnOjPKyJ1YCnQtUheZOoZTtwV6JZP9vr6nJeuwLE3HYErzVS BIjMPHl0OkhrZL215HQHQHsKMvReVdsVHDdzGtV8= 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.10 074/112] KVM: x86: Fully initialize struct kvm_lapic_irq in kvm_pv_kick_cpu_op() Date: Tue, 19 Jul 2022 13:54:07 +0200 Message-Id: <20220719114633.660941761@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114626.156073229@linuxfoundation.org> References: <20220719114626.156073229@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 da547752580a..c71f702c037d 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -8142,15 +8142,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