From patchwork Thu Feb 27 13:37:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 230304 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 2FB7EC4BA2D for ; Thu, 27 Feb 2020 14:26:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ED2F121D7E for ; Thu, 27 Feb 2020 14:26:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582813569; bh=5bD7RjzDBM4Cn3X4m5cxlyQ8eVsypFN/FZmInh4myb8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=cqSYlxNR31+YZBMkBgqSo7WX0pd5VSIwxc0mY5WKUrnZIkCuBFvKFqbBW+96gSuJ3 0fIXPjTDJUirbhHYFj5DIJnE706bOhCUW5AUQZpuBdNVgL9Iw8y0vGwIJ+dtz0r+zR gdJluYncnRt9P9TOOfcXcEipoYgBnUwJwP9/Hgeo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388555AbgB0OKc (ORCPT ); Thu, 27 Feb 2020 09:10:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:48740 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388553AbgB0OKc (ORCPT ); Thu, 27 Feb 2020 09:10:32 -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 AE43C20801; Thu, 27 Feb 2020 14:10:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582812632; bh=5bD7RjzDBM4Cn3X4m5cxlyQ8eVsypFN/FZmInh4myb8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SemXfIDqmNqElaJK3AMaIX2sgQGOMyyu4SvG0LNiODIS6YcdZvriP50liVsvg1Q4p 16KgO0dSrfZB0AWAuRv51iuWqlaQBiTOYgriN/bkHV52LO+EtMm+7CpIgtZFRa++hy hB6I4GP5N2Oi/4jyW1K3ZF+PuqmXHtRNkB6ilaOo= 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 5.4 091/135] KVM: apic: avoid calculating pending eoi from an uninitialized val Date: Thu, 27 Feb 2020 14:37:11 +0100 Message-Id: <20200227132242.970867787@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200227132228.710492098@linuxfoundation.org> References: <20200227132228.710492098@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 @@ -637,9 +637,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) { printk(KERN_WARNING "Can't read EOI MSR value: 0x%llx\n", (unsigned long long)vcpu->arch.pv_eoi.msr_val); + return false; + } return val & 0x1; }