diff options
author | Konstantin Belousov <kib@FreeBSD.org> | 2011-01-25 21:12:31 +0000 |
---|---|---|
committer | Konstantin Belousov <kib@FreeBSD.org> | 2011-01-25 21:12:31 +0000 |
commit | cb38d4941c45e3c72c4b5b3fad87d297d950cf53 (patch) | |
tree | 6b984b52162918ea8254c857cb2d30fd43f83cbf | |
parent | f1410015f0543e69e52034a5d1cb4ca1982bca34 (diff) | |
download | src-cb38d4941c45e3c72c4b5b3fad87d297d950cf53.tar.gz src-cb38d4941c45e3c72c4b5b3fad87d297d950cf53.zip |
When loading dso without PT_GNU_STACK phdr, only call
__pthread_map_stacks_exec() on architectures that allow executable
stacks.
Reported and tested by: marcel (ia64)
Notes
Notes:
svn path=/head/; revision=217851
-rw-r--r-- | libexec/rtld-elf/amd64/rtld_machdep.h | 3 | ||||
-rw-r--r-- | libexec/rtld-elf/arm/rtld_machdep.h | 3 | ||||
-rw-r--r-- | libexec/rtld-elf/i386/rtld_machdep.h | 3 | ||||
-rw-r--r-- | libexec/rtld-elf/ia64/rtld_machdep.h | 3 | ||||
-rw-r--r-- | libexec/rtld-elf/map_object.c | 2 | ||||
-rw-r--r-- | libexec/rtld-elf/mips/rtld_machdep.h | 3 | ||||
-rw-r--r-- | libexec/rtld-elf/powerpc/rtld_machdep.h | 3 | ||||
-rw-r--r-- | libexec/rtld-elf/powerpc64/rtld_machdep.h | 3 | ||||
-rw-r--r-- | libexec/rtld-elf/rtld.c | 2 | ||||
-rw-r--r-- | libexec/rtld-elf/sparc64/rtld_machdep.h | 3 |
10 files changed, 26 insertions, 2 deletions
diff --git a/libexec/rtld-elf/amd64/rtld_machdep.h b/libexec/rtld-elf/amd64/rtld_machdep.h index 301eb0c59e1d..48d225f3e6e0 100644 --- a/libexec/rtld-elf/amd64/rtld_machdep.h +++ b/libexec/rtld-elf/amd64/rtld_machdep.h @@ -73,4 +73,7 @@ typedef struct { extern void *__tls_get_addr(tls_index *ti); +#define RTLD_DEFAULT_STACK_PF_EXEC PF_X +#define RTLD_DEFAULT_STACK_EXEC PROT_EXEC + #endif diff --git a/libexec/rtld-elf/arm/rtld_machdep.h b/libexec/rtld-elf/arm/rtld_machdep.h index 8364afa2e71a..8a1b7869e3f0 100644 --- a/libexec/rtld-elf/arm/rtld_machdep.h +++ b/libexec/rtld-elf/arm/rtld_machdep.h @@ -69,4 +69,7 @@ void _rtld_bind_start(void); extern void *__tls_get_addr(tls_index *ti); +#define RTLD_DEFAULT_STACK_PF_EXEC PF_X +#define RTLD_DEFAULT_STACK_EXEC PROT_EXEC + #endif diff --git a/libexec/rtld-elf/i386/rtld_machdep.h b/libexec/rtld-elf/i386/rtld_machdep.h index 9b3dcdf209d7..7d121e4ca447 100644 --- a/libexec/rtld-elf/i386/rtld_machdep.h +++ b/libexec/rtld-elf/i386/rtld_machdep.h @@ -74,4 +74,7 @@ typedef struct { extern void *___tls_get_addr(tls_index *ti) __attribute__((__regparm__(1))); extern void *__tls_get_addr(tls_index *ti); +#define RTLD_DEFAULT_STACK_PF_EXEC PF_X +#define RTLD_DEFAULT_STACK_EXEC PROT_EXEC + #endif diff --git a/libexec/rtld-elf/ia64/rtld_machdep.h b/libexec/rtld-elf/ia64/rtld_machdep.h index 5af9602f7649..c47b3090b8f6 100644 --- a/libexec/rtld-elf/ia64/rtld_machdep.h +++ b/libexec/rtld-elf/ia64/rtld_machdep.h @@ -65,4 +65,7 @@ void call_initfini_pointer(const struct Struct_Obj_Entry *, Elf_Addr); extern void *__tls_get_addr(unsigned long module, unsigned long offset); +#define RTLD_DEFAULT_STACK_PF_EXEC 0 +#define RTLD_DEFAULT_STACK_EXEC 0 + #endif diff --git a/libexec/rtld-elf/map_object.c b/libexec/rtld-elf/map_object.c index 3f69e9b5d523..2b33862bc7fb 100644 --- a/libexec/rtld-elf/map_object.c +++ b/libexec/rtld-elf/map_object.c @@ -101,7 +101,7 @@ map_object(int fd, const char *path, const struct stat *sb) phdyn = phinterp = phtls = NULL; phdr_vaddr = 0; segs = alloca(sizeof(segs[0]) * hdr->e_phnum); - stack_flags = PF_X | PF_R | PF_W; + stack_flags = RTLD_DEFAULT_STACK_PF_EXEC | PF_R | PF_W; while (phdr < phlimit) { switch (phdr->p_type) { diff --git a/libexec/rtld-elf/mips/rtld_machdep.h b/libexec/rtld-elf/mips/rtld_machdep.h index 8364afa2e71a..8a1b7869e3f0 100644 --- a/libexec/rtld-elf/mips/rtld_machdep.h +++ b/libexec/rtld-elf/mips/rtld_machdep.h @@ -69,4 +69,7 @@ void _rtld_bind_start(void); extern void *__tls_get_addr(tls_index *ti); +#define RTLD_DEFAULT_STACK_PF_EXEC PF_X +#define RTLD_DEFAULT_STACK_EXEC PROT_EXEC + #endif diff --git a/libexec/rtld-elf/powerpc/rtld_machdep.h b/libexec/rtld-elf/powerpc/rtld_machdep.h index bf589c5728f6..4d0dad4ac4ce 100644 --- a/libexec/rtld-elf/powerpc/rtld_machdep.h +++ b/libexec/rtld-elf/powerpc/rtld_machdep.h @@ -84,4 +84,7 @@ typedef struct { extern void *__tls_get_addr(tls_index* ti); +#define RTLD_DEFAULT_STACK_PF_EXEC PF_X +#define RTLD_DEFAULT_STACK_EXEC PROT_EXEC + #endif diff --git a/libexec/rtld-elf/powerpc64/rtld_machdep.h b/libexec/rtld-elf/powerpc64/rtld_machdep.h index 3c08ea599455..041efe09937f 100644 --- a/libexec/rtld-elf/powerpc64/rtld_machdep.h +++ b/libexec/rtld-elf/powerpc64/rtld_machdep.h @@ -76,4 +76,7 @@ typedef struct { extern void *__tls_get_addr(tls_index* ti); +#define RTLD_DEFAULT_STACK_PF_EXEC PF_X +#define RTLD_DEFAULT_STACK_EXEC PROT_EXEC + #endif diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 8acbdc5a7fcc..2ed7ea4a9d7a 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -191,7 +191,7 @@ extern Elf_Dyn _DYNAMIC; int osreldate, pagesize; -static int stack_prot = PROT_READ | PROT_WRITE | PROT_EXEC; +static int stack_prot = PROT_READ | PROT_WRITE | RTLD_DEFAULT_STACK_EXEC; static int max_stack_flags; /* diff --git a/libexec/rtld-elf/sparc64/rtld_machdep.h b/libexec/rtld-elf/sparc64/rtld_machdep.h index a1610718ba18..3160391424bf 100644 --- a/libexec/rtld-elf/sparc64/rtld_machdep.h +++ b/libexec/rtld-elf/sparc64/rtld_machdep.h @@ -65,4 +65,7 @@ typedef struct { extern void *__tls_get_addr(tls_index *ti); +#define RTLD_DEFAULT_STACK_PF_EXEC 0 +#define RTLD_DEFAULT_STACK_EXEC 0 + #endif |