Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3464747rwa; Tue, 23 Aug 2022 05:19:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR4AvCRhhgS//IlUkG8vY+jzzQP4HyxBkeFebpuzdj8wf6AKzI3bmzlqc7KALtwtgEkt8yAr X-Received: by 2002:a63:5f17:0:b0:427:8dbf:52b8 with SMTP id t23-20020a635f17000000b004278dbf52b8mr19857019pgb.64.1661257175456; Tue, 23 Aug 2022 05:19:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661257175; cv=none; d=google.com; s=arc-20160816; b=Z6RLAV5YVtZVJURLusG1I0xbN66l8K2spGgwHoqDy3RoDUJPPsovedMzrBzcjls4W/ tBXEVPVAW0J6kLm3RGjvV7BksTBCS0JCm4E0rE7h3n80YHbHRIR/GkvttZy1k2CG8Pih rIMfn2bt5TXZ1uySF2w/53vynJS0d8Fpg24OJNg1YcTajXz4vj7OBW2EAueru2gm0M3l NgWL7QFKoAKxRUD7ccBXDL8BISKC0KenP++l3AB0NlpYtsdmLjvb35KX/SThD7Ai9te5 pWt0NKEpVteztlZ81uxoXJFeWKxOffBA9ED2qwUW5myJTBLspNqRxJcWiq0YHAfUkzCQ wZvw== 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=WP0Lbu7RVrb6OaDlNt39dd78EcNH9Ez/buO5o+aVl1g=; b=0BaOU5ojnhsOKt1oH7tOGLLpmL/x7XWHeTBb16hYgNaSpK32W5iXb1INq62ZtmHfUq 502KgvrBWEZQt1Of7sFuaUS8tTQrPxdx2TafukjvzRqSG9REhcZAIOWUIpEqvqJ3MvmO I0kC93fU1AB8AI0kKVAMEVDShpslCfl62uG7ooerzIgalKOuWon89Bo4NCjJwz1/p2Dh sygQKkIU2iejc698hvoX2sOsB5OByWcgJ73J33dm3Q552kIxlLRscQ75UwUrUb35pFBq 91vI0R2LSho691JJpwk8usQLds/dDMQ4sH+zYA9uI+jAqK4jPz6bkTF3CiP2R7tjr/0U C/Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=blqU+WJE; 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 n8-20020a170902e54800b0016fa785c045si16217490plf.288.2022.08.23.05.19.24; Tue, 23 Aug 2022 05:19:35 -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=blqU+WJE; 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 S1352735AbiHWKKD (ORCPT + 99 others); Tue, 23 Aug 2022 06:10:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352733AbiHWKC0 (ORCPT ); Tue, 23 Aug 2022 06:02:26 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 716CF7C52E; Tue, 23 Aug 2022 01:50:41 -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 C6C34B8105C; Tue, 23 Aug 2022 08:50:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C41CC433D6; Tue, 23 Aug 2022 08:50:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244638; bh=hEUNJb7IAicBZVfgahbqM6ydvks3bcoQGC/znlVEVbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=blqU+WJEeTRoc+wRKaC3rGKTfq243USOROI3zycNs5NcT0eFL7yMIu6rz+dCrbXeX KtA+ZUdrojxer0kNvG+vKB4L47S16h8PbqxH5p30mDlQU03Ca3ay+wyV8EjFNfxLcn q2/4+Bv9pD+TxRR+bOzWCp+Z0cV0YAq3FWFGwEhg= 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.14 168/229] KVM: x86: Avoid theoretical NULL pointer dereference in kvm_irq_delivery_to_apic_fast() Date: Tue, 23 Aug 2022 10:25:29 +0200 Message-Id: <20220823080059.653148604@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080053.202747790@linuxfoundation.org> References: <20220823080053.202747790@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 @@ -894,6 +894,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; }