From patchwork Wed Feb 17 12:01:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 12091503 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=-11.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,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 026E9C433E0 for ; Wed, 17 Feb 2021 12:03:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C20B464E5B for ; Wed, 17 Feb 2021 12:03:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232549AbhBQMDb (ORCPT ); Wed, 17 Feb 2021 07:03:31 -0500 Received: from 8bytes.org ([81.169.241.247]:55946 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232583AbhBQMDA (ORCPT ); Wed, 17 Feb 2021 07:03:00 -0500 Received: from cap.home.8bytes.org (p549adcf6.dip0.t-ipconnect.de [84.154.220.246]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by theia.8bytes.org (Postfix) with ESMTPSA id 2E8D9246; Wed, 17 Feb 2021 13:02:08 +0100 (CET) From: Joerg Roedel To: x86@kernel.org Cc: Joerg Roedel , Joerg Roedel , hpa@zytor.com, Andy Lutomirski , Dave Hansen , Peter Zijlstra , Jiri Slaby , Dan Williams , Tom Lendacky , Juergen Gross , Kees Cook , David Rientjes , Cfir Cohen , Erdem Aktas , Masami Hiramatsu , Mike Stunes , Sean Christopherson , Martin Radev , Arvind Sankar , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: [PATCH 0/3] x86/sev-es: Check for trusted regs->sp in __sev_es_ist_enter() Date: Wed, 17 Feb 2021 13:01:40 +0100 Message-Id: <20210217120143.6106-1-joro@8bytes.org> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Joerg Roedel Hi, here are some changes to the Linux SEV-ES code to check whether the value in regs->sp can be trusted, before checking whether it points to the #VC IST stack. Andy Lutomirski reported that it is entirely possible to reach this function with a regs->sp value which was set by user-space. So check for this condition and don't use regs->sp if it can't be trusted. Also improve the comments around __sev_es_ist_enter/exit() to better explain what these function do and why they are there. Please review. Thanks, Joerg Joerg Roedel (3): x86/sev-es: Introduce from_syscall_gap() helper x86/sev-es: Check if regs->sp is trusted before adjusting #VC IST stack x86/sev-es: Improve comments in and around __sev_es_ist_enter/exit() arch/x86/include/asm/ptrace.h | 8 ++++++++ arch/x86/kernel/sev-es.c | 27 +++++++++++++++++++-------- arch/x86/kernel/traps.c | 3 +-- 3 files changed, 28 insertions(+), 10 deletions(-)