Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp678700pxb; Tue, 5 Apr 2022 18:26:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwViRTva8sX+eeoQl2kuPpeRszXdBOWYxpfYPicUVFj0owF5cgairZFFESj1f7ZMkFZ0Lgg X-Received: by 2002:aa7:c401:0:b0:41c:c002:e6e6 with SMTP id j1-20020aa7c401000000b0041cc002e6e6mr6432343edq.347.1649208368169; Tue, 05 Apr 2022 18:26:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649208368; cv=none; d=google.com; s=arc-20160816; b=FFaLXYBDXnL4YVit94RbIP8QjNJG1LhAmmLN7+hMxwk4PQ/ssHYMHSLUprVZy9sgTh ztpEuLMP53GBrfPpa/cmlzLmZ6aOUt4CfqUlaR1glomwqWQ/62a7ARoxLH1Xf9lXcCl0 VycKK3IhocBHWwgplArCamLNuFnfj0hBD1KEJtdVW8YEJB+Oc8w+DCQSFH/t0mqH52Xj K1CS1cPuoyYzrAsbc43PkkDhlrNJbeRfiCOIH8u1FfJcVMuFiX/1ZTz87NjBtakJO87R 4d02WMFhwGqpnNlGkI6V1LibyyQsXF6WFBIDw3d0a/qKzbDZQgHcBXpUnj05Rn6AW68A 4u/Q== 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=BAs0XcO60FevjwFwJqj/Cr6n4PlR4Mq64FK1qM50y9Y=; b=dWI6O0O+87urk1YGUw0BL8JShmXk3iPB3YyvdHb/cjwgeENzolGuQY4QQ85/bosc8E yyD+e0KOHabOfSYor1CWY16wEYzKBqbkFdOjPoKXA3DwXkOJ6UA3nWpk1BMnD+73H4hY O3l06yTfXsaYF9UyxG4R/XNN192bO5zWxcLcXyq0VpT2Q27h72P5/hOoa6NYLaMmKi+o wqYuSXHc9KWBYh1J6QZfi4mJMj3S4XaSZFOEHC2wdvWwuFlI+6Igv6xaNxBAgF6Sziih W92HOV5LFCapvjklN0dEOAdJJrA8M/mltS3SQv/FZemJMdjjr66bMdCK+K3RvzK1mGrP UQoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HuEGp4V6; 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 q18-20020a170906145200b006df76385e3fsi10180987ejc.735.2022.04.05.18.25.43; Tue, 05 Apr 2022 18:26:08 -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=HuEGp4V6; 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 S1384919AbiDENco (ORCPT + 99 others); Tue, 5 Apr 2022 09:32:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345957AbiDEJXN (ORCPT ); Tue, 5 Apr 2022 05:23:13 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2C73A8EC1; Tue, 5 Apr 2022 02:12:39 -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 ams.source.kernel.org (Postfix) with ESMTPS id 23A78B81A12; Tue, 5 Apr 2022 09:12:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C968C385A2; Tue, 5 Apr 2022 09:12:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649149956; bh=KYthF1V1rwYdHB0aarjtYpgHgzauarKh6ljbQ558ZEI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HuEGp4V6VPhCz4duGkd4NuNJa00LiEH3E9nMm/WyICF2phHkeg678fM7TsCs+ltyx 23UMHbf0kaH9Ulzw0qV+eEl43NkUZrP3kMgTHLVk+qqxGl203ppLXwrQ+WpvpsEsOM D/OcgpB+yRzAtkWhzAB4Oherz/WIEyJCZnX100qU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vitaly Kuznetsov , Paolo Bonzini Subject: [PATCH 5.16 0902/1017] KVM: x86: Avoid theoretical NULL pointer dereference in kvm_irq_delivery_to_apic_fast() Date: Tue, 5 Apr 2022 09:30:15 +0200 Message-Id: <20220405070421.000501880@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@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.1 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,T_SCC_BODY_TEXT_LINE 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 commit 00b5f37189d24ac3ed46cb7f11742094778c46ce upstream. When kvm_irq_delivery_to_apic_fast() is called with APIC_DEST_SELF shorthand, 'src' must not be NULL. Crash the VM with KVM_BUG_ON() instead of crashing the host. Signed-off-by: Vitaly Kuznetsov Message-Id: <20220325132140.25650-3-vkuznets@redhat.com> Cc: stable@vger.kernel.org Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/lapic.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -987,6 +987,10 @@ bool kvm_irq_delivery_to_apic_fast(struc *r = -1; if (irq->shorthand == APIC_DEST_SELF) { + if (KVM_BUG_ON(!src, kvm)) { + *r = 0; + return true; + } *r = kvm_apic_set_irq(src->vcpu, irq, dest_map); return true; }