Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEBFCC38A06 for ; Mon, 15 Nov 2021 19:52:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9A61461B29 for ; Mon, 15 Nov 2021 19:52:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348399AbhKOTwV (ORCPT ); Mon, 15 Nov 2021 14:52:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:46082 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239848AbhKOSEy (ORCPT ); Mon, 15 Nov 2021 13:04:54 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 24602632E6; Mon, 15 Nov 2021 17:39:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1636997980; bh=XzweCvmoHTy63gnpL5NBLwzrwLQJJgkukG8j1sy6zHI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oXW/f7LkMrDBGCZe5w/CF5QctZll7e4MclJaQ1yjxN0VgW1OGsQhPDO9v/Lk8iduA zSFFFEKZU4x2oGDl+vJL7j2qaK/Us2PmGGweGnNRQSXULtk6Zr33Hy7LU4E6lgBubQ Pa6/bjwg5SNwV6P0/aHstBnyIHvpsSgd4xQgHbjI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tom Lendacky , Joerg Roedel , Borislav Petkov , Sasha Levin Subject: [PATCH 5.10 344/575] x86/sev: Fix stack type check in vc_switch_off_ist() Date: Mon, 15 Nov 2021 18:01:09 +0100 Message-Id: <20211115165355.694642447@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211115165343.579890274@linuxfoundation.org> References: <20211115165343.579890274@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel [ Upstream commit 5681981fb788281b09a4ea14d310d30b2bd89132 ] The value of STACK_TYPE_EXCEPTION_LAST points to the last _valid_ exception stack. Reflect that in the check done in the vc_switch_off_ist() function. Fixes: a13644f3a53de ("x86/entry/64: Add entry code for #VC handler") Reported-by: Tom Lendacky Signed-off-by: Joerg Roedel Signed-off-by: Borislav Petkov Link: https://lkml.kernel.org/r/20211021080833.30875-2-joro@8bytes.org Signed-off-by: Sasha Levin --- arch/x86/kernel/traps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 7692bf7908e6c..143fcb8af38f4 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -701,7 +701,7 @@ asmlinkage __visible noinstr struct pt_regs *vc_switch_off_ist(struct pt_regs *r stack = (unsigned long *)sp; if (!get_stack_info_noinstr(stack, current, &info) || info.type == STACK_TYPE_ENTRY || - info.type >= STACK_TYPE_EXCEPTION_LAST) + info.type > STACK_TYPE_EXCEPTION_LAST) sp = __this_cpu_ist_top_va(VC2); sync: -- 2.33.0