162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef _ASM_STACKPROTECTOR_H
362306a36Sopenharmony_ci#define _ASM_STACKPROTECTOR_H 1
462306a36Sopenharmony_ci
562306a36Sopenharmony_ciextern unsigned long __stack_chk_guard;
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci/*
862306a36Sopenharmony_ci * Initialize the stackprotector canary value.
962306a36Sopenharmony_ci *
1062306a36Sopenharmony_ci * NOTE: this must only be called from functions that never return,
1162306a36Sopenharmony_ci * and it must always be inlined.
1262306a36Sopenharmony_ci */
1362306a36Sopenharmony_cistatic __always_inline void boot_init_stack_canary(void)
1462306a36Sopenharmony_ci{
1562306a36Sopenharmony_ci	unsigned long canary = get_random_canary();
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci	current->stack_canary = canary;
1862306a36Sopenharmony_ci	__stack_chk_guard = current->stack_canary;
1962306a36Sopenharmony_ci}
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci#endif /* __ASM_SH_STACKPROTECTOR_H */
22