From patchwork Wed Jul 19 22:47:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 122911 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp2771386vqt; Wed, 19 Jul 2023 16:27:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlHHWvsvdbxmNY6ZneBI+fN/jzAzEaeoS1ejnBT5qEIRR8G/PwxFJaFuvuiCa7DEcMoBBo7E X-Received: by 2002:a17:90b:3606:b0:250:8f09:75f2 with SMTP id ml6-20020a17090b360600b002508f0975f2mr14492360pjb.22.1689809256746; Wed, 19 Jul 2023 16:27:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689809256; cv=none; d=google.com; s=arc-20160816; b=SFBfVrgbDKHc9j7EbnNG+/8+D45Opxl8jcZ1qruCyWZ9hdYTCz9FgbD8cZixYSRhl6 4RYE4VKzSNbucKOgC28OSUTmgjn98o35BE8J9KY6Wsr0evKe8UBvFrhyX3/MOGRgZoCg JWkBPvIyEA/UlJfBRzAsBzjMbbNi0QS2uSJbyoz0XaQ+ihU/EcHMWFPT6AJagZbITtHS TwmB3FCDtFLyXWk+sbYYNBU6+jNnDkyp3Zz3sZjYTjy6YKDssWX9Q8aOUjFZwr42Inew hKDE3i76YpyVSNJwuKhXh0q+cnmPBh2pVu/obZpsDTcN82Tor59TXfiXvnJ4IGGxcbtH Y0jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=iyuYd8QMB9FAdqbSNXeTgPoNkZ6fmC7VxJ7OXEZ8Qv4=; fh=cYKsLYKlfL5GLDpOt1a9DaF93PQ8azQhO0iBCt+veh0=; b=KH/Ixu7xEbhrcyk0ptS2tbBA4fbFBA6sRbPaQe/9x04NjEbeCafHHCjQDW57vPIw/X cGBiZSYB4LPmtrwQ16WxZpAbII2L5mkhbtW403v19z+3cF+3Qql5gPYylc5mHNN8lTwl wMoHyp+e0flIXux+vyUq2cq5VYwkZO1ITMdIHDuPJ8GbCCpFrrdHMBRlJI8e8hHWtlLI MCV6DkLt64b7AIDuEE07ZDp973JN7J5aHpUEahH1QvahsmxjuVFMwIATkPiAtpm0qH2U 2+705Me4X+hO8UhJGSst0jCoddgld5iwQXWeqDaLqTv1jKF4FjQzJkpVS9/FGtfjb7tV NJ5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=x2lJMMsz; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l11-20020a17090a660b00b00263e357cb01si2243276pjj.71.2023.07.19.16.27.24; Wed, 19 Jul 2023 16:27:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=x2lJMMsz; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231391AbjGSWti (ORCPT + 99 others); Wed, 19 Jul 2023 18:49:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231268AbjGSWrz (ORCPT ); Wed, 19 Jul 2023 18:47:55 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7404B2712; Wed, 19 Jul 2023 15:47:44 -0700 (PDT) Date: Wed, 19 Jul 2023 22:47:41 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689806862; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iyuYd8QMB9FAdqbSNXeTgPoNkZ6fmC7VxJ7OXEZ8Qv4=; b=x2lJMMsz5lIsEQ2eqvhPmhTuyharuylO4IHoph+MSgbcwGJqMArzI1cup8KOpLjoEXMmDA 6dnwMLo2UCs5KdtmsDoih0aSgxerFPH2W0TTN2TiPHLpqbfbo6sQSZt1O+ZYO5nyDtfW0Z 4d59jReHDbofrL86X6ZiqayoLazkoXovYQ3OclAvcBBwK4UX+77ImH9R2dwRN78zOVUtpe oWxW9LZd7Ho4we7d0kRuhgZa6C0/JxMTCjST6dVB5Orl37flpWw4QZoM999QeoSaOvoEh7 rbClBWxTC74e00O2FfgwQMXxjbDt3hgjBiQJwsoxkeojNSo8voq0HhVYrtmkiA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689806862; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iyuYd8QMB9FAdqbSNXeTgPoNkZ6fmC7VxJ7OXEZ8Qv4=; b=pCckvF4SRGHcylgJdptTbpf2Ju4ypb7wShyMJUlyk3HgHQZYVD6keO1nE5VB/cBkUeRsZj m+bFpLbmwReLVGCg== From: "tip-bot2 for Rick Edgecombe" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/shstk] x86/shstk: Add Kconfig option for shadow stack Cc: "Yu-cheng Yu" , Rick Edgecombe , Dave Hansen , "Borislav Petkov (AMD)" , Kees Cook , "Mike Rapoport (IBM)" , Pengfei Xu , John Allen , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <168980686167.28540.17336697338680035127.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771893430945754086 X-GMAIL-MSGID: 1771893430945754086 The following commit has been merged into the x86/shstk branch of tip: Commit-ID: 18e66b695e787374ca762ecdeaa1ab5e3772af94 Gitweb: https://git.kernel.org/tip/18e66b695e787374ca762ecdeaa1ab5e3772af94 Author: Rick Edgecombe AuthorDate: Mon, 12 Jun 2023 17:10:32 -07:00 Committer: Rick Edgecombe CommitterDate: Tue, 11 Jul 2023 14:12:18 -07:00 x86/shstk: Add Kconfig option for shadow stack Shadow stack provides protection for applications against function return address corruption. It is active when the processor supports it, the kernel has CONFIG_X86_SHADOW_STACK enabled, and the application is built for the feature. This is only implemented for the 64-bit kernel. When it is enabled, legacy non-shadow stack applications continue to work, but without protection. Since there is another feature that utilizes CET (Kernel IBT) that will share implementation with shadow stacks, create CONFIG_CET to signify that at least one CET feature is configured. Co-developed-by: Yu-cheng Yu Signed-off-by: Yu-cheng Yu Signed-off-by: Rick Edgecombe Signed-off-by: Dave Hansen Reviewed-by: Borislav Petkov (AMD) Reviewed-by: Kees Cook Acked-by: Mike Rapoport (IBM) Tested-by: Pengfei Xu Tested-by: John Allen Tested-by: Kees Cook Link: https://lore.kernel.org/all/20230613001108.3040476-7-rick.p.edgecombe%40intel.com --- arch/x86/Kconfig | 24 ++++++++++++++++++++++++ arch/x86/Kconfig.assembler | 5 +++++ 2 files changed, 29 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 7422db4..e860f80 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1849,6 +1849,11 @@ config CC_HAS_IBT (CC_IS_CLANG && CLANG_VERSION >= 140000)) && \ $(as-instr,endbr64) +config X86_CET + def_bool n + help + CET features configured (Shadow stack or IBT) + config X86_KERNEL_IBT prompt "Indirect Branch Tracking" def_bool y @@ -1856,6 +1861,7 @@ config X86_KERNEL_IBT # https://github.com/llvm/llvm-project/commit/9d7001eba9c4cb311e03cd8cdc231f9e579f2d0f depends on !LD_IS_LLD || LLD_VERSION >= 140000 select OBJTOOL + select X86_CET help Build the kernel with support for Indirect Branch Tracking, a hardware support course-grain forward-edge Control Flow Integrity @@ -1949,6 +1955,24 @@ config X86_SGX If unsure, say N. +config X86_USER_SHADOW_STACK + bool "X86 userspace shadow stack" + depends on AS_WRUSS + depends on X86_64 + select ARCH_USES_HIGH_VMA_FLAGS + select X86_CET + help + Shadow stack protection is a hardware feature that detects function + return address corruption. This helps mitigate ROP attacks. + Applications must be enabled to use it, and old userspace does not + get protection "for free". + + CPUs supporting shadow stacks were first released in 2020. + + See Documentation/x86/shstk.rst for more information. + + If unsure, say N. + config EFI bool "EFI runtime service support" depends on ACPI diff --git a/arch/x86/Kconfig.assembler b/arch/x86/Kconfig.assembler index b88f784..8ad41da 100644 --- a/arch/x86/Kconfig.assembler +++ b/arch/x86/Kconfig.assembler @@ -24,3 +24,8 @@ config AS_GFNI def_bool $(as-instr,vgf2p8mulb %xmm0$(comma)%xmm1$(comma)%xmm2) help Supported by binutils >= 2.30 and LLVM integrated assembler + +config AS_WRUSS + def_bool $(as-instr,wrussq %rax$(comma)(%rbx)) + help + Supported by binutils >= 2.31 and LLVM integrated assembler