From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27F81C52D2E for ; Thu, 27 Feb 2020 14:05:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E9E8A20578 for ; Thu, 27 Feb 2020 14:05:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582812336; bh=tv7oqiBsCZdrCegQgEvHRYMt6M59ibt4cgkGfQBEUjQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=nTODd9QWRubycQWwQXDK50J5W+KFRs+8VRpgUNuB0ugaqqzBQ5/oCaswJvyQ6g7Cl FLdherdWSreH8rQaVvAWA0+Qau5Qv4sUF7C4HJ/3mMQLIYgtfgks30hxzESzyvb3pc aPW10TpTTPencypkVYrROZ8KjQvTizqUltf/q/rw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730247AbgB0OFf (ORCPT ); Thu, 27 Feb 2020 09:05:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:42208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387777AbgB0OFa (ORCPT ); Thu, 27 Feb 2020 09:05:30 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9D8BE20578; Thu, 27 Feb 2020 14:05:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582812330; bh=tv7oqiBsCZdrCegQgEvHRYMt6M59ibt4cgkGfQBEUjQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MBYln0I8sbGSsWbJIBvWJ1qmfZV0SKmkSsv6voFrGfLhPMrMZ17bVP3QzVNi4m7Ch nd97zp8ZZ5TWjrJi6tA8edPn9fpbDqi2LyAruHjGwWLbkaFo8ah+i6LP5APz7iEunz g7g1uMb2hIquHSNUd79AATQceaLU3DFSysp+/k3k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vitaly Kuznetsov , Miaohe Lin , Paolo Bonzini Subject: [PATCH 4.19 74/97] KVM: apic: avoid calculating pending eoi from an uninitialized val Date: Thu, 27 Feb 2020 14:37:22 +0100 Message-Id: <20200227132226.570161039@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200227132214.553656188@linuxfoundation.org> References: <20200227132214.553656188@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miaohe Lin commit 23520b2def95205f132e167cf5b25c609975e959 upstream. When pv_eoi_get_user() fails, 'val' may remain uninitialized and the return value of pv_eoi_get_pending() becomes random. Fix the issue by initializing the variable. Reviewed-by: Vitaly Kuznetsov Signed-off-by: Miaohe Lin 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, 3 insertions(+), 1 deletion(-) --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -633,9 +633,11 @@ static inline bool pv_eoi_enabled(struct static bool pv_eoi_get_pending(struct kvm_vcpu *vcpu) { u8 val; - if (pv_eoi_get_user(vcpu, &val) < 0) + if (pv_eoi_get_user(vcpu, &val) < 0) { apic_debug("Can't read EOI MSR value: 0x%llx\n", (unsigned long long)vcpu->arch.pv_eoi.msr_val); + return false; + } return val & 0x1; }