1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-14 10:09:48 +00:00
freebsd/sys/kern/stack_protector.c
Conrad Meyer e199792d23 Revert r346292 (permit_nonrandom_stackcookies)
We have a better, more comprehensive knob for this now:
kern.random.initial_seeding.bypass_before_seeding=1.

Requested by:	delphij
Sponsored by:	Dell EMC Isilon
2019-05-13 23:37:44 +00:00

31 lines
613 B
C

#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/libkern.h>
long __stack_chk_guard[8] = {};
void __stack_chk_fail(void);
void
__stack_chk_fail(void)
{
panic("stack overflow detected; backtrace may be corrupted");
}
static void
__stack_chk_init(void *dummy __unused)
{
size_t i;
long guard[nitems(__stack_chk_guard)];
arc4rand(guard, sizeof(guard), 0);
for (i = 0; i < nitems(guard); i++)
__stack_chk_guard[i] = guard[i];
}
SYSINIT(stack_chk, SI_SUB_RANDOM, SI_ORDER_ANY, __stack_chk_init, NULL);