aboutsummaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorRyan S. Arnold <rsa@us.ibm.com>2010-12-19 22:49:01 -0500
committerUlrich Drepper <drepper@gmail.com>2010-12-19 22:49:01 -0500
commit30950a5fd2346c43ba4fc59c16f122cfb59f9629 (patch)
tree400aceac60bdb17ec66caf2850d173ad8554e135 /elf
parentdb753e2cfb2051ebf20dc089f87c5b1297cc2cff (diff)
downloadglibc-30950a5fd2346c43ba4fc59c16f122cfb59f9629.tar
glibc-30950a5fd2346c43ba4fc59c16f122cfb59f9629.tar.gz
glibc-30950a5fd2346c43ba4fc59c16f122cfb59f9629.tar.bz2
glibc-30950a5fd2346c43ba4fc59c16f122cfb59f9629.zip
Make PowerPC64 default to nonexecutable stack
Diffstat (limited to 'elf')
-rw-r--r--elf/Makefile8
-rw-r--r--elf/check-execstack.c13
-rw-r--r--elf/dl-load.c6
-rw-r--r--elf/dl-support.c6
-rw-r--r--elf/rtld.c6
5 files changed, 28 insertions, 11 deletions
diff --git a/elf/Makefile b/elf/Makefile
index b0420f50ef..bba6493084 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -899,8 +899,14 @@ $(objpfx)check-textrel: check-textrel.c
$(native-compile)
check-execstack-CFLAGS = -O -Wall -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -std=gnu99
+# Perform the same operation as $(native-compile) but add the sysdeps
+# directories as header search locations.
$(objpfx)check-execstack: check-execstack.c
- $(native-compile)
+ $(make-target-directory)
+ $(patsubst %/,cd % &&,$(objpfx)) \
+ $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
+ $(addprefix -I$(shell pwd)/,$(sysdirs)) -I$(shell pwd) \
+ $(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(@F)
check-localplt-CFLAGS = -O -Wall -D_GNU_SOURCE -std=gnu99
$(objpfx)check-localplt: check-localplt.c
diff --git a/elf/check-execstack.c b/elf/check-execstack.c
index 55cf48721a..64353751e9 100644
--- a/elf/check-execstack.c
+++ b/elf/check-execstack.c
@@ -1,5 +1,5 @@
/* Check for executable stacks in DSOs.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contribute by Ulrich Drepper <drepper@redhat.com>. 2009.
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <stackinfo.h>
#ifdef BITS
@@ -150,9 +151,13 @@ main (int argc, char *argv[])
int cnt;
int result = 0;
- for (cnt = 1; cnt < argc; ++cnt)
- result |= handle_file (argv[cnt]);
-
+ /* We can return successfully, i.e., not fail, if PF_X isn't present. If it
+ * is present then check for the GNU_STACK header. */
+ if (DEFAULT_STACK_PERMS & PF_X)
+ {
+ for (cnt = 1; cnt < argc; ++cnt)
+ result |= handle_file (argv[cnt]);
+ }
return result;
}
#endif
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 4c14f08e55..41b5ce7691 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -984,8 +984,10 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
}
}
- /* Presumed absent PT_GNU_STACK. */
- uint_fast16_t stack_flags = PF_R|PF_W|PF_X;
+ /* On most platforms presume that PT_GNU_STACK is absent and the stack is
+ * executable. Other platforms default to a nonexecutable stack and don't
+ * need PT_GNU_STACK to do so. */
+ uint_fast16_t stack_flags = DEFAULT_STACK_PERMS;
{
/* Scan the program header table, collecting its load commands. */
diff --git a/elf/dl-support.c b/elf/dl-support.c
index 5897b32e8c..1b128c37ff 100644
--- a/elf/dl-support.c
+++ b/elf/dl-support.c
@@ -32,6 +32,7 @@
#include <dl-procinfo.h>
#include <unsecvars.h>
#include <hp-timing.h>
+#include <stackinfo.h>
extern char *__progname;
char **_dl_argv = &__progname; /* This is checked for some error messages. */
@@ -134,8 +135,9 @@ uint64_t _dl_hwcap __attribute__ ((nocommon));
setting _dl_hwcap nonzero below, but we do anyway. */
uint64_t _dl_hwcap_mask __attribute__ ((nocommon));
-/* Prevailing state of the stack, PF_X indicating it's executable. */
-ElfW(Word) _dl_stack_flags = PF_R|PF_W|PF_X;
+/* Prevailing state of the stack. Generally this includes PF_X, indicating it's
+ * executable but this isn't true for all platforms. */
+ElfW(Word) _dl_stack_flags = DEFAULT_STACK_PERMS;
/* If loading a shared object requires that we make the stack executable
when it was not, we do it by calling this function.
diff --git a/elf/rtld.c b/elf/rtld.c
index d53730fe30..851038089c 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -40,6 +40,7 @@
#include <dl-osinfo.h>
#include <dl-procinfo.h>
#include <tls.h>
+#include <stackinfo.h>
#include <assert.h>
@@ -122,8 +123,9 @@ INTVARDEF(_dl_starting_up)
(except those which cannot be added for some reason). */
struct rtld_global _rtld_global =
{
- /* Default presumption without further information is executable stack. */
- ._dl_stack_flags = PF_R|PF_W|PF_X,
+ /* Generally the default presumption without further information is an
+ * executable stack but this is not true for all platforms. */
+ ._dl_stack_flags = DEFAULT_STACK_PERMS,
#ifdef _LIBC_REENTRANT
._dl_load_lock = _RTLD_LOCK_RECURSIVE_INITIALIZER,
._dl_load_write_lock = _RTLD_LOCK_RECURSIVE_INITIALIZER,