Skip to content

Commit 18e66b6

Browse files
committed
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 <yu-cheng.yu@intel.com> Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com> Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Reviewed-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Kees Cook <keescook@chromium.org> Acked-by: Mike Rapoport (IBM) <rppt@kernel.org> Tested-by: Pengfei Xu <pengfei.xu@intel.com> Tested-by: John Allen <john.allen@amd.com> Tested-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/all/20230613001108.3040476-7-rick.p.edgecombe%40intel.com
1 parent fb47a79 commit 18e66b6

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

arch/x86/Kconfig

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,13 +1849,19 @@ config CC_HAS_IBT
18491849
(CC_IS_CLANG && CLANG_VERSION >= 140000)) && \
18501850
$(as-instr,endbr64)
18511851

1852+
config X86_CET
1853+
def_bool n
1854+
help
1855+
CET features configured (Shadow stack or IBT)
1856+
18521857
config X86_KERNEL_IBT
18531858
prompt "Indirect Branch Tracking"
18541859
def_bool y
18551860
depends on X86_64 && CC_HAS_IBT && HAVE_OBJTOOL
18561861
# https://github.com/llvm/llvm-project/commit/9d7001eba9c4cb311e03cd8cdc231f9e579f2d0f
18571862
depends on !LD_IS_LLD || LLD_VERSION >= 140000
18581863
select OBJTOOL
1864+
select X86_CET
18591865
help
18601866
Build the kernel with support for Indirect Branch Tracking, a
18611867
hardware support course-grain forward-edge Control Flow Integrity
@@ -1949,6 +1955,24 @@ config X86_SGX
19491955

19501956
If unsure, say N.
19511957

1958+
config X86_USER_SHADOW_STACK
1959+
bool "X86 userspace shadow stack"
1960+
depends on AS_WRUSS
1961+
depends on X86_64
1962+
select ARCH_USES_HIGH_VMA_FLAGS
1963+
select X86_CET
1964+
help
1965+
Shadow stack protection is a hardware feature that detects function
1966+
return address corruption. This helps mitigate ROP attacks.
1967+
Applications must be enabled to use it, and old userspace does not
1968+
get protection "for free".
1969+
1970+
CPUs supporting shadow stacks were first released in 2020.
1971+
1972+
See Documentation/x86/shstk.rst for more information.
1973+
1974+
If unsure, say N.
1975+
19521976
config EFI
19531977
bool "EFI runtime service support"
19541978
depends on ACPI

arch/x86/Kconfig.assembler

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@ config AS_GFNI
2424
def_bool $(as-instr,vgf2p8mulb %xmm0$(comma)%xmm1$(comma)%xmm2)
2525
help
2626
Supported by binutils >= 2.30 and LLVM integrated assembler
27+
28+
config AS_WRUSS
29+
def_bool $(as-instr,wrussq %rax$(comma)(%rbx))
30+
help
31+
Supported by binutils >= 2.31 and LLVM integrated assembler

0 commit comments

Comments
 (0)