diff options
author | Huacai Chen <chenhuacai@loongson.cn> | 2022-12-10 17:40:15 +0300 |
---|---|---|
committer | Huacai Chen <chenhuacai@loongson.cn> | 2022-12-14 03:41:53 +0300 |
commit | 09f33601bf940f955c10a6e75a1c1b7bcadee5e2 (patch) | |
tree | 423542be6f130680ebf31b6f679af26cb764775a /arch/loongarch/kernel/switch.S | |
parent | 7db54bfe44a662c8f2c10277bccfa02c2f4c719c (diff) | |
download | linux-09f33601bf940f955c10a6e75a1c1b7bcadee5e2.tar.xz |
LoongArch: Add basic STACKPROTECTOR support
Add basic stack protector support similar to other architectures. A
constant canary value is set at boot time, and with help of compiler's
-fstack-protector we can detect stack corruption.
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Diffstat (limited to 'arch/loongarch/kernel/switch.S')
-rw-r--r-- | arch/loongarch/kernel/switch.S | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/arch/loongarch/kernel/switch.S b/arch/loongarch/kernel/switch.S index 202a163cb32f..31dd8199b245 100644 --- a/arch/loongarch/kernel/switch.S +++ b/arch/loongarch/kernel/switch.S @@ -23,6 +23,11 @@ SYM_FUNC_START(__switch_to) stptr.d ra, a0, THREAD_REG01 stptr.d a3, a0, THREAD_SCHED_RA stptr.d a4, a0, THREAD_SCHED_CFA +#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP) + la t7, __stack_chk_guard + LONG_L t8, a1, TASK_STACK_CANARY + LONG_S t8, t7, 0 +#endif move tp, a2 cpu_restore_nonscratch a1 |