mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
tools/nolibc: ensure stack protector guard is never zero
The all-zero pattern is one of the more probable out-of-bound writes so add a special case to not accidentally accept it. Also it enables the reliable detection of stack protector initialization during testing. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
This commit is contained in:
parent
7a9b234520
commit
88fc7eb54e
1 changed files with 3 additions and 2 deletions
|
@ -45,8 +45,9 @@ __attribute__((weak,no_stack_protector,section(".text.nolibc_stack_chk")))
|
||||||
void __stack_chk_init(void)
|
void __stack_chk_init(void)
|
||||||
{
|
{
|
||||||
my_syscall3(__NR_getrandom, &__stack_chk_guard, sizeof(__stack_chk_guard), 0);
|
my_syscall3(__NR_getrandom, &__stack_chk_guard, sizeof(__stack_chk_guard), 0);
|
||||||
/* a bit more randomness in case getrandom() fails */
|
/* a bit more randomness in case getrandom() fails, ensure the guard is never 0 */
|
||||||
__stack_chk_guard ^= (uintptr_t) &__stack_chk_guard;
|
if (__stack_chk_guard != (uintptr_t) &__stack_chk_guard)
|
||||||
|
__stack_chk_guard ^= (uintptr_t) &__stack_chk_guard;
|
||||||
}
|
}
|
||||||
#endif /* defined(NOLIBC_STACKPROTECTOR) */
|
#endif /* defined(NOLIBC_STACKPROTECTOR) */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue