Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3468425rwa; Tue, 23 Aug 2022 05:23:08 -0700 (PDT) X-Google-Smtp-Source: AA6agR4irb3fVtCMt9Vk7S0aHbtCB3/FwJVKWYILDAIueOcQ0RtVbVioDFgEnBY4kdl0OvPX0opU X-Received: by 2002:a63:8a4b:0:b0:42a:5144:a44 with SMTP id y72-20020a638a4b000000b0042a51440a44mr14904739pgd.164.1661257388680; Tue, 23 Aug 2022 05:23:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661257388; cv=none; d=google.com; s=arc-20160816; b=HhKtCCnB8CU8v/z3KP6+BbIJA4AYcucrioK/nZRumFTK+/FLAr16L+yMmdPCbPUiFA jc9gkvhJ8HejHWz3+ultw3ybzjp3XcoRPWJiQpLPUs2NJDKreYmndLkKDIvS+24YMiPQ BIpy4vcpVnuCs6OkaHmPV5EDqd48TO2uP7T1kn20UxQA/CD5emMxRO7RZj74RDYQO4ov 6PURltOzcXItmfCJldefL/0sbTeK8VUSom4vedP6ogF6ufJQlzfLRDmJhBty6G2xuOwu DpoXTlKxjXJ9ZU0DPd1bnVC+9PwUdvKp++kZatxbjAbFT7+aIpsjM0ljHnqYRLsvIMGc fswA== 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=1b8FuQbkIiIszVwaV5qt5l1j2guP0jaQTeJTyRNI0qs=; b=SbvLUPQyVYpfNLU8C2hOHnbyVGdXHgfOy8/SL2B1VmFJiT2zAxjnN5m/8Dv6AP6vwx pBgzOpj/plNcOzPL3Zy0eVB1OljebVBiNNwq8ycgJdxrAwvL6MhOcdsWENT98NdiFUmE dks2K4MANA6AXWnUC8fxGXzKRicwv0P5zRsOCQrbsGGgSGj1/WHCoFdfZyQcUCd9sy/D Ud+Ttbj/QpLSDOIRquh3kJuQo8xuID2OHxpnk7zO/983jcMBY8k0wvB1hXvbftnmQjtC 9GS8wylTlEAn0tokskgAlvedOJ2VhJOFBZp7JcmzFyBw87qJojyeJB0ZdpC+kGlNqTx3 bZQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xqCNAfte; 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 cw1-20020a056a00450100b00536ee478380si2178165pfb.7.2022.08.23.05.22.56; Tue, 23 Aug 2022 05:23: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=xqCNAfte; 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 S1357030AbiHWKwy (ORCPT + 99 others); Tue, 23 Aug 2022 06:52:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354595AbiHWKpD (ORCPT ); Tue, 23 Aug 2022 06:45:03 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DABC6CD05; Tue, 23 Aug 2022 02:10:58 -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 C5C45B81C4E; Tue, 23 Aug 2022 09:10:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24129C433C1; Tue, 23 Aug 2022 09:10:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661245855; bh=T+cjKnqP5c+d0j/ipL7rhJOCgCi5Mifx3c2EKwNwMCE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xqCNAfteGwzA9T1PNnX6AW00S/me6gJTTbZkoqkGmTC6mP6QOqJpd2HBJIfrMNUNB EigsBFJChY9YgOb5xfi+vG8um7cmgpiJuVpdgmiv57BvynUWeZVviKm12wTZMr5pas 94TKcuXwi6wU1W8XkdqNInS9YMk4i5X6OoAxoRMI= 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 204/287] KVM: x86: Check lapic_in_kernel() before attempting to set a SynIC irq Date: Tue, 23 Aug 2022 10:26:13 +0200 Message-Id: <20220823080107.757910945@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 7ec37d1cbe17d8189d9562178d8b29167fe1c31a upstream When KVM_CAP_HYPERV_SYNIC{,2} is activated, KVM already checks for irqchip_in_kernel() so normally SynIC irqs should never be set. It is, however, possible for a misbehaving VMM to write to SYNIC/STIMER MSRs causing erroneous behavior. The immediate issue being fixed is that kvm_irq_delivery_to_apic() (kvm_irq_delivery_to_apic_fast()) crashes when called with 'irq.shorthand = APIC_DEST_SELF' and 'src == NULL'. Signed-off-by: Vitaly Kuznetsov Message-Id: <20220325132140.25650-2-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/hyperv.c | 3 +++ 1 file changed, 3 insertions(+) --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -341,6 +341,9 @@ static int synic_set_irq(struct kvm_vcpu struct kvm_lapic_irq irq; int ret, vector; + if (KVM_BUG_ON(!lapic_in_kernel(vcpu), vcpu->kvm)) + return -EINVAL; + if (sint >= ARRAY_SIZE(synic->sint)) return -EINVAL;