Skip to content

Commit

Permalink
start_kernel: Omit prevent_tail_call_optimization() for newer toolchains
Browse files Browse the repository at this point in the history
prevent_tail_call_optimization() was added in
commit a9a3ed1 ("x86: Fix early boot crash on gcc-10, third try")
to work around stack canaries getting inserted into functions that would
initialize the stack canary in the first place.

Now that we have no_stack_protector function attribute (gcc-11+,
clang-7+) and use it on start_kernel(), remove the call to
prevent_tail_call_optimization() such that we may one day remove it
outright.

Reviewed-by: Nathan Chancellor <[email protected]>
Acked-by: Peter Zijlstra (Intel) <[email protected]>
Signed-off-by: Nick Desaulniers <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Josh Poimboeuf <[email protected]>
  • Loading branch information
nickdesaulniers authored and jpoimboe committed May 16, 2023
1 parent 514ca14 commit dc1d055
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions init/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,13 @@ void start_kernel(void)
/* Do the rest non-__init'ed, we're now alive */
arch_call_rest_init();

/*
* Avoid stack canaries in callers of boot_init_stack_canary for gcc-10
* and older.
*/
#if !__has_attribute(__no_stack_protector__)
prevent_tail_call_optimization();
#endif
}

/* Call all constructor functions linked into the kernel. */
Expand Down

0 comments on commit dc1d055

Please sign in to comment.