From patchwork Mon Feb 10 12:32:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 232011 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=ham 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 70E06C352A3 for ; Mon, 10 Feb 2020 12:38:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 40FFA20873 for ; Mon, 10 Feb 2020 12:38:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338308; bh=a1x5KIPiysAsw/dzQhhYLOgGzN8IKYmOGr5d7X+Auh8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ouuSqQefRC7OZSjRroYOKxs7GezFmrMOskIVhLb8aUxpl3y7gV6ZjcURPbDa+L7x0 an6CSUtFHDQ0Hb75odPpYx3Q/OALG4LFdasXu6YSfpCgW80mXUwFSpVnmAaiXyNrvz CPCldPfb0cG3Sro60CSuuZHxETducFj7q4oe+Yo0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729132AbgBJMiX (ORCPT ); Mon, 10 Feb 2020 07:38:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:33716 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729128AbgBJMiX (ORCPT ); Mon, 10 Feb 2020 07:38:23 -0500 Received: from localhost (unknown [209.37.97.194]) (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 B233520842; Mon, 10 Feb 2020 12:38:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338302; bh=a1x5KIPiysAsw/dzQhhYLOgGzN8IKYmOGr5d7X+Auh8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XMPmYzCvS6MmdSthZDJnSxqHV8Ci8ZC8OQayMSikQcJ+HWrCpynVIsOBZOTKL5v5j w2S7EAoeYyDII6dKyvC0RV9enJr4AdnRgoXV9x03Nepi53LvixY+6Yq/07bOcr2kdS /BV/QOjf2eyRygZR7OH+9CLoXmmarqlTmOwlT22U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Boris Ostrovsky , Joao Martins , Paolo Bonzini Subject: [PATCH 5.4 214/309] x86/kvm: Be careful not to clear KVM_VCPU_FLUSH_TLB bit Date: Mon, 10 Feb 2020 04:32:50 -0800 Message-Id: <20200210122427.098533996@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122406.106356946@linuxfoundation.org> References: <20200210122406.106356946@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: Boris Ostrovsky commit 8c6de56a42e0c657955e12b882a81ef07d1d073e upstream. kvm_steal_time_set_preempted() may accidentally clear KVM_VCPU_FLUSH_TLB bit if it is called more than once while VCPU is preempted. This is part of CVE-2019-3016. (This bug was also independently discovered by Jim Mattson ) Signed-off-by: Boris Ostrovsky Reviewed-by: Joao Martins Cc: stable@vger.kernel.org Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/x86.c | 3 +++ 1 file changed, 3 insertions(+) --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3499,6 +3499,9 @@ static void kvm_steal_time_set_preempted if (!(vcpu->arch.st.msr_val & KVM_MSR_ENABLED)) return; + if (vcpu->arch.st.steal.preempted) + return; + vcpu->arch.st.steal.preempted = KVM_VCPU_PREEMPTED; kvm_write_guest_offset_cached(vcpu->kvm, &vcpu->arch.st.stime,