Kconfig: Add configurable Stack Canaries protection levels.

Introduce a configurable stack-protection level for the existing
CONFIG_STACK_CANARIES, instead of hard-coding -fstack-protector-all.
Add Kconfig choice STACK_CANARIES_LEVEL four selectable levels:

 -fstack-protector
 -fstack-protector-strong
 -fstack-protector-all (default)
 -fstack-protector-explicit

Signed-off-by: nuttxs <zhaoqing.zhang@sony.com>
This commit is contained in:
nuttxs
2025-09-10 18:28:33 +08:00
committed by Xiang Xiao
parent 092d7eac73
commit a5b810bdb1
20 changed files with 59 additions and 19 deletions
+40
View File
@@ -2469,6 +2469,46 @@ config STACK_CANARIES
Enabling this option can result in a significant increase
in footprint and an associated decrease in performance.
choice STACK_CANARIES_LEVEL
prompt "Stack Canaries Level Configuration"
default STACK_PROTECTOR_ALL
depends on STACK_CANARIES
---help---
Based on the configuration options, configure the stack Canaries Level.
config STACK_PROTECTOR
bool "-fstack-protector"
---help---
Enable basic stack protection.
config STACK_PROTECTOR_STRONG
bool "-fstack-protector-strong"
---help---
Using stronger stack protection mechanisms may involve more complex
security checks.
config STACK_PROTECTOR_ALL
bool "-fstack-protector-all"
---help---
Enable stack protection for all functions, including those that are
typically not protected.
config STACK_PROTECTOR_EXPLICIT
bool "-fstack-protector-explicit"
---help---
Enable stack protection only for functions explicitly marked as
requiring stack protection.
endchoice # Stack Canaries Level Configuration
config STACK_CANARIES_LEVEL
string
default "-fstack-protector" if STACK_PROTECTOR
default "-fstack-protector-strong" if STACK_PROTECTOR_STRONG
default "-fstack-protector-all" if STACK_PROTECTOR_ALL
default "-fstack-protector-explicit" if STACK_PROTECTOR_EXPLICIT
depends on STACK_CANARIES
config STACK_USAGE
bool "Generate stack usage information"
---help---