summaryrefslogtreecommitdiff
path: root/lib/libc/sys
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2013-12-27 18:32:20 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2013-12-27 18:32:20 +0000
commitab254730433eb671acd4f65fe5dd882081ee5c50 (patch)
tree05f1d098ff8033c0886fbcc4bfd94029353fd856 /lib/libc/sys
parentd70b8788f416c3a59599a9628f93dc37792fd8aa (diff)
do not need to create the stack cookie using a constructor anymore,
since the kernel supplies a .openbsd.randomdata segment. ok matthew miod guenther
Diffstat (limited to 'lib/libc/sys')
-rw-r--r--lib/libc/sys/stack_protector.c30
1 files changed, 1 insertions, 29 deletions
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 <sys/param.h>
-#include <sys/sysctl.h>
#include <signal.h>
#include <string.h>
#include <syslog.h>
#include <unistd.h>
-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)