mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-24 07:21:22 +01:00

Add __stack_chk_fail() and __stack_chk_guard variable which are used by compiler built-in stack protector. This patch just try to support stack-protector so the value of the stack guard variable is simply fixed for now. It could be improved by deriving from a random number generator, such as Zkr extension or any platform-specific random number sources. Introduce three configurations for the stack protector: 1. CONFIG_STACK_PROTECTOR to enable the stack protector feature by providing "-fstack-protector" compiler flag 2. CONFIG_STACK_PROTECTOR_STRONG to provide "-fstack-protector-strong" 3. CONFIG_STACK_PROTECTOR_ALL to provide "-fstack-protector-all" Instead of fixing the compiler flag of stack-protector feature as "-fstack-protector", we derive it from the introduced Kconfig configurations. The compiler flag "stack-protector-cflags-y" is defined as Makefile "immediately expanded variables" with ":=". Thus, the stronger configuration of the stack protector can overwrite the preceding one. Signed-off-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu-Chien Peter Lin <peter.lin@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20250703151957.2545958-3-alvinga@andestech.com Signed-off-by: Anup Patel <anup@brainfault.org>
29 lines
739 B
Plaintext
29 lines
739 B
Plaintext
# SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
menu "Stack Protector Support"
|
|
|
|
config STACK_PROTECTOR
|
|
bool "Stack Protector buffer overflow detection"
|
|
default n
|
|
help
|
|
This option turns on the "stack-protector" compiler feature.
|
|
|
|
config STACK_PROTECTOR_STRONG
|
|
bool "Strong Stack Protector"
|
|
depends on STACK_PROTECTOR
|
|
default n
|
|
help
|
|
Turn on the "stack-protector" with "-fstack-protector-strong" option.
|
|
Like -fstack-protector but includes additional functions to be
|
|
protected.
|
|
|
|
config STACK_PROTECTOR_ALL
|
|
bool "Almighty Stack Protector"
|
|
depends on STACK_PROTECTOR
|
|
default n
|
|
help
|
|
Turn on the "stack-protector" with "-fstack-protector-all" option.
|
|
Like -fstack-protector except that all functions are protected.
|
|
|
|
endmenu
|