From ce3b560306ddc4c2dd2c964c7d64809779b04f07 Mon Sep 17 00:00:00 2001 From: Jerome Forissier Date: Fri, 20 Sep 2024 13:44:08 +0200 Subject: [PATCH] ta: apply __no_stack_protector to __ta_entry() or __ta_entry_c() Apply the __no_stack_protector attribute to the first C function called following the TA entry point (i.e., __ta_entry(), or for the special case of ARM32, __ta_entry_c()). This is required because __stack_chk_guard is initialized in this very function, therefore stack protection cannot be assumed to be functional at this point. Fixes a TA crash on QEMUv7 with Clang 18.1.7 [1]. Link: https://github.com/OP-TEE/optee_os/issues/7047 [1] Signed-off-by: Jerome Forissier Acked-by: Etienne Carriere --- ta/user_ta_header.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/ta/user_ta_header.c b/ta/user_ta_header.c index d602f9226de..3125af55c44 100644 --- a/ta/user_ta_header.c +++ b/ta/user_ta_header.c @@ -39,15 +39,17 @@ struct utee_params; TEE_Result __utee_entry(unsigned long func, unsigned long session_id, struct utee_params *up, unsigned long cmd_id); -void __noreturn _C_FUNCTION(__ta_entry)(unsigned long func, - unsigned long session_id, - struct utee_params *up, - unsigned long cmd_id); - -void __noreturn _C_FUNCTION(__ta_entry)(unsigned long func, - unsigned long session_id, - struct utee_params *up, - unsigned long cmd_id) +void __noreturn __no_stack_protector +_C_FUNCTION(__ta_entry)(unsigned long func, + unsigned long session_id, + struct utee_params *up, + unsigned long cmd_id); + +void __noreturn __no_stack_protector +_C_FUNCTION(__ta_entry)(unsigned long func, + unsigned long session_id, + struct utee_params *up, + unsigned long cmd_id) { static bool stack_canary_inited; TEE_Result res = TEE_ERROR_GENERIC;