Message ID | 20231020-delay-verw-v1-3-cff54096326d@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp1316131vqb; Fri, 20 Oct 2023 13:47:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHdTNczhcuRN6cawN21Da7fQHd58kdVyCRLAfyjqUQwpeiEFdx+RlAr/Up3TY10QnAfxdlN X-Received: by 2002:a92:d481:0:b0:357:5179:6453 with SMTP id p1-20020a92d481000000b0035751796453mr2854205ilg.32.1697834836552; Fri, 20 Oct 2023 13:47:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697834836; cv=none; d=google.com; s=arc-20160816; b=C8TLFfds2c2Fz9t7Tcq9fofcQygDGIb/Cp0ctbydeAiibzlOhhqy28v1D5bolfxOTc nyEfJb9fMoCpDrSeOdjoMwcGmn+69xWnp7ByzW3zVHYMNdvU6UeYnVS+IyCug1SaMYX0 CWIXjGmiJQL/ytQzo6/XZfqA1gNG+YO3dNZ43Gb2KdY5nJDgifEe8u+NJbep8De7GTT/ malt584JG62lMrIOFiT9PFDvqNgPOog3TEDmmaki0Hg8wFwcAq7rPx9xmZF1yMxG+hQF rIT7WUIUhB9AG85m58YSNssUyHD0grHFLHXUgbWYQbJgKUS5XJ65MoGqssJ+NJrdQTGb 6dTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/363Ck6ML1XM7ZYyVTDe7YNHEqM+JbJAFbfKlaD1Q1k=; fh=lbJsPO+ZRDN9baDq/BZnnNH6CGOpZtNT0YCi3hapTHQ=; b=rf3daz8+QKn/KKT0hbRZDqNDWLdxlSbWzyzxlgJxtxHmOQ7hC7/ci60dUIsyvDW5mV vQRSQh5O9XulXhuiWIftX1Qf7luJ8FB4mG6TFw9d1S3AOp5xYtMjOwymFcgFC3HWu+ka 3bJWaZuVyAYjlQJo9kBvrRt7U5MsWTLZxavOFFUgwCtH2aO4jMbAD4fQzh4sCMm2ZN1v rdupLDYexauIDfMRdbyM0WW5UcDKyMd79ByEcqFyVp0VomoXTXo3CyfKAU5dZ9ZaSOMy w4vpTvL0XFM271B01kt0VIzXk0IzgjlHrIFPtbx5GlAEJbipgUZrJtmAgtBNCrJK9LdW UzDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TgfSmSbN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id bv67-20020a632e46000000b005b065bb6822si2401518pgb.286.2023.10.20.13.47.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 13:47:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TgfSmSbN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 321B08097A37; Fri, 20 Oct 2023 13:45:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232345AbjJTUpV (ORCPT <rfc822;a1648639935@gmail.com> + 26 others); Fri, 20 Oct 2023 16:45:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230408AbjJTUpP (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 20 Oct 2023 16:45:15 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D711D73; Fri, 20 Oct 2023 13:45:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697834711; x=1729370711; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=0qW8gkQ9cQn9nJIAFp1D4GChim4j3ri4y26baGhJi2U=; b=TgfSmSbN2UWoYOR68QBC3ieQZ05CW1/XqLHaJxayGBCoJn/5/ybDPij/ EYG4rXAafabNr1tzgTAlVhftdr7xGEwHdld8P7HZBI9rg0vdFPTs+XkP+ 4dYd+5V1U0XAO0ZsU0LzeGILbka7tIEj17kwG0izuM0XibxtlSQlVlMnP szjlDwHWh9XBMCE6VdHcEZUKJ17aRpCfHp8GdfuKuH23km6dyy6yXqVVP un76a1JOnAPFcfe+GXBCDZkEiLesavYqajCpNi1MwUE102s5vROJ7S3mx gzaYTnX1dY0T3aoJ0x0JAFSOInqsiPsj5FZG+RouyItpLFdxnucZgAzpz w==; X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="371640238" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="371640238" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2023 13:45:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="931117494" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="931117494" Received: from hkchanda-mobl.amr.corp.intel.com (HELO desk) ([10.209.90.113]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2023 13:45:09 -0700 Date: Fri, 20 Oct 2023 13:45:09 -0700 From: Pawan Gupta <pawan.kumar.gupta@linux.intel.com> To: Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, Dave Hansen <dave.hansen@linux.intel.com>, x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>, Peter Zijlstra <peterz@infradead.org>, Josh Poimboeuf <jpoimboe@kernel.org>, Andy Lutomirski <luto@kernel.org>, Jonathan Corbet <corbet@lwn.net>, Sean Christopherson <seanjc@google.com>, Paolo Bonzini <pbonzini@redhat.com>, tony.luck@intel.com, ak@linux.intel.com, tim.c.chen@linux.intel.com Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, kvm@vger.kernel.org, Alyssa Milburn <alyssa.milburn@linux.intel.com>, Daniel Sneddon <daniel.sneddon@linux.intel.com>, antonio.gomez.iglesias@linux.intel.com, Pawan Gupta <pawan.kumar.gupta@linux.intel.com> Subject: [PATCH 3/6] x86/entry_32: Add VERW just before userspace transition Message-ID: <20231020-delay-verw-v1-3-cff54096326d@linux.intel.com> X-Mailer: b4 0.12.3 References: <20231020-delay-verw-v1-0-cff54096326d@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231020-delay-verw-v1-0-cff54096326d@linux.intel.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Fri, 20 Oct 2023 13:45:35 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780308861838952734 X-GMAIL-MSGID: 1780308861838952734 |
Series |
Delay VERW
|
|
Commit Message
Pawan Gupta
Oct. 20, 2023, 8:45 p.m. UTC
As done for entry_64, add support for executing VERW late in exit to
user path for 32-bit mode.
Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
---
arch/x86/entry/entry_32.S | 8 ++++++++
1 file changed, 8 insertions(+)
Comments
On Fri, Oct 20, 2023 at 01:45:09PM -0700, Pawan Gupta wrote: > As done for entry_64, add support for executing VERW late in exit to > user path for 32-bit mode. > > Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com> > --- > arch/x86/entry/entry_32.S | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S > index 6e6af42e044a..bbf77d2aab2e 100644 > --- a/arch/x86/entry/entry_32.S > +++ b/arch/x86/entry/entry_32.S > @@ -886,6 +886,9 @@ SYM_FUNC_START(entry_SYSENTER_32) > popfl > popl %eax > > + /* Mitigate CPU data sampling attacks .e.g. MDS */ > + USER_CLEAR_CPU_BUFFERS > + > /* > * Return back to the vDSO, which will pop ecx and edx. > * Don't bother with DS and ES (they already contain __USER_DS). Did you forget the INT 0x80 entry point? -Andi
On Fri, Oct 20, 2023 at 04:49:34PM -0700, Andi Kleen wrote: > On Fri, Oct 20, 2023 at 01:45:09PM -0700, Pawan Gupta wrote: > > As done for entry_64, add support for executing VERW late in exit to > > user path for 32-bit mode. > > > > Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com> > > --- > > arch/x86/entry/entry_32.S | 8 ++++++++ > > 1 file changed, 8 insertions(+) > > > > diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S > > index 6e6af42e044a..bbf77d2aab2e 100644 > > --- a/arch/x86/entry/entry_32.S > > +++ b/arch/x86/entry/entry_32.S > > @@ -886,6 +886,9 @@ SYM_FUNC_START(entry_SYSENTER_32) > > popfl > > popl %eax > > > > + /* Mitigate CPU data sampling attacks .e.g. MDS */ > > + USER_CLEAR_CPU_BUFFERS > > + > > /* > > * Return back to the vDSO, which will pop ecx and edx. > > * Don't bother with DS and ES (they already contain __USER_DS). > > Did you forget the INT 0x80 entry point? I do have VERW in the INT80 path, the diff is showing just the label restore_all_switch_stack. Below is the sequence: SYM_FUNC_START(entry_INT80_32) ASM_CLAC pushl %eax /* pt_regs->orig_ax */ SAVE_ALL pt_regs_ax=$-ENOSYS switch_stacks=1 /* save rest */ movl %esp, %eax call do_int80_syscall_32 .Lsyscall_32_done: STACKLEAK_ERASE restore_all_switch_stack: SWITCH_TO_ENTRY_STACK CHECK_AND_APPLY_ESPFIX /* Switch back to user CR3 */ SWITCH_TO_USER_CR3 scratch_reg=%eax BUG_IF_WRONG_CR3 /* Restore user state */ RESTORE_REGS pop=4 # skip orig_eax/error_code /* Mitigate CPU data sampling attacks .e.g. MDS */ USER_CLEAR_CPU_BUFFERS ^^^^^^^^^^^^^^^^^^^^^^
diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S index 6e6af42e044a..bbf77d2aab2e 100644 --- a/arch/x86/entry/entry_32.S +++ b/arch/x86/entry/entry_32.S @@ -886,6 +886,9 @@ SYM_FUNC_START(entry_SYSENTER_32) popfl popl %eax + /* Mitigate CPU data sampling attacks .e.g. MDS */ + USER_CLEAR_CPU_BUFFERS + /* * Return back to the vDSO, which will pop ecx and edx. * Don't bother with DS and ES (they already contain __USER_DS). @@ -954,6 +957,9 @@ restore_all_switch_stack: /* Restore user state */ RESTORE_REGS pop=4 # skip orig_eax/error_code + + /* Mitigate CPU data sampling attacks .e.g. MDS */ + USER_CLEAR_CPU_BUFFERS .Lirq_return: /* * ARCH_HAS_MEMBARRIER_SYNC_CORE rely on IRET core serialization @@ -1146,6 +1152,8 @@ SYM_CODE_START(asm_exc_nmi) /* Not on SYSENTER stack. */ call exc_nmi + /* Mitigate CPU data sampling attacks .e.g. MDS */ + USER_CLEAR_CPU_BUFFERS jmp .Lnmi_return .Lnmi_from_sysenter_stack: