summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-02-07 23:52:23 +0000
committerUlrich Drepper <drepper@redhat.com>2005-02-07 23:52:23 +0000
commitecc1d0c301d97bdd540ff8d414a2eb4dcae51ea0 (patch)
tree25bf997247ab51a685f81445eca219026f7877bd
parent16cc1800298a4369111b7cba2c755dab3c969a98 (diff)
downloadglibc-ecc1d0c301d97bdd540ff8d414a2eb4dcae51ea0.tar.gz
* elf/dl-load.c (open_path): If rtld_search_dirs is in RELRO segment,
avoid writing to it if none of the standard search directories exist.
-rw-r--r--ChangeLog5
-rw-r--r--elf/dl-load.c17
2 files changed, 15 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 72b7a36ab9..14bb890be7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-01-07 Jakub Jelinek <jakub@redhat.com>
+
+ * elf/dl-load.c (open_path): If rtld_search_dirs is in RELRO segment,
+ avoid writing to it if none of the standard search directories exist.
+
2005-02-07 Steven Munroe <sjmunroe@us.ibm.com>
[BZ #700]
diff --git a/elf/dl-load.c b/elf/dl-load.c
index f74f98f91e..03b7f0b4ee 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -105,13 +105,11 @@ ELF_PREFERRED_ADDRESS_DATA;
int __stack_prot attribute_hidden attribute_relro
- = (PROT_READ|PROT_WRITE
#if _STACK_GROWS_DOWN && defined PROT_GROWSDOWN
- |PROT_GROWSDOWN
+ = PROT_GROWSDOWN;
#elif _STACK_GROWS_UP && defined PROT_GROWSUP
- |PROT_GROWSUP
+ = PROT_GROWSUP;
#endif
- );
/* Type for the buffer we put the ELF header and hopefully the program
@@ -1368,12 +1366,12 @@ cannot allocate TLS data structures for initial thread");
if (__builtin_expect (__check_caller (RETURN_ADDRESS (0),
allow_ldso) == 0,
0))
- __stack_prot |= PROT_EXEC;
+ __stack_prot |= PROT_READ|PROT_WRITE|PROT_EXEC;
__mprotect ((void *) p, s, PROT_READ);
}
else
#endif
- __stack_prot |= PROT_EXEC;
+ __stack_prot |= PROT_READ|PROT_WRITE|PROT_EXEC;
errval = (*GL(dl_make_stack_executable_hook)) (stack_endp);
if (errval)
@@ -1876,7 +1874,12 @@ open_path (const char *name, size_t namelen, int preloaded,
must not be freed using the general free() in libc. */
if (sps->malloced)
free (sps->dirs);
- sps->dirs = (void *) -1;
+#ifdef HAVE_Z_RELRO
+ /* rtld_search_dirs is attribute_relro, therefore avoid writing
+ into it. */
+ if (sps != &rtld_search_dirs)
+#endif
+ sps->dirs = (void *) -1;
}
return -1;