The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/kern/stack_protector.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 #include <sys/cdefs.h>
    2 __FBSDID("$FreeBSD$");
    3 
    4 #include <sys/types.h>
    5 #include <sys/param.h>
    6 #include <sys/kernel.h>
    7 #include <sys/systm.h>
    8 #include <sys/libkern.h>
    9 
   10 long __stack_chk_guard[8] = {};
   11 void __stack_chk_fail(void);
   12 
   13 void
   14 __stack_chk_fail(void)
   15 {
   16 
   17         panic("stack overflow detected; backtrace may be corrupted");
   18 }
   19 
   20 static void
   21 __stack_chk_init(void *dummy __unused)
   22 {
   23         size_t i;
   24         long guard[nitems(__stack_chk_guard)];
   25 
   26         arc4rand(guard, sizeof(guard), 0);
   27         for (i = 0; i < nitems(guard); i++)
   28                 __stack_chk_guard[i] = guard[i];
   29 }
   30 SYSINIT(stack_chk, SI_SUB_RANDOM, SI_ORDER_ANY, __stack_chk_init, NULL);

Cache object: 2ba1490cd30fd2916e32fdb4d102a309


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.