aboutsummaryrefslogtreecommitdiff
path: root/arch/arm64/include/asm/stackprotector.h
diff options
context:
space:
mode:
authorAmit Daniel Kachhap <[email protected]>2020-03-13 14:34:57 +0530
committerCatalin Marinas <[email protected]>2020-03-18 09:50:20 +0000
commit28321582334c261c13b20d7efe634e610b4c100b (patch)
tree1a345f68e800b30309c0b710048d97dea3aecf16 /arch/arm64/include/asm/stackprotector.h
parent33e45234987ea3ed4b05fc512f4441696478f12d (diff)
arm64: initialize ptrauth keys for kernel booting task
This patch uses the existing boot_init_stack_canary arch function to initialize the ptrauth keys for the booting task in the primary core. The requirement here is that it should be always inline and the caller must never return. As pointer authentication too detects a subset of stack corruption so it makes sense to place this code here. Both pointer authentication and stack canary codes are protected by their respective config option. Suggested-by: Ard Biesheuvel <[email protected]> Signed-off-by: Amit Daniel Kachhap <[email protected]> Reviewed-by: Vincenzo Frascino <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Signed-off-by: Catalin Marinas <[email protected]>
Diffstat (limited to 'arch/arm64/include/asm/stackprotector.h')
-rw-r--r--arch/arm64/include/asm/stackprotector.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/arch/arm64/include/asm/stackprotector.h b/arch/arm64/include/asm/stackprotector.h
index 5884a2b02827..7263e0bac680 100644
--- a/arch/arm64/include/asm/stackprotector.h
+++ b/arch/arm64/include/asm/stackprotector.h
@@ -15,6 +15,7 @@
#include <linux/random.h>
#include <linux/version.h>
+#include <asm/pointer_auth.h>
extern unsigned long __stack_chk_guard;
@@ -26,6 +27,7 @@ extern unsigned long __stack_chk_guard;
*/
static __always_inline void boot_init_stack_canary(void)
{
+#if defined(CONFIG_STACKPROTECTOR)
unsigned long canary;
/* Try to get a semi random initial value. */
@@ -36,6 +38,9 @@ static __always_inline void boot_init_stack_canary(void)
current->stack_canary = canary;
if (!IS_ENABLED(CONFIG_STACKPROTECTOR_PER_TASK))
__stack_chk_guard = current->stack_canary;
+#endif
+ ptrauth_thread_init_kernel(current);
+ ptrauth_thread_switch_kernel(current);
}
#endif /* _ASM_STACKPROTECTOR_H */