svn commit: branches/uClibc-nptl/libc/sysdeps/linux/common
sjhill at uclibc.org
sjhill at uclibc.org
Sun Nov 6 05:22:08 UTC 2005
Author: sjhill
Date: 2005-11-05 21:22:05 -0800 (Sat, 05 Nov 2005)
New Revision: 12169
Log:
Sync.
Modified:
branches/uClibc-nptl/libc/sysdeps/linux/common/ssp-local.c
Changeset:
Modified: branches/uClibc-nptl/libc/sysdeps/linux/common/ssp-local.c
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/common/ssp-local.c 2005-11-06 05:21:49 UTC (rev 12168)
+++ branches/uClibc-nptl/libc/sysdeps/linux/common/ssp-local.c 2005-11-06 05:22:05 UTC (rev 12169)
@@ -1,103 +1,35 @@
-/*
- * Distributed under the terms of the GNU Lesser General Public License
- * $Header: $
- *
- * This is a modified version of Hiroaki Etoh's stack smashing routines
- * implemented for glibc.
- *
- * The following people have contributed input to this code.
- * Ned Ludd - <solar[@]gentoo.org>
- * Alexander Gabert - <pappy[@]gentoo.org>
- * The PaX Team - <pageexec[@]freemail.hu>
- * Peter S. Mazinger - <ps.m[@]gmx.net>
- * Yoann Vandoorselaere - <yoann[@]prelude-ids.org>
- * Robert Connolly - <robert[@]linuxfromscratch.org>
- * Cory Visi <cory[@]visi.name>
- * Mike Frysinger <vapier[@]gentoo.org>
- */
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
-#include <string.h>
-#include <unistd.h>
-#include <sys/syslog.h>
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#include <ssp-internal.h>
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
-static __always_inline void block_signals(void)
-{
- struct sigaction sa;
- sigset_t mask;
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
- sigfillset(&mask);
+/*
+ * Peter S. Mazinger ps.m[@]gmx.net
+ * copied stack_chk_fail_local.c from glibc and adapted for uClibc
+ */
- sigdelset(&mask, SSP_SIGTYPE); /* Block all signal handlers */
- SIGPROCMASK(SIG_BLOCK, &mask, NULL); /* except SSP_SIGTYPE */
+#include <features.h>
- /* Make the default handler associated with the signal handler */
- memset(&sa, 0, sizeof(struct sigaction));
- sigfillset(&sa.sa_mask); /* Block all signals */
- sa.sa_flags = 0;
- sa.sa_handler = SIG_DFL;
- SIGACTION(SSP_SIGTYPE, &sa, NULL);
-}
+extern void __stack_chk_fail (void) __attribute__ ((noreturn));
-static __always_inline void ssp_write(int fd, const char *msg1, const char *msg2, const char *msg3)
-{
- WRITE(fd, msg1, strlen(msg1));
- WRITE(fd, msg2, strlen(msg2));
- WRITE(fd, msg3, strlen(msg3));
- WRITE(fd, "()\n", 3);
- openlog("ssp", LOG_CONS | LOG_PID, LOG_USER);
- syslog(LOG_INFO, "%s%s%s()", msg1, msg2, msg3);
- closelog();
-}
+/* On some architectures, this helps needless PIC pointer setup
+ that would be needed just for the __stack_chk_fail call. */
-static __always_inline void terminate(void)
+void __attribute__ ((noreturn)) attribute_hidden
+__stack_chk_fail_local (void)
{
- (void) KILL(GETPID(), SSP_SIGTYPE);
- EXIT(127);
+ __stack_chk_fail ();
}
-
-void __attribute__ ((noreturn)) __stack_smash_handler(char func[], int damaged __attribute__ ((unused)));
-void __attribute__ ((noreturn)) __stack_smash_handler(char func[], int damaged)
-{
- extern char *__progname;
- static const char message[] = ": stack smashing attack in function ";
-
- block_signals();
-
- ssp_write(STDERR_FILENO, __progname, message, func);
-
- /* The loop is added only to keep gcc happy. */
- while(1)
- terminate();
-}
-
-void __attribute__ ((noreturn)) __stack_chk_fail(void)
-{
- extern char *__progname;
- static const char msg1[] = "stack smashing detected: ";
- static const char msg3[] = " terminated";
-
- block_signals();
-
- ssp_write(STDERR_FILENO, msg1, __progname, msg3);
-
- /* The loop is added only to keep gcc happy. */
- while(1)
- terminate();
-}
-
-void __attribute__ ((noreturn)) __chk_fail(void)
-{
- extern char *__progname;
- static const char msg1[] = "buffer overflow detected: ";
- static const char msg3[] = " terminated";
-
- block_signals();
-
- ssp_write(STDERR_FILENO, msg1, __progname, msg3);
-
- /* The loop is added only to keep gcc happy. */
- while(1)
- terminate();
-}
More information about the uClibc-cvs
mailing list