diff mbox series

[30/33] riscv: create a config for shadow stack and landing pad instr support

Message ID 20241001-v5_user_cfi_series-v1-30-3ba65b6e550f@rivosinc.com (mailing list archive)
State Superseded
Headers show
Series riscv control-flow integrity for usermode | expand

Checks

Context Check Description
conchuod/vmtest-fixes-PR fail PR summary
conchuod/patch-30-test-1 success .github/scripts/patches/tests/build_rv32_defconfig.sh took 98.81s
conchuod/patch-30-test-2 success .github/scripts/patches/tests/build_rv64_clang_allmodconfig.sh took 928.13s
conchuod/patch-30-test-3 success .github/scripts/patches/tests/build_rv64_gcc_allmodconfig.sh took 1111.06s
conchuod/patch-30-test-4 fail .github/scripts/patches/tests/build_rv64_nommu_k210_defconfig.sh took 4.22s
conchuod/patch-30-test-5 fail .github/scripts/patches/tests/build_rv64_nommu_virt_defconfig.sh took 4.21s
conchuod/patch-30-test-6 success .github/scripts/patches/tests/checkpatch.sh took 0.30s
conchuod/patch-30-test-7 success .github/scripts/patches/tests/dtb_warn_rv64.sh took 35.93s
conchuod/patch-30-test-8 success .github/scripts/patches/tests/header_inline.sh took 0.00s
conchuod/patch-30-test-9 success .github/scripts/patches/tests/kdoc.sh took 0.49s
conchuod/patch-30-test-10 success .github/scripts/patches/tests/module_param.sh took 0.01s
conchuod/patch-30-test-11 success .github/scripts/patches/tests/verify_fixes.sh took 0.00s
conchuod/patch-30-test-12 success .github/scripts/patches/tests/verify_signedoff.sh took 0.02s

Commit Message

Deepak Gupta Oct. 1, 2024, 4:06 p.m. UTC
This patch creates a config for shadow stack support and landing pad instr
support. Shadow stack support and landing instr support can be enabled by
selecting `CONFIG_RISCV_USER_CFI`. Selecting `CONFIG_RISCV_USER_CFI` wires
up path to enumerate CPU support and if cpu support exists, kernel will
support cpu assisted user mode cfi.

If CONFIG_RISCV_USER_CFI is selected, select `ARCH_USES_HIGH_VMA_FLAGS`
and `ARCH_HAS_USER_SHADOW_STACK` for riscv.

Signed-off-by: Deepak Gupta <debug@rivosinc.com>
---
 arch/riscv/Kconfig | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
diff mbox series

Patch

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 808ea66b9537..d0cc2879fcd4 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -245,6 +245,25 @@  config ARCH_HAS_BROKEN_DWARF5
 	# https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77
 	depends on LD_IS_LLD && LLD_VERSION < 180000
 
+config RISCV_USER_CFI
+	def_bool y
+	bool "riscv userspace control flow integrity"
+	depends on 64BIT && $(cc-option,-mabi=lp64 -march=rv64ima_zicfiss)
+	depends on RISCV_ALTERNATIVE
+	select ARCH_HAS_USER_SHADOW_STACK
+	select ARCH_USES_HIGH_VMA_FLAGS
+	help
+	  Provides CPU assisted control flow integrity to userspace tasks.
+	  Control flow integrity is provided by implementing shadow stack for
+	  backward edge and indirect branch tracking for forward edge in program.
+	  Shadow stack protection is a hardware feature that detects function
+	  return address corruption. This helps mitigate ROP attacks.
+	  Indirect branch tracking enforces that all indirect branches must land
+	  on a landing pad instruction else CPU will fault. This mitigates against
+	  JOP / COP attacks. Applications must be enabled to use it, and old user-
+	  space does not get protection "for free".
+	  default y
+
 config ARCH_MMAP_RND_BITS_MIN
 	default 18 if 64BIT
 	default 8