|
|
ce426f |
#
|
|
|
ce426f |
# As of 2013-08-09 this patch is posted upstream here, but not checked in yet:
|
|
|
ce426f |
# http://sourceware.org/ml/libc-alpha/2013-07/msg00367.html
|
|
|
ce426f |
# http://sourceware.org/ml/libc-alpha/2013-08/msg00057.html
|
|
|
ce426f |
#
|
|
|
ce426f |
# Red Hat bug:
|
|
|
ce426f |
# https://bugzilla.redhat.com/show_bug.cgi?id=990481
|
|
|
ce426f |
#
|
|
|
ce426f |
# Upstream bug:
|
|
|
ce426f |
# http://sourceware.org/bugzilla/show_bug.cgi?id=15754
|
|
|
ce426f |
#
|
|
|
ce426f |
# 2013-07-19 Carlos O'Donell <carlos@redhat.com>
|
|
|
ce426f |
#
|
|
|
ce426f |
# [BZ #15754]
|
|
|
ce426f |
# * elf/Makefile (tests): Add tst-ptrguard1.
|
|
|
ce426f |
# (tests-static): Add tst-ptrguard1-static.
|
|
|
ce426f |
# (tst-ptrguard1-ARGS): Define.
|
|
|
ce426f |
# (tst-ptrguard1-static-ARGS): Define.
|
|
|
ce426f |
# * elf/tst-ptrguard1.c: New file.
|
|
|
ce426f |
# * elf/tst-ptrguard1-static.c: New file.
|
|
|
ce426f |
# * sysdeps/x86_64/stackguard-macros.h: Define POINTER_CHK_GUARD.
|
|
|
ce426f |
# * sysdeps/i386/stackguard-macros.h: Likewise.
|
|
|
ce426f |
# * sysdeps/powerpc/powerpc32/stackguard-macros.h: Likewise.
|
|
|
ce426f |
# * sysdeps/powerpc/powerpc64/stackguard-macros.h: Likewise.
|
|
|
ce426f |
# * sysdeps/s390/s390-32/stackguard-macros.h: Likewise.
|
|
|
ce426f |
# * sysdeps/s390/s390-64/stackguard-macros.h: Likewise.
|
|
|
ce426f |
#
|
|
|
ce426f |
# 2013-07-19 Hector Marco <hecmargi@upv.es>
|
|
|
ce426f |
# Ismael Ripoll <iripoll@disca.upv.es>
|
|
|
ce426f |
# Carlos O'Donell <carlos@redhat.com>
|
|
|
ce426f |
#
|
|
|
ce426f |
# [BZ #15754]
|
|
|
ce426f |
# * sysdeps/generic/stackguard-macros.h: Define __pointer_chk_guard_local
|
|
|
ce426f |
# and POINTER_CHK_GUARD.
|
|
|
ce426f |
# * csu/libc-start.c [!SHARED && !THREAD_SET_POINTER_GUARD]:
|
|
|
ce426f |
# Define __pointer_chk_guard_local.
|
|
|
ce426f |
# (LIBC_START_MAIN) [!SHARED]: Call _dl_setup_pointer_guard.
|
|
|
ce426f |
# Use THREAD_SET_POINTER_GUARD or set __pointer_chk_guard_local.
|
|
|
ce426f |
#
|
|
|
ce426f |
diff -urN glibc-2.17-c758a686/csu/libc-start.c glibc-2.17-c758a686/csu/libc-start.c
|
|
|
ce426f |
--- glibc-2.17-c758a686/csu/libc-start.c 2013-08-09 17:40:41.662856773 -0400
|
|
|
ce426f |
+++ glibc-2.17-c758a686/csu/libc-start.c 2013-08-09 17:53:40.383236966 -0400
|
|
|
ce426f |
@@ -38,6 +38,12 @@
|
|
|
ce426f |
in thread local area. */
|
|
|
ce426f |
uintptr_t __stack_chk_guard attribute_relro;
|
|
|
ce426f |
# endif
|
|
|
ce426f |
+# ifndef THREAD_SET_POINTER_GUARD
|
|
|
ce426f |
+/* Only exported for architectures that don't store the pointer guard
|
|
|
ce426f |
+ value in thread local area. */
|
|
|
ce426f |
+uintptr_t __pointer_chk_guard_local
|
|
|
ce426f |
+ attribute_relro attribute_hidden __attribute__ ((nocommon));
|
|
|
ce426f |
+# endif
|
|
|
ce426f |
#endif
|
|
|
ce426f |
|
|
|
ce426f |
#ifdef HAVE_PTR_NTHREADS
|
|
|
ce426f |
@@ -184,6 +190,16 @@
|
|
|
ce426f |
# else
|
|
|
ce426f |
__stack_chk_guard = stack_chk_guard;
|
|
|
ce426f |
# endif
|
|
|
ce426f |
+
|
|
|
ce426f |
+ /* Set up the pointer guard value. */
|
|
|
ce426f |
+ uintptr_t pointer_chk_guard = _dl_setup_pointer_guard (_dl_random,
|
|
|
ce426f |
+ stack_chk_guard);
|
|
|
ce426f |
+# ifdef THREAD_SET_POINTER_GUARD
|
|
|
ce426f |
+ THREAD_SET_POINTER_GUARD (pointer_chk_guard);
|
|
|
ce426f |
+# else
|
|
|
ce426f |
+ __pointer_chk_guard_local = pointer_chk_guard;
|
|
|
ce426f |
+# endif
|
|
|
ce426f |
+
|
|
|
ce426f |
#endif
|
|
|
ce426f |
|
|
|
ce426f |
/* Register the destructor of the dynamic linker if there is any. */
|
|
|
ce426f |
diff -urN glibc-2.17-c758a686/elf/Makefile glibc-2.17-c758a686/elf/Makefile
|
|
|
ce426f |
--- glibc-2.17-c758a686/elf/Makefile 2013-08-09 17:40:41.757856472 -0400
|
|
|
ce426f |
+++ glibc-2.17-c758a686/elf/Makefile 2013-08-09 17:53:40.383236966 -0400
|
|
|
ce426f |
@@ -121,7 +121,8 @@
|
|
|
ce426f |
tests = tst-tls1 tst-tls2 tst-tls9 tst-leaks1 \
|
|
|
ce426f |
tst-array1 tst-array2 tst-array3 tst-array4 tst-array5
|
|
|
ce426f |
tests-static = tst-tls1-static tst-tls2-static tst-stackguard1-static \
|
|
|
ce426f |
- tst-leaks1-static tst-array1-static tst-array5-static
|
|
|
ce426f |
+ tst-leaks1-static tst-array1-static tst-array5-static \
|
|
|
ce426f |
+ tst-ptrguard1-static
|
|
|
ce426f |
ifeq (yes,$(build-shared))
|
|
|
ce426f |
tests-static += tst-tls9-static
|
|
|
ce426f |
tst-tls9-static-ENV = \
|
|
|
ce426f |
@@ -145,7 +146,7 @@
|
|
|
ce426f |
tst-audit1 tst-audit2 tst-audit8 tst-audit9 \
|
|
|
ce426f |
tst-stackguard1 tst-addr1 tst-thrlock \
|
|
|
ce426f |
tst-unique1 tst-unique2 tst-unique3 tst-unique4 \
|
|
|
ce426f |
- tst-initorder tst-initorder2 tst-relsort1
|
|
|
ce426f |
+ tst-initorder tst-initorder2 tst-relsort1 tst-ptrguard1
|
|
|
ce426f |
# reldep9
|
|
|
ce426f |
test-srcs = tst-pathopt
|
|
|
ce426f |
selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
|
|
|
ce426f |
@@ -1062,6 +1063,9 @@
|
|
|
ce426f |
tst-stackguard1-ARGS = --command "$(host-built-program-cmd) --child"
|
|
|
ce426f |
tst-stackguard1-static-ARGS = --command "$(objpfx)tst-stackguard1-static --child"
|
|
|
ce426f |
|
|
|
ce426f |
+tst-ptrguard1-ARGS = --command "$(host-built-program-cmd) --child"
|
|
|
ce426f |
+tst-ptrguard1-static-ARGS = --command "$(objpfx)tst-ptrguard1-static --child"
|
|
|
ce426f |
+
|
|
|
ce426f |
$(objpfx)tst-leaks1: $(libdl)
|
|
|
ce426f |
$(objpfx)tst-leaks1-mem: $(objpfx)tst-leaks1.out
|
|
|
ce426f |
$(common-objpfx)malloc/mtrace $(objpfx)tst-leaks1.mtrace > $@
|
|
|
ce426f |
diff -urN glibc-2.17-c758a686/elf/tst-ptrguard1.c glibc-2.17-c758a686/elf/tst-ptrguard1.c
|
|
|
ce426f |
--- glibc-2.17-c758a686/elf/tst-ptrguard1.c 1969-12-31 19:00:00.000000000 -0500
|
|
|
ce426f |
+++ glibc-2.17-c758a686/elf/tst-ptrguard1.c 2013-08-09 17:53:40.383236966 -0400
|
|
|
ce426f |
@@ -0,0 +1,202 @@
|
|
|
ce426f |
+/* Copyright (C) 2013 Free Software Foundation, Inc.
|
|
|
ce426f |
+ This file is part of the GNU C Library.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
ce426f |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
ce426f |
+ License as published by the Free Software Foundation; either
|
|
|
ce426f |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
ce426f |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
ce426f |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
ce426f |
+ Lesser General Public License for more details.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
ce426f |
+ License along with the GNU C Library; if not, see
|
|
|
ce426f |
+ <http://www.gnu.org/licenses/>. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+#include <errno.h>
|
|
|
ce426f |
+#include <stdbool.h>
|
|
|
ce426f |
+#include <stdio.h>
|
|
|
ce426f |
+#include <stdlib.h>
|
|
|
ce426f |
+#include <string.h>
|
|
|
ce426f |
+#include <sys/wait.h>
|
|
|
ce426f |
+#include <stackguard-macros.h>
|
|
|
ce426f |
+#include <tls.h>
|
|
|
ce426f |
+#include <unistd.h>
|
|
|
ce426f |
+
|
|
|
ce426f |
+#ifndef POINTER_CHK_GUARD
|
|
|
ce426f |
+extern uintptr_t __pointer_chk_guard_local;
|
|
|
ce426f |
+# define POINTER_CHK_GUARD __pointer_chk_guard_local
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
+
|
|
|
ce426f |
+static const char *command;
|
|
|
ce426f |
+static bool child;
|
|
|
ce426f |
+static uintptr_t ptr_chk_guard_copy;
|
|
|
ce426f |
+static bool ptr_chk_guard_copy_set;
|
|
|
ce426f |
+static int fds[2];
|
|
|
ce426f |
+
|
|
|
ce426f |
+static void __attribute__ ((constructor))
|
|
|
ce426f |
+con (void)
|
|
|
ce426f |
+{
|
|
|
ce426f |
+ ptr_chk_guard_copy = POINTER_CHK_GUARD;
|
|
|
ce426f |
+ ptr_chk_guard_copy_set = true;
|
|
|
ce426f |
+}
|
|
|
ce426f |
+
|
|
|
ce426f |
+static int
|
|
|
ce426f |
+uintptr_t_cmp (const void *a, const void *b)
|
|
|
ce426f |
+{
|
|
|
ce426f |
+ if (*(uintptr_t *) a < *(uintptr_t *) b)
|
|
|
ce426f |
+ return 1;
|
|
|
ce426f |
+ if (*(uintptr_t *) a > *(uintptr_t *) b)
|
|
|
ce426f |
+ return -1;
|
|
|
ce426f |
+ return 0;
|
|
|
ce426f |
+}
|
|
|
ce426f |
+
|
|
|
ce426f |
+static int
|
|
|
ce426f |
+do_test (void)
|
|
|
ce426f |
+{
|
|
|
ce426f |
+ if (!ptr_chk_guard_copy_set)
|
|
|
ce426f |
+ {
|
|
|
ce426f |
+ puts ("constructor has not been run");
|
|
|
ce426f |
+ return 1;
|
|
|
ce426f |
+ }
|
|
|
ce426f |
+
|
|
|
ce426f |
+ if (ptr_chk_guard_copy != POINTER_CHK_GUARD)
|
|
|
ce426f |
+ {
|
|
|
ce426f |
+ puts ("POINTER_CHK_GUARD changed between constructor and do_test");
|
|
|
ce426f |
+ return 1;
|
|
|
ce426f |
+ }
|
|
|
ce426f |
+
|
|
|
ce426f |
+ if (child)
|
|
|
ce426f |
+ {
|
|
|
ce426f |
+ write (2, &ptr_chk_guard_copy, sizeof (ptr_chk_guard_copy));
|
|
|
ce426f |
+ return 0;
|
|
|
ce426f |
+ }
|
|
|
ce426f |
+
|
|
|
ce426f |
+ if (command == NULL)
|
|
|
ce426f |
+ {
|
|
|
ce426f |
+ puts ("missing --command or --child argument");
|
|
|
ce426f |
+ return 1;
|
|
|
ce426f |
+ }
|
|
|
ce426f |
+
|
|
|
ce426f |
+#define N 16
|
|
|
ce426f |
+ uintptr_t child_ptr_chk_guards[N + 1];
|
|
|
ce426f |
+ child_ptr_chk_guards[N] = ptr_chk_guard_copy;
|
|
|
ce426f |
+ int i;
|
|
|
ce426f |
+ for (i = 0; i < N; ++i)
|
|
|
ce426f |
+ {
|
|
|
ce426f |
+ if (pipe (fds) < 0)
|
|
|
ce426f |
+ {
|
|
|
ce426f |
+ printf ("couldn't create pipe: %m\n");
|
|
|
ce426f |
+ return 1;
|
|
|
ce426f |
+ }
|
|
|
ce426f |
+
|
|
|
ce426f |
+ pid_t pid = fork ();
|
|
|
ce426f |
+ if (pid < 0)
|
|
|
ce426f |
+ {
|
|
|
ce426f |
+ printf ("fork failed: %m\n");
|
|
|
ce426f |
+ return 1;
|
|
|
ce426f |
+ }
|
|
|
ce426f |
+
|
|
|
ce426f |
+ if (!pid)
|
|
|
ce426f |
+ {
|
|
|
ce426f |
+ if (ptr_chk_guard_copy != POINTER_CHK_GUARD)
|
|
|
ce426f |
+ {
|
|
|
ce426f |
+ puts ("POINTER_CHK_GUARD changed after fork");
|
|
|
ce426f |
+ exit (1);
|
|
|
ce426f |
+ }
|
|
|
ce426f |
+
|
|
|
ce426f |
+ close (fds[0]);
|
|
|
ce426f |
+ close (2);
|
|
|
ce426f |
+ dup2 (fds[1], 2);
|
|
|
ce426f |
+ close (fds[1]);
|
|
|
ce426f |
+
|
|
|
ce426f |
+ system (command);
|
|
|
ce426f |
+ exit (0);
|
|
|
ce426f |
+ }
|
|
|
ce426f |
+
|
|
|
ce426f |
+ close (fds[1]);
|
|
|
ce426f |
+
|
|
|
ce426f |
+ if (TEMP_FAILURE_RETRY (read (fds[0], &child_ptr_chk_guards[i],
|
|
|
ce426f |
+ sizeof (uintptr_t))) != sizeof (uintptr_t))
|
|
|
ce426f |
+ {
|
|
|
ce426f |
+ puts ("could not read ptr_chk_guard value from child");
|
|
|
ce426f |
+ return 1;
|
|
|
ce426f |
+ }
|
|
|
ce426f |
+
|
|
|
ce426f |
+ close (fds[0]);
|
|
|
ce426f |
+
|
|
|
ce426f |
+ pid_t termpid;
|
|
|
ce426f |
+ int status;
|
|
|
ce426f |
+ termpid = TEMP_FAILURE_RETRY (waitpid (pid, &status, 0));
|
|
|
ce426f |
+ if (termpid == -1)
|
|
|
ce426f |
+ {
|
|
|
ce426f |
+ printf ("waitpid failed: %m\n");
|
|
|
ce426f |
+ return 1;
|
|
|
ce426f |
+ }
|
|
|
ce426f |
+ else if (termpid != pid)
|
|
|
ce426f |
+ {
|
|
|
ce426f |
+ printf ("waitpid returned %ld != %ld\n",
|
|
|
ce426f |
+ (long int) termpid, (long int) pid);
|
|
|
ce426f |
+ return 1;
|
|
|
ce426f |
+ }
|
|
|
ce426f |
+ else if (!WIFEXITED (status) || WEXITSTATUS (status))
|
|
|
ce426f |
+ {
|
|
|
ce426f |
+ puts ("child hasn't exited with exit status 0");
|
|
|
ce426f |
+ return 1;
|
|
|
ce426f |
+ }
|
|
|
ce426f |
+ }
|
|
|
ce426f |
+
|
|
|
ce426f |
+ qsort (child_ptr_chk_guards, N + 1, sizeof (uintptr_t), uintptr_t_cmp);
|
|
|
ce426f |
+
|
|
|
ce426f |
+ /* The default pointer guard is the same as the default stack guard.
|
|
|
ce426f |
+ They are only set to default if dl_random is NULL. */
|
|
|
ce426f |
+ uintptr_t default_guard = 0;
|
|
|
ce426f |
+ unsigned char *p = (unsigned char *) &default_guard;
|
|
|
ce426f |
+ p[sizeof (uintptr_t) - 1] = 255;
|
|
|
ce426f |
+ p[sizeof (uintptr_t) - 2] = '\n';
|
|
|
ce426f |
+ p[0] = 0;
|
|
|
ce426f |
+
|
|
|
ce426f |
+ /* Test if the pointer guard canaries are either randomized,
|
|
|
ce426f |
+ or equal to the default pointer guard canary value.
|
|
|
ce426f |
+ Even with randomized pointer guards it might happen
|
|
|
ce426f |
+ that the random number generator generates the same
|
|
|
ce426f |
+ values, but if that happens in more than half from
|
|
|
ce426f |
+ the 16 runs, something is very wrong. */
|
|
|
ce426f |
+ int ndifferences = 0;
|
|
|
ce426f |
+ int ndefaults = 0;
|
|
|
ce426f |
+ for (i = 0; i < N; ++i)
|
|
|
ce426f |
+ {
|
|
|
ce426f |
+ if (child_ptr_chk_guards[i] != child_ptr_chk_guards[i+1])
|
|
|
ce426f |
+ ndifferences++;
|
|
|
ce426f |
+ else if (child_ptr_chk_guards[i] == default_guard)
|
|
|
ce426f |
+ ndefaults++;
|
|
|
ce426f |
+ }
|
|
|
ce426f |
+
|
|
|
ce426f |
+ printf ("differences %d defaults %d\n", ndifferences, ndefaults);
|
|
|
ce426f |
+
|
|
|
ce426f |
+ if (ndifferences < N / 2 && ndefaults < N / 2)
|
|
|
ce426f |
+ {
|
|
|
ce426f |
+ puts ("pointer guard canaries are not randomized enough");
|
|
|
ce426f |
+ puts ("nor equal to the default canary value");
|
|
|
ce426f |
+ return 1;
|
|
|
ce426f |
+ }
|
|
|
ce426f |
+
|
|
|
ce426f |
+ return 0;
|
|
|
ce426f |
+}
|
|
|
ce426f |
+
|
|
|
ce426f |
+#define OPT_COMMAND 10000
|
|
|
ce426f |
+#define OPT_CHILD 10001
|
|
|
ce426f |
+#define CMDLINE_OPTIONS \
|
|
|
ce426f |
+ { "command", required_argument, NULL, OPT_COMMAND }, \
|
|
|
ce426f |
+ { "child", no_argument, NULL, OPT_CHILD },
|
|
|
ce426f |
+#define CMDLINE_PROCESS \
|
|
|
ce426f |
+ case OPT_COMMAND: \
|
|
|
ce426f |
+ command = optarg; \
|
|
|
ce426f |
+ break; \
|
|
|
ce426f |
+ case OPT_CHILD: \
|
|
|
ce426f |
+ child = true; \
|
|
|
ce426f |
+ break;
|
|
|
ce426f |
+#define TEST_FUNCTION do_test ()
|
|
|
ce426f |
+#include "../test-skeleton.c"
|
|
|
ce426f |
diff -urN glibc-2.17-c758a686/elf/tst-ptrguard1-static.c glibc-2.17-c758a686/elf/tst-ptrguard1-static.c
|
|
|
ce426f |
--- glibc-2.17-c758a686/elf/tst-ptrguard1-static.c 1969-12-31 19:00:00.000000000 -0500
|
|
|
ce426f |
+++ glibc-2.17-c758a686/elf/tst-ptrguard1-static.c 2013-08-09 17:53:40.384236962 -0400
|
|
|
ce426f |
@@ -0,0 +1 @@
|
|
|
ce426f |
+#include "tst-ptrguard1.c"
|
|
|
ce426f |
diff -urN glibc-2.17-c758a686/sysdeps/generic/stackguard-macros.h glibc-2.17-c758a686/sysdeps/generic/stackguard-macros.h
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/generic/stackguard-macros.h 2013-08-09 17:40:41.917855965 -0400
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/generic/stackguard-macros.h 2013-08-09 17:53:40.384236962 -0400
|
|
|
ce426f |
@@ -2,3 +2,6 @@
|
|
|
ce426f |
|
|
|
ce426f |
extern uintptr_t __stack_chk_guard;
|
|
|
ce426f |
#define STACK_CHK_GUARD __stack_chk_guard
|
|
|
ce426f |
+
|
|
|
ce426f |
+extern uintptr_t __pointer_chk_guard_local;
|
|
|
ce426f |
+#define POINTER_CHK_GUARD __pointer_chk_guard_local
|
|
|
ce426f |
diff -urN glibc-2.17-c758a686/sysdeps/i386/stackguard-macros.h glibc-2.17-c758a686/sysdeps/i386/stackguard-macros.h
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/i386/stackguard-macros.h 2013-08-09 17:40:41.893856041 -0400
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/i386/stackguard-macros.h 2013-08-09 22:44:04.774298862 -0400
|
|
|
ce426f |
@@ -2,3 +2,11 @@
|
|
|
ce426f |
|
|
|
ce426f |
#define STACK_CHK_GUARD \
|
|
|
ce426f |
({ uintptr_t x; asm ("movl %%gs:0x14, %0" : "=r" (x)); x; })
|
|
|
ce426f |
+
|
|
|
ce426f |
+#define POINTER_CHK_GUARD \
|
|
|
ce426f |
+ ({ \
|
|
|
ce426f |
+ uintptr_t x; \
|
|
|
ce426f |
+ asm ("movl %%gs:%c1, %0" : "=r" (x) \
|
|
|
ce426f |
+ : "i" (offsetof (tcbhead_t, pointer_guard))); \
|
|
|
ce426f |
+ x; \
|
|
|
ce426f |
+ })
|
|
|
ce426f |
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/stackguard-macros.h glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/stackguard-macros.h
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/stackguard-macros.h 2013-08-09 17:40:42.006855683 -0400
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/stackguard-macros.h 2013-08-09 22:24:48.778793075 -0400
|
|
|
ce426f |
@@ -2,3 +2,13 @@
|
|
|
ce426f |
|
|
|
ce426f |
#define STACK_CHK_GUARD \
|
|
|
ce426f |
({ uintptr_t x; asm ("lwz %0,-28680(2)" : "=r" (x)); x; })
|
|
|
ce426f |
+
|
|
|
ce426f |
+#define POINTER_CHK_GUARD \
|
|
|
ce426f |
+ ({ \
|
|
|
ce426f |
+ uintptr_t x; \
|
|
|
ce426f |
+ asm ("lwz %0,%1(2)" \
|
|
|
ce426f |
+ : "=r" (x) \
|
|
|
ce426f |
+ : "i" (offsetof (tcbhead_t, pointer_guard) - TLS_TCB_OFFSET - sizeof (tcbhead_t)) \
|
|
|
ce426f |
+ ); \
|
|
|
ce426f |
+ x; \
|
|
|
ce426f |
+ })
|
|
|
ce426f |
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/stackguard-macros.h glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/stackguard-macros.h
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/stackguard-macros.h 2013-08-09 17:40:41.994855721 -0400
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/stackguard-macros.h 2013-08-09 22:24:47.831795865 -0400
|
|
|
ce426f |
@@ -2,3 +2,13 @@
|
|
|
ce426f |
|
|
|
ce426f |
#define STACK_CHK_GUARD \
|
|
|
ce426f |
({ uintptr_t x; asm ("ld %0,-28688(13)" : "=r" (x)); x; })
|
|
|
ce426f |
+
|
|
|
ce426f |
+#define POINTER_CHK_GUARD \
|
|
|
ce426f |
+ ({ \
|
|
|
ce426f |
+ uintptr_t x; \
|
|
|
ce426f |
+ asm ("ld %0,%1(13)" \
|
|
|
ce426f |
+ : "=r" (x) \
|
|
|
ce426f |
+ : "i" (offsetof (tcbhead_t, pointer_guard) - TLS_TCB_OFFSET - sizeof (tcbhead_t)) \
|
|
|
ce426f |
+ ); \
|
|
|
ce426f |
+ x; \
|
|
|
ce426f |
+ })
|
|
|
ce426f |
diff -urN glibc-2.17-c758a686/sysdeps/s390/s390-32/stackguard-macros.h glibc-2.17-c758a686/sysdeps/s390/s390-32/stackguard-macros.h
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/s390/s390-32/stackguard-macros.h 2013-08-09 17:40:42.059855515 -0400
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/s390/s390-32/stackguard-macros.h 2013-08-09 22:39:31.913120373 -0400
|
|
|
ce426f |
@@ -2,3 +2,15 @@
|
|
|
ce426f |
|
|
|
ce426f |
#define STACK_CHK_GUARD \
|
|
|
ce426f |
({ uintptr_t x; asm ("ear %0,%%a0; l %0,0x14(%0)" : "=a" (x)); x; })
|
|
|
ce426f |
+
|
|
|
ce426f |
+/* On s390/s390x there is no unique pointer guard, instead we use the
|
|
|
ce426f |
+ same value as the stack guard. */
|
|
|
ce426f |
+#define POINTER_CHK_GUARD \
|
|
|
ce426f |
+ ({ \
|
|
|
ce426f |
+ uintptr_t x; \
|
|
|
ce426f |
+ asm ("ear %0,%%a0; l %0,%1(%0)" \
|
|
|
ce426f |
+ : "=a" (x) \
|
|
|
ce426f |
+ : "i" (offsetof (tcbhead_t, stack_guard))); \
|
|
|
ce426f |
+ x; \
|
|
|
ce426f |
+ })
|
|
|
ce426f |
+
|
|
|
ce426f |
diff -urN glibc-2.17-c758a686/sysdeps/x86_64/stackguard-macros.h glibc-2.17-c758a686/sysdeps/x86_64/stackguard-macros.h
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/x86_64/stackguard-macros.h 2013-08-09 17:40:42.013855661 -0400
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/x86_64/stackguard-macros.h 2013-08-09 22:44:53.550153736 -0400
|
|
|
ce426f |
@@ -4,3 +4,11 @@
|
|
|
ce426f |
({ uintptr_t x; \
|
|
|
ce426f |
asm ("mov %%fs:%c1, %0" : "=r" (x) \
|
|
|
ce426f |
: "i" (offsetof (tcbhead_t, stack_guard))); x; })
|
|
|
ce426f |
+
|
|
|
ce426f |
+#define POINTER_CHK_GUARD \
|
|
|
ce426f |
+ ({ \
|
|
|
ce426f |
+ uintptr_t x; \
|
|
|
ce426f |
+ asm ("mov %%fs:%c1, %0" : "=r" (x) \
|
|
|
ce426f |
+ : "i" (offsetof (tcbhead_t, pointer_guard))); \
|
|
|
ce426f |
+ x; \
|
|
|
ce426f |
+ })
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/s390/s390-64/stackguard-macros.h 2013-08-09 17:40:42.057855522 -0400
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/s390/s390-64/stackguard-macros.h 2013-08-26 15:21:27.239043425 -0400
|
|
|
ce426f |
@@ -2,3 +2,17 @@
|
|
|
ce426f |
|
|
|
ce426f |
#define STACK_CHK_GUARD \
|
|
|
ce426f |
({ uintptr_t x; asm ("ear %0,%%a0; sllg %0,%0,32; ear %0,%%a1; lg %0,0x28(%0)" : "=a" (x)); x; })
|
|
|
ce426f |
+
|
|
|
ce426f |
+/* On s390/s390x there is no unique pointer guard, instead we use the
|
|
|
ce426f |
+ same value as the stack guard. */
|
|
|
ce426f |
+#define POINTER_CHK_GUARD \
|
|
|
ce426f |
+ ({ \
|
|
|
ce426f |
+ uintptr_t x; \
|
|
|
ce426f |
+ asm ("ear %0,%%a0;" \
|
|
|
ce426f |
+ "sllg %0,%0,32;" \
|
|
|
ce426f |
+ "ear %0,%%a1;" \
|
|
|
ce426f |
+ "lg %0,%1(%0)" \
|
|
|
ce426f |
+ : "=a" (x) \
|
|
|
ce426f |
+ : "i" (offsetof (tcbhead_t, stack_guard))); \
|
|
|
ce426f |
+ x; \
|
|
|
ce426f |
+ })
|