Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp663388pxb; Tue, 5 Apr 2022 17:50:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGxp8jsERCk3IwyQB2d6cXC4eIP/ZUa///LbdGX+dn4gA6crSBV1l0+VpoC1HE4ekyHfCn X-Received: by 2002:a17:907:970e:b0:6df:9b6f:8a52 with SMTP id jg14-20020a170907970e00b006df9b6f8a52mr5891876ejc.761.1649206248286; Tue, 05 Apr 2022 17:50:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649206248; cv=none; d=google.com; s=arc-20160816; b=t5aVJGf3eXcutSTqc8Yz8UEw6d12O5jwKBJykcqGe98eUKyGqF5kUaI+3T5unOOzMC 8krHjNYjZ+G1Y2Q6nVoI39ffb1bO4UnwLq75nxlnfSN/uKDxpka3tAJTU+Xz1Jtz5lh9 ey+2+B7FlBtONthtgXdIxzg/GscLYD+XZ/Q7xrwcXabU/y81BlsvA3d00vFxH+SEKXlg 7/RNqbp45rMUDFn1ogIU+1H0HhE0a12N+aPShLhlPf3nr+KHOD6xMD8OkzCulYp6DGcv ltxb+Og0QnzZUXWr5EzU2ht2RrjoCbfi3ihaIf+d/O9/Bf+L7UETAvmR4zUncssXeelW gkgw== 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=sFl8mqxkjD0FV3GF+Zqd11e+pbZIIh9/CxH+BLJT4CE=; b=wXhfy7PPUDOcLTkomPTe+lMvo8fk602zDVF5bR6IBwqXNPe6qqbRrmIF9GpCOHb9WH Jl1W+Ll5eES1DpUJNwIxHjit0OKz4vA8IMxugR21Sn4V4fludEnVx5GVJHVKEuPabdfq /YQnb79eLKgMgOSFQzJmE5e4JjlGWFBPh9ZgnRd+iqXixXxKPWAaOuqXrIe7GyV/GGtE 2WAw1OsELPoXWqOU51DLanjUbXJff1VLsGz4QnI/vVCU5+Njno8byIZBW71Ig7CNolPf SIeRMzKWnQpf43lPee4swZX2GqePX8KlLW+rlRpsaf0F9vX92hulQRdfeJm9BYw49OR0 PwnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SeWwAxSb; 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 a13-20020a1709065f8d00b006df76385d87si7100269eju.551.2022.04.05.17.50.23; Tue, 05 Apr 2022 17:50:48 -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=SeWwAxSb; 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 S1390805AbiDENn3 (ORCPT + 99 others); Tue, 5 Apr 2022 09:43:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345932AbiDEJXL (ORCPT ); Tue, 5 Apr 2022 05:23:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10F85A774B; Tue, 5 Apr 2022 02:12:35 -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 9F59961654; Tue, 5 Apr 2022 09:12:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0577C385A2; Tue, 5 Apr 2022 09:12:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649149954; bh=cznyEpNzsTlaaxDVh7pqUaJlIdL/rp+lo6bpM9NMiN0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SeWwAxSbXQZqqJUl/W2nfjohwoCi/rLH8jEkYBoBpsbSQgSylfFoWPldUOHD4Ve6q uzZ/sFh2UVLt5Yn7G+gsYpxPUZDKhzJX1h2Cc4Utby5RGCnoFiZ7LTCGx1RWu+4B5B rCnJAC/De1UrqvuNjWgC5rKlSleTAlgKrHAfvDx4= 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 0901/1017] KVM: x86: Check lapic_in_kernel() before attempting to set a SynIC irq Date: Tue, 5 Apr 2022 09:30:14 +0200 Message-Id: <20220405070420.971150721@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 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: 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 @@ -446,6 +446,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;