From: deraadt Date: Fri, 27 Dec 2013 18:32:19 +0000 (+0000) Subject: do not need to create the stack cookie using a constructor anymore, X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=9bb65f61fd5c3769b8ef4152583f06b78297c945;p=openbsd do not need to create the stack cookie using a constructor anymore, since the kernel supplies a .openbsd.randomdata segment. ok matthew miod guenther --- diff --git a/lib/libc/sys/stack_protector.c b/lib/libc/sys/stack_protector.c index da65b8195f2..c89f572c1ee 100644 --- a/lib/libc/sys/stack_protector.c +++ b/lib/libc/sys/stack_protector.c @@ -1,4 +1,4 @@ -/* $OpenBSD: stack_protector.c,v 1.13 2013/12/27 03:22:27 deraadt Exp $ */ +/* $OpenBSD: stack_protector.c,v 1.14 2013/12/27 18:32:19 deraadt Exp $ */ /* * Copyright (c) 2002 Hiroaki Etoh, Federico G. Schwindt, and Miodrag Vallat. @@ -28,43 +28,15 @@ */ #include -#include #include #include #include #include -extern int __sysctl(int *, u_int, void *, size_t *, void *, size_t); - long __guard[8] __attribute__((section(".openbsd.randomdata"))); -static void __guard_setup(void) __attribute__ ((constructor)); void __stack_smash_handler(char func[], int damaged __attribute__((unused))); -static void -__guard_setup(void) -{ - int mib[2]; - size_t i, len; - - for (i = 0; i < sizeof(__guard) / sizeof(__guard[0]); i++) - if (__guard[i] != 0) - return; - - mib[0] = CTL_KERN; - mib[1] = KERN_ARND; - - len = sizeof(__guard); - if (__sysctl(mib, 2, __guard, &len, NULL, 0) == -1 || - len != sizeof(__guard)) { - /* If sysctl was unsuccessful, use the "terminator canary". */ - ((unsigned char *)__guard)[0] = 0; - ((unsigned char *)__guard)[1] = 0; - ((unsigned char *)__guard)[2] = '\n'; - ((unsigned char *)__guard)[3] = 255; - } -} - /*ARGSUSED*/ void __stack_smash_handler(char func[], int damaged)