Skip to content

Commit

Permalink
ta: apply __no_stack_protector to __ta_entry() or __ta_entry_c()
Browse files Browse the repository at this point in the history
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: OP-TEE#7047 [1]
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Khoa Hoang <admin@khoahoang.com>
  • Loading branch information
jforissier committed Sep 25, 2024
1 parent 010c75a commit e505a13
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions ta/user_ta_header.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e505a13

Please sign in to comment.