From 5a79777b4407edd39781e06216e4dc6ca68bb6a7 Mon Sep 17 00:00:00 2001 From: kib Date: Tue, 17 Aug 2010 09:13:26 +0000 Subject: Use aux vector to get values for SSP canary, pagesize, pagesizes array, number of host CPUs and osreldate. This eliminates the last sysctl(2) calls from the dynamically linked image startup. No objections from: kan Tested by: marius (sparc64) MFC after: 1 month --- lib/libc/sys/stack_protector.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/libc/sys/stack_protector.c') diff --git a/lib/libc/sys/stack_protector.c b/lib/libc/sys/stack_protector.c index 14c20eb..b0108f9 100644 --- a/lib/libc/sys/stack_protector.c +++ b/lib/libc/sys/stack_protector.c @@ -34,10 +34,13 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include #include #include +#include "libc_private.h" extern int __sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen); @@ -54,9 +57,14 @@ __guard_setup(void) { int mib[2]; size_t len; + int error; if (__stack_chk_guard[0] != 0) return; + error = _elf_aux_info(AT_CANARY, __stack_chk_guard, + sizeof(__stack_chk_guard)); + if (error == 0 && __stack_chk_guard[0] != 0) + return; mib[0] = CTL_KERN; mib[1] = KERN_ARND; -- cgit v1.1 From ccc2cef693f2f02fa55024c17c959c78003839d9 Mon Sep 17 00:00:00 2001 From: kib Date: Tue, 24 Aug 2010 12:58:54 +0000 Subject: Move the __stack_chk_fail_local@FBSD_1.0 compat symbol definition into the separate .o for libc_pic.a. This prevents rtld from making the symbol global. Putting the stack_protector_compat.c into the public domain acknowledged by kan. Reviewed by: kan MFC after: 2 weeks --- lib/libc/sys/stack_protector.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'lib/libc/sys/stack_protector.c') diff --git a/lib/libc/sys/stack_protector.c b/lib/libc/sys/stack_protector.c index b0108f9..114972f 100644 --- a/lib/libc/sys/stack_protector.c +++ b/lib/libc/sys/stack_protector.c @@ -116,8 +116,6 @@ __chk_fail(void) __fail("buffer overflow detected; terminated"); } -#ifdef PIC -__sym_compat(__stack_chk_fail_local, __stack_chk_fail, FBSD_1.0); -#else +#ifndef PIC __weak_reference(__stack_chk_fail, __stack_chk_fail_local); #endif -- cgit v1.1 From b9202ef929060f15b016e7b75e2f5ad51331856d Mon Sep 17 00:00:00 2001 From: kib Date: Tue, 24 Aug 2010 13:02:22 +0000 Subject: Remove extra FreeBSD tag. MFC after: 3 days --- lib/libc/sys/stack_protector.c | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/libc/sys/stack_protector.c') diff --git a/lib/libc/sys/stack_protector.c b/lib/libc/sys/stack_protector.c index 114972f..14e991e 100644 --- a/lib/libc/sys/stack_protector.c +++ b/lib/libc/sys/stack_protector.c @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /* $NetBSD: stack_protector.c,v 1.4 2006/11/22 17:23:25 christos Exp $ */ /* $OpenBSD: stack_protector.c,v 1.10 2006/03/31 05:34:44 deraadt Exp $ */ /* -- cgit v1.1 From 501752af9c2900d1e6903aa8598db800e97cdfc7 Mon Sep 17 00:00:00 2001 From: rpaulo Date: Wed, 13 Oct 2010 16:57:06 +0000 Subject: Clang related fixes: * When calling syslog(), pass a format string. * Define YY_NO_INPUT on nslexer.l Submitted by: Norberto Lopes --- lib/libc/sys/stack_protector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libc/sys/stack_protector.c') diff --git a/lib/libc/sys/stack_protector.c b/lib/libc/sys/stack_protector.c index 14e991e..ed7d635 100644 --- a/lib/libc/sys/stack_protector.c +++ b/lib/libc/sys/stack_protector.c @@ -92,7 +92,7 @@ __fail(const char *msg) (void)sigprocmask(SIG_BLOCK, &mask, NULL); /* This may fail on a chroot jail... */ - syslog(LOG_CRIT, msg); + syslog(LOG_CRIT, "%s", msg); (void)memset(&sa, 0, sizeof(sa)); (void)sigemptyset(&sa.sa_mask); -- cgit v1.1