Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3407729rwa; Tue, 23 Aug 2022 04:23:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR7AwFsOJHGw1T629JDN7oWIHp9CIRyjzmcR4YY+mjbZ0xmRrIa1QW8Hf0AmdXJGo3QYoCa5 X-Received: by 2002:a05:6a00:1251:b0:536:b942:35d8 with SMTP id u17-20020a056a00125100b00536b94235d8mr7673884pfi.5.1661253808959; Tue, 23 Aug 2022 04:23:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253808; cv=none; d=google.com; s=arc-20160816; b=UCcxIHR7AawAzrtkqDd8THL0fKIZfWdH+kq9UUFVNAgcVvko16RQtadD06zxh5cpWq 89z+f5yHqMQaWU2iTpnizc53zoYPN4Gk9J8gCG2JKYcVLAtxbN5LAAjzU71Apf3rdALl 0gOZWtubJ8si7Wv6lnqrnTbMRE9K0x3Ov9EGxXpZd9bzJsbZ8hVYIw47f2ztdaN+CKau 9PnO5tVhbtTZm/gmSL49OLF7ve+syNPkUSDRUKoKyyWomMNsqiFU3+Zn3+o1Ir7C5tQS P6r8K7s3ujzIyTRiHS1X1peFh1SwWfooL2zvaVC49FaBb7RA2Q3V5D/OoWarKLNOIbQC kmJQ== 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=P02ArICO9OUd69YsLrkSpIxF3iLyBoOU5F7JUvFiD2U=; b=MMj1kysR/rdiESromXT+HU4CE/k7sTPltq4yzKZEuMHT1TIVsLBsl8MnKgEuFxfgNL rNwQKSec+FbQ7KfymAxbRkSAM+fnWf2ArD9lVLaQpavWBP+7nCMEQbfpvl2Nr57GjXKJ RnZSYa97Vyux3AQPe1017cU6W4kZ3gJYymmbzGvxG4xACNRdQzFo611P1/ZPxL93qwsF ZPNQwfUoA6LOsxRaUQw8SyUZtjMVcBBNTYLlo6jbBZczSiA1DPYwUet7+XPKUHBZMJ/c S42uaqxGtMEtkPe7HAoeZ/xCnrsKsRbuxqgJ1NhfSzyJOCN50sxv8dpntwz6ux1rydrR Yv0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XiY8tuiy; 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 m6-20020a654386000000b0042971e401e3si16178042pgp.307.2022.08.23.04.23.15; Tue, 23 Aug 2022 04:23:28 -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=XiY8tuiy; 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 S1356307AbiHWKyF (ORCPT + 99 others); Tue, 23 Aug 2022 06:54:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355971AbiHWKqE (ORCPT ); Tue, 23 Aug 2022 06:46:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D82374CFE; Tue, 23 Aug 2022 02:11:32 -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 5A5D86069D; Tue, 23 Aug 2022 09:11:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E584C433D6; Tue, 23 Aug 2022 09:11:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661245890; bh=9nPrtpR65w8b56LwHzABe1G5wYv2w6YiwZOjMphzI00=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XiY8tuiyZDvt+3eQafZzh1rEa4gCV7BG5hOnleA8Y0ZeZp2Ic3HZP+KADFWDq2J7V ByrTK758H0hR7rFQKrIu+IBw5r+TUdxZbrE8I+1JQvN9rAMQU9KNXVDMKmyZdH8Fz8 kFIxpbEbjEyQi11phyXYvnygHeUH/seI8cvz8kN8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Vitaly Kuznetsov , Paolo Bonzini , Stefan Ghinea Subject: [PATCH 4.19 205/287] KVM: x86: Avoid theoretical NULL pointer dereference in kvm_irq_delivery_to_apic_fast() Date: Tue, 23 Aug 2022 10:26:14 +0200 Message-Id: <20220823080107.801921160@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080100.268827165@linuxfoundation.org> References: <20220823080100.268827165@linuxfoundation.org> User-Agent: quilt/0.67 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: Stefan Ghinea 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 @@ -961,6 +961,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; }