This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch master updated. glibc-2.19-14-g0b7c747
- From: vapier at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 8 Feb 2014 12:56:02 -0000
- Subject: GNU C Library master sources branch master updated. glibc-2.19-14-g0b7c747
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, master has been updated
via 0b7c7473b9ffaf5128acc40d53685e1c8bd5de73 (commit)
via ac8cc9e300a002228eb7e660df3e7b333d9a7414 (commit)
via c5bb8e2399f55c09a98c66936940ba744b5841da (commit)
via 10444e425e539ec12e42415756b0a874413ce94a (commit)
via 1e805e8db596a4e09e33aeba94aad568a365d110 (commit)
from 7c70f2272edd4efcc4525f1bbb50e92de1a27a57 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=0b7c7473b9ffaf5128acc40d53685e1c8bd5de73
commit 0b7c7473b9ffaf5128acc40d53685e1c8bd5de73
Author: Mike Frysinger <vapier@gentoo.org>
Date: Mon Dec 30 10:31:19 2013 +0000
tst-backtrace4: expand output even on failures
When debugging failures in this test, it's helpful to see as much output
as possible. So rather than returning immediately, let the code run as
far as it can. We still mark failures as soon as they happen.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
diff --git a/ChangeLog b/ChangeLog
index 8e06921..73d38ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2014-02-08 Mike Frysinger <vapier@gentoo.org>
+ * debug/tst-backtrace4.c (handle_signal): Add NUM_FUNCTIONS to output.
+ Only return early when n is <= 0. Delete unused return statement.
+
+2014-02-08 Mike Frysinger <vapier@gentoo.org>
+
* debug/Makefile (CFLAGS-tst-longjmp_chk3.c): Define.
(CPPFLAGS-tst-longjmp_chk3.c): Likewise.
* debug/tst-longjmp_chk3.c: New file.
diff --git a/debug/tst-backtrace4.c b/debug/tst-backtrace4.c
index a98775a..26fbdd0 100644
--- a/debug/tst-backtrace4.c
+++ b/debug/tst-backtrace4.c
@@ -49,12 +49,16 @@ handle_signal (int signum)
/* Get the backtrace addresses. */
n = backtrace (addresses, sizeof (addresses) / sizeof (addresses[0]));
- printf ("Obtained backtrace with %d functions\n", n);
- /* Check that there are at least six functions. */
+ printf ("Obtained backtrace with %d functions (but wanted at least %d)\n",
+ n, NUM_FUNCTIONS);
+ /* Check that there are at least six functions. */
if (n < NUM_FUNCTIONS)
{
FAIL ();
- return;
+ /* Only return if we got no symbols at all. The partial output is
+ still useful for debugging failures. */
+ if (n <= 0)
+ return;
}
/* Convert them to symbols. */
symbols = backtrace_symbols (addresses, n);
@@ -68,10 +72,7 @@ handle_signal (int signum)
printf ("Function %d: %s\n", i, symbols[i]);
/* Check that the function names obtained are accurate. */
if (!match (symbols[0], "handle_signal"))
- {
- FAIL ();
- return;
- }
+ FAIL ();
/* Do not check name for signal trampoline. */
for (i = 2; i < n - 1; i++)
if (!match (symbols[i], "fn"))
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=ac8cc9e300a002228eb7e660df3e7b333d9a7414
commit ac8cc9e300a002228eb7e660df3e7b333d9a7414
Author: Mike Frysinger <vapier@gentoo.org>
Date: Sun Dec 29 23:15:03 2013 +0000
tst-longjmp_chk3: new test for checking sigaltstack edge cases
Make sure the longjmp checking logic catches stacks that are slightly
outside of a valid alternative signal stack.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
diff --git a/ChangeLog b/ChangeLog
index 610eef6..8e06921 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2014-02-08 Mike Frysinger <vapier@gentoo.org>
+ * debug/Makefile (CFLAGS-tst-longjmp_chk3.c): Define.
+ (CPPFLAGS-tst-longjmp_chk3.c): Likewise.
+ * debug/tst-longjmp_chk3.c: New file.
+
+2014-02-08 Mike Frysinger <vapier@gentoo.org>
+
* benchtests/bench-strcpy_chk.c: Move test-skeleton.c to top.
(test_main): Replace code with set_fortify_handler call.
* debug/test-strcpy_chk.c: Likewise.
diff --git a/debug/Makefile b/debug/Makefile
index ab06c17..fc15ef3 100644
--- a/debug/Makefile
+++ b/debug/Makefile
@@ -90,6 +90,8 @@ CFLAGS-tst-longjmp_chk.c = -fexceptions -fasynchronous-unwind-tables
CPPFLAGS-tst-longjmp_chk.c = -D_FORTIFY_SOURCE=1
CFLAGS-tst-longjmp_chk2.c = -fexceptions -fasynchronous-unwind-tables
CPPFLAGS-tst-longjmp_chk2.c = -D_FORTIFY_SOURCE=1
+CFLAGS-tst-longjmp_chk3.c = -fexceptions -fasynchronous-unwind-tables
+CPPFLAGS-tst-longjmp_chk3.c = -D_FORTIFY_SOURCE=1
# We know these tests have problems with format strings, this is what
# we are testing. Disable that warning.
diff --git a/debug/tst-longjmp_chk3.c b/debug/tst-longjmp_chk3.c
new file mode 100644
index 0000000..f0f67e5
--- /dev/null
+++ b/debug/tst-longjmp_chk3.c
@@ -0,0 +1,85 @@
+/* Make sure longjmp fortification catches bad signal stacks.
+ Copyright (C) 2013-2014 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ 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.
+
+ 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.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <setjmp.h>
+#include <signal.h>
+#include <string.h>
+
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
+
+static char buf[SIGSTKSZ * 4];
+static jmp_buf jb;
+
+static void
+handler (int sig)
+{
+ if (sig == SIGUSR1)
+ {
+ if (setjmp (jb) != 0)
+ {
+ puts ("setjmp should not have been called");
+ kill (getpid (), SIGTERM);
+ }
+ }
+ else if (sig == SIGABRT)
+ {
+ /* Yeah it worked. */
+ _exit (0);
+ }
+}
+
+static int
+do_test (void)
+{
+ stack_t ss;
+
+ set_fortify_handler (handler);
+
+ /* Create a valid signal stack and enable it. */
+ ss.ss_sp = buf;
+ ss.ss_size = sizeof (buf);
+ ss.ss_flags = 0;
+ if (sigaltstack (&ss, NULL) < 0)
+ {
+ printf ("first sigaltstack failed: %m\n");
+ return 1;
+ }
+
+ /* Trigger the signal handler which will create a jmpbuf that points to the
+ end of the signal stack. */
+ signal (SIGUSR1, handler);
+ kill (getpid (), SIGUSR1);
+
+ /* Shrink the signal stack so the jmpbuf is now invalid.
+ We adjust the start & end to handle stacks that grow up & down. */
+ ss.ss_sp = buf + sizeof (buf) / 2;
+ ss.ss_size = sizeof (buf) / 4;
+ if (sigaltstack (&ss, NULL) < 0)
+ {
+ printf ("second sigaltstack failed: %m\n");
+ return 1;
+ }
+
+ /* This should fail. */
+ longjmp (jb, 1);
+
+ puts ("longjmp returned and shouldn't");
+ return 1;
+}
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=c5bb8e2399f55c09a98c66936940ba744b5841da
commit c5bb8e2399f55c09a98c66936940ba744b5841da
Author: Mike Frysinger <vapier@gentoo.org>
Date: Sun Dec 29 23:13:20 2013 +0000
tests: unify fortification handler logic
We have multiple tests that copy & paste the same logic for disabling the
fortification output. Let's unify this in the test-skeleton instead.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
diff --git a/ChangeLog b/ChangeLog
index 4e0aab0..610eef6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2014-02-08 Mike Frysinger <vapier@gentoo.org>
+ * benchtests/bench-strcpy_chk.c: Move test-skeleton.c to top.
+ (test_main): Replace code with set_fortify_handler call.
+ * debug/test-strcpy_chk.c: Likewise.
+ * debug/tst-chk1.c: Likewise.
+ * debug/tst-longjmp_chk.c: Likewise.
+ * test-skeleton.c: Include fcntl.h & paths.h
+ (set_fortify_handler): Define.
+
+2014-02-08 Mike Frysinger <vapier@gentoo.org>
+
* debug/tst-longjmp_chk.c: Add header comment and include
../test-skeleton.c.
(do_test): Mark static.
diff --git a/benchtests/bench-strcpy_chk.c b/benchtests/bench-strcpy_chk.c
index 8accb61..828c9bc 100644
--- a/benchtests/bench-strcpy_chk.c
+++ b/benchtests/bench-strcpy_chk.c
@@ -53,6 +53,9 @@ simple_strcpy_chk (char *dst, const char *src, size_t len)
#include <setjmp.h>
#include <signal.h>
+static int test_main (void);
+#include "../test-skeleton.c"
+
volatile int chk_fail_ok;
jmp_buf chk_fail_buf;
@@ -156,28 +159,12 @@ do_test (size_t align1, size_t align2, size_t len, size_t dlen, int max_char)
putchar ('\n');
}
-int
+static int
test_main (void)
{
size_t i;
- struct sigaction sa;
- sa.sa_handler = handler;
- sa.sa_flags = 0;
- sigemptyset (&sa.sa_mask);
-
- sigaction (SIGABRT, &sa, NULL);
-
- /* Avoid all the buffer overflow messages on stderr. */
- int fd = open (_PATH_DEVNULL, O_WRONLY);
- if (fd == -1)
- close (STDERR_FILENO);
- else
- {
- dup2 (fd, STDERR_FILENO);
- close (fd);
- }
- setenv ("LIBC_FATAL_STDERR_", "1", 1);
+ set_fortify_handler (handler);
test_init ();
@@ -254,5 +241,3 @@ test_main (void)
return 0;
}
-
-#include "../test-skeleton.c"
diff --git a/debug/test-strcpy_chk.c b/debug/test-strcpy_chk.c
index 62a581d..0e683be 100644
--- a/debug/test-strcpy_chk.c
+++ b/debug/test-strcpy_chk.c
@@ -54,6 +54,10 @@ simple_strcpy_chk (char *dst, const char *src, size_t len)
#include <setjmp.h>
#include <signal.h>
+static int test_main (void);
+#define TEST_FUNCTION test_main ()
+#include "../test-skeleton.c"
+
volatile int chk_fail_ok;
jmp_buf chk_fail_buf;
@@ -266,28 +270,12 @@ Iteration %zd - different strings, %s (%zd, %zd, %zd)\n",
}
}
-int
+static int
test_main (void)
{
size_t i;
- struct sigaction sa;
- sa.sa_handler = handler;
- sa.sa_flags = 0;
- sigemptyset (&sa.sa_mask);
-
- sigaction (SIGABRT, &sa, NULL);
-
- /* Avoid all the buffer overflow messages on stderr. */
- int fd = open (_PATH_DEVNULL, O_WRONLY);
- if (fd == -1)
- close (STDERR_FILENO);
- else
- {
- dup2 (fd, STDERR_FILENO);
- close (fd);
- }
- setenv ("LIBC_FATAL_STDERR_", "1", 1);
+ set_fortify_handler (handler);
test_init ();
@@ -365,5 +353,3 @@ test_main (void)
do_random_tests ();
return ret;
}
-
-#include "../test-skeleton.c"
diff --git a/debug/tst-chk1.c b/debug/tst-chk1.c
index f0b86a0..3393153 100644
--- a/debug/tst-chk1.c
+++ b/debug/tst-chk1.c
@@ -20,7 +20,6 @@
#include <fcntl.h>
#include <locale.h>
#include <obstack.h>
-#include <paths.h>
#include <setjmp.h>
#include <signal.h>
#include <stdio.h>
@@ -119,23 +118,7 @@ int num2 = 987654;
static int
do_test (void)
{
- struct sigaction sa;
- sa.sa_handler = handler;
- sa.sa_flags = 0;
- sigemptyset (&sa.sa_mask);
-
- sigaction (SIGABRT, &sa, NULL);
-
- /* Avoid all the buffer overflow messages on stderr. */
- int fd = open (_PATH_DEVNULL, O_WRONLY);
- if (fd == -1)
- close (STDERR_FILENO);
- else
- {
- dup2 (fd, STDERR_FILENO);
- close (fd);
- }
- setenv ("LIBC_FATAL_STDERR_", "1", 1);
+ set_fortify_handler (handler);
struct A { char buf1[9]; char buf2[1]; } a;
struct wA { wchar_t buf1[9]; wchar_t buf2[1]; } wa;
@@ -1366,7 +1349,7 @@ do_test (void)
ret = 1;
}
- fd = posix_openpt (O_RDWR);
+ int fd = posix_openpt (O_RDWR);
if (fd != -1)
{
char enough[1000];
diff --git a/debug/tst-longjmp_chk.c b/debug/tst-longjmp_chk.c
index dba1855..e4e93d2 100644
--- a/debug/tst-longjmp_chk.c
+++ b/debug/tst-longjmp_chk.c
@@ -10,6 +10,12 @@
#include <stdlib.h>
#include <unistd.h>
+
+static int do_test(void);
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
+
+
static jmp_buf b;
@@ -48,23 +54,7 @@ handler (int sig)
static int
do_test (void)
{
- struct sigaction sa;
- sa.sa_handler = handler;
- sa.sa_flags = 0;
- sigemptyset (&sa.sa_mask);
-
- sigaction (SIGABRT, &sa, NULL);
-
- /* Avoid all the buffer overflow messages on stderr. */
- int fd = open (_PATH_DEVNULL, O_WRONLY);
- if (fd == -1)
- close (STDERR_FILENO);
- else
- {
- dup2 (fd, STDERR_FILENO);
- close (fd);
- }
- setenv ("LIBC_FATAL_STDERR_", "1", 1);
+ set_fortify_handler (handler);
expected_to_fail = false;
@@ -86,6 +76,3 @@ do_test (void)
puts ("second longjmp returned");
return 1;
}
-
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
diff --git a/test-skeleton.c b/test-skeleton.c
index b08cfb5..d7d2f75 100644
--- a/test-skeleton.c
+++ b/test-skeleton.c
@@ -18,8 +18,10 @@
<http://www.gnu.org/licenses/>. */
#include <errno.h>
+#include <fcntl.h>
#include <getopt.h>
#include <malloc.h>
+#include <paths.h>
#include <search.h>
#include <signal.h>
#include <stdio.h>
@@ -194,6 +196,32 @@ signal_handler (int sig __attribute__ ((unused)))
exit (1);
}
+/* Set fortification error handler. Used when tests want to verify that bad
+ code is caught by the library. */
+static void
+__attribute__ ((unused))
+set_fortify_handler (void (*handler) (int sig))
+{
+ struct sigaction sa;
+
+ sa.sa_handler = handler;
+ sa.sa_flags = 0;
+ sigemptyset (&sa.sa_mask);
+
+ sigaction (SIGABRT, &sa, NULL);
+
+ /* Avoid all the buffer overflow messages on stderr. */
+ int fd = open (_PATH_DEVNULL, O_WRONLY);
+ if (fd == -1)
+ close (STDERR_FILENO);
+ else
+ {
+ dup2 (fd, STDERR_FILENO);
+ close (fd);
+ }
+ setenv ("LIBC_FATAL_STDERR_", "1", 1);
+}
+
/* We provide the entry point here. */
int
main (int argc, char *argv[])
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=10444e425e539ec12e42415756b0a874413ce94a
commit 10444e425e539ec12e42415756b0a874413ce94a
Author: Mike Frysinger <vapier@gentoo.org>
Date: Sun Dec 29 22:19:45 2013 +0000
tst-longjmp_chk: add comments and convert to test-skeleton
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
diff --git a/ChangeLog b/ChangeLog
index aefcb38..4e0aab0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2014-02-08 Mike Frysinger <vapier@gentoo.org>
+ * debug/tst-longjmp_chk.c: Add header comment and include
+ ../test-skeleton.c.
+ (do_test): Mark static.
+ (TEST_FUNCTION): Define.
+
+2014-02-08 Mike Frysinger <vapier@gentoo.org>
+
* sysdeps/unix/sysv/linux/bits/in.h (IP_NODEFRAG): Define.
(IP_PMTUDISC_INTERFACE): Likewise.
(IP_MULTICAST_IF): Likewise.
diff --git a/debug/tst-longjmp_chk.c b/debug/tst-longjmp_chk.c
index 8892974..dba1855 100644
--- a/debug/tst-longjmp_chk.c
+++ b/debug/tst-longjmp_chk.c
@@ -1,3 +1,5 @@
+/* Basic test to make sure doing a longjmp to a jmpbuf with an invalid sp
+ is caught by the fortification code. */
#include <errno.h>
#include <fcntl.h>
#include <paths.h>
@@ -43,8 +45,8 @@ handler (int sig)
}
-int
-main (void)
+static int
+do_test (void)
{
struct sigaction sa;
sa.sa_handler = handler;
@@ -84,3 +86,6 @@ main (void)
puts ("second longjmp returned");
return 1;
}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=1e805e8db596a4e09e33aeba94aad568a365d110
commit 1e805e8db596a4e09e33aeba94aad568a365d110
Author: Mike Frysinger <vapier@gentoo.org>
Date: Sat Feb 8 06:57:48 2014 -0500
linux: bits/in.h: sync with latest kernel headers
Forgot to include ChangeLog update.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
diff --git a/ChangeLog b/ChangeLog
index 6aaca42..aefcb38 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,29 @@
2014-02-08 Mike Frysinger <vapier@gentoo.org>
+ * sysdeps/unix/sysv/linux/bits/in.h (IP_NODEFRAG): Define.
+ (IP_PMTUDISC_INTERFACE): Likewise.
+ (IP_MULTICAST_IF): Likewise.
+ (IP_MULTICAST_TTL): Likewise.
+ (IP_MULTICAST_LOOP): Likewise.
+ (IP_ADD_MEMBERSHIP): Likewise.
+ (IP_DROP_MEMBERSHIP): Likewise.
+ (IP_UNBLOCK_SOURCE): Likewise.
+ (IP_BLOCK_SOURCE): Likewise.
+ (IP_ADD_SOURCE_MEMBERSHIP): Likewise.
+ (IP_DROP_SOURCE_MEMBERSHIP): Likewise.
+ (IP_MSFILTER): Likewise.
+ (MCAST_JOIN_GROUP): Likewise.
+ (MCAST_BLOCK_SOURCE): Likewise.
+ (MCAST_UNBLOCK_SOURCE): Likewise.
+ (MCAST_LEAVE_GROUP): Likewise.
+ (MCAST_JOIN_SOURCE_GROUP): Likewise.
+ (MCAST_LEAVE_SOURCE_GROUP): Likewise.
+ (MCAST_MSFILTER): Likewise.
+ (IP_MULTICAST_ALL): Likewise.
+ (IP_UNICAST_IF): Likewise.
+
+2014-02-08 Mike Frysinger <vapier@gentoo.org>
+
* timezone/Makefile: Delete $(have-ksh) check.
($(objpfx)tzselect): Change $(KSH) to $(BASH).
* timezone/tzselect.ksh: Add +x mode bits.
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 52 +++++++++++++++++++++++++
benchtests/bench-strcpy_chk.c | 25 ++----------
debug/Makefile | 2 +
debug/test-strcpy_chk.c | 26 +++----------
debug/tst-backtrace4.c | 15 ++++---
debug/tst-chk1.c | 21 +---------
debug/tst-longjmp_chk.c | 30 +++++---------
debug/tst-longjmp_chk3.c | 85 +++++++++++++++++++++++++++++++++++++++++
test-skeleton.c | 28 +++++++++++++
9 files changed, 199 insertions(+), 85 deletions(-)
create mode 100644 debug/tst-longjmp_chk3.c
hooks/post-receive
--
GNU C Library master sources