lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon,  8 Apr 2024 23:10:37 -0700
From: Deepak Gupta <debug@...osinc.com>
To: linux-riscv@...ts.infradead.org,
	linux-kernel@...r.kernel.org,
	llvm@...ts.linux.dev
Cc: paul.walmsley@...ive.com,
	palmer@...belt.com,
	aou@...s.berkeley.edu,
	nathan@...nel.org,
	ndesaulniers@...gle.com,
	morbo@...gle.com,
	justinstitt@...gle.com,
	andy.chiu@...ive.com,
	debug@...osinc.com,
	hankuan.chen@...ive.com,
	guoren@...nel.org,
	greentime.hu@...ive.com,
	samitolvanen@...gle.com,
	cleger@...osinc.com,
	apatel@...tanamicro.com,
	ajones@...tanamicro.com,
	conor.dooley@...rochip.com,
	mchitale@...tanamicro.com,
	dbarboza@...tanamicro.com,
	waylingii@...il.com,
	sameo@...osinc.com,
	alexghiti@...osinc.com,
	akpm@...ux-foundation.org,
	shikemeng@...weicloud.com,
	rppt@...nel.org,
	charlie@...osinc.com,
	xiao.w.wang@...el.com,
	willy@...radead.org,
	jszhang@...nel.org,
	leobras@...hat.com,
	songshuaishuai@...ylab.org,
	haxel@....de,
	samuel.holland@...ive.com,
	namcaov@...il.com,
	bjorn@...osinc.com,
	cuiyunhui@...edance.com,
	wangkefeng.wang@...wei.com,
	falcon@...ylab.org,
	viro@...iv.linux.org.uk,
	bhe@...hat.com,
	chenjiahao16@...wei.com,
	hca@...ux.ibm.com,
	arnd@...db.de,
	kent.overstreet@...ux.dev,
	boqun.feng@...il.com,
	oleg@...hat.com,
	paulmck@...nel.org,
	broonie@...nel.org,
	rick.p.edgecombe@...el.com
Subject: [RFC PATCH 06/12] scs: place init shadow stack in .shadowstack section

If compiled for riscv and dynamic scs is turned on, place shadow stack in
`.shadowstack` section. Arch specific linker script can place logic to
protect this section against regular stores.

Signed-off-by: Deepak Gupta <debug@...osinc.com>
---
 include/linux/init_task.h |  5 +++++
 init/init_task.c          | 12 ++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index bccb3f1f6262..f025022e1164 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -40,4 +40,9 @@ extern struct cred init_cred;
 /* Attach to the thread_info data structure for proper alignment */
 #define __init_thread_info __section(".data..init_thread_info")
 
+#if defined(CONFIG_RISCV) && defined(CONFIG_DYNAMIC_SCS)
+/* init shadow stack page */
+#define __init_shadow_stack __section(".shadowstack..init")
+#endif
+
 #endif
diff --git a/init/init_task.c b/init/init_task.c
index 4daee6d761c8..3c0a01455978 100644
--- a/init/init_task.c
+++ b/init/init_task.c
@@ -52,10 +52,18 @@ static struct sighand_struct init_sighand = {
 };
 
 #ifdef CONFIG_SHADOW_CALL_STACK
-unsigned long init_shadow_call_stack[SCS_SIZE / sizeof(long)] = {
+unsigned long init_shadow_call_stack[SCS_SIZE / sizeof(long)]
+#if defined(CONFIG_RISCV) && defined(CONFIG_DYNAMIC_SCS)
+	/* RISC-V dynamic SCS implements shadow stack and must go in special section */
+	__init_shadow_stack = {
+	[0] = SCS_END_MAGIC
+};
+#else
+	= {
 	[(SCS_SIZE / sizeof(long)) - 1] = SCS_END_MAGIC
 };
-#endif
+#endif /* CONFIG_RISCV && CONFIG_DYNAMIC_SCS */
+#endif /* CONFIG_SHADOW_CALL_STACK */
 
 /*
  * Set up the first task table, touch at your own risk!. Base=0,
-- 
2.43.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ