diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index b12e4437bf0a247f3269919969a432a88da37e6e..f3fea3928efce873a5fe3290d08a2ae3a92826cc 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -1469,6 +1469,7 @@ static void add_cpu_to_masks(int cpu) } /* Activate a secondary processor. */ +__no_stack_protector void start_secondary(void *unused) { unsigned int cpu = raw_smp_processor_id(); diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_attributes.h index 08eb06301791d7ad4a44b867e2498904813c5f6f..6f495fca9d79574463f95cd9b4bbc521800b5ab6 100644 --- a/include/linux/compiler_attributes.h +++ b/include/linux/compiler_attributes.h @@ -251,6 +251,18 @@ */ #define __noreturn __attribute__((__noreturn__)) +/* + * Optional: only supported since GCC >= 11.1, clang >= 7.0. + * + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-no_005fstack_005fprotector-function-attribute + * clang: https://clang.llvm.org/docs/AttributeReference.html#no-stack-protector-safebuffers + */ +#if __has_attribute(__no_stack_protector__) +# define __no_stack_protector __attribute__((__no_stack_protector__)) +#else +# define __no_stack_protector +#endif + /* * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-packed-type-attribute * clang: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-packed-variable-attribute diff --git a/init/main.c b/init/main.c index 2b466bd041104f56047fdb96107f55633c8470e5..86b31c0f485692789af49d8581f13360e262df76 100644 --- a/init/main.c +++ b/init/main.c @@ -874,7 +874,8 @@ void __init __weak arch_call_rest_init(void) rest_init(); } -asmlinkage __visible void __init __no_sanitize_address start_kernel(void) +asmlinkage __visible __init __no_sanitize_address __noreturn __no_stack_protector +void start_kernel(void) { char *command_line; char *after_dashes; @@ -1076,6 +1077,7 @@ asmlinkage __visible void __init __no_sanitize_address start_kernel(void) arch_call_rest_init(); prevent_tail_call_optimization(); + unreachable(); } /* Call all constructor functions linked into the kernel. */