svn commit: r217851 - in head/libexec/rtld-elf: . amd64 arm i386 ia64 mips powerpc powerpc64 sparc64

Konstantin Belousov kib at FreeBSD.org
Tue Jan 25 21:12:32 UTC 2011


Author: kib
Date: Tue Jan 25 21:12:31 2011
New Revision: 217851
URL: http://svn.freebsd.org/changeset/base/217851

Log:
  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)

Modified:
  head/libexec/rtld-elf/amd64/rtld_machdep.h
  head/libexec/rtld-elf/arm/rtld_machdep.h
  head/libexec/rtld-elf/i386/rtld_machdep.h
  head/libexec/rtld-elf/ia64/rtld_machdep.h
  head/libexec/rtld-elf/map_object.c
  head/libexec/rtld-elf/mips/rtld_machdep.h
  head/libexec/rtld-elf/powerpc/rtld_machdep.h
  head/libexec/rtld-elf/powerpc64/rtld_machdep.h
  head/libexec/rtld-elf/rtld.c
  head/libexec/rtld-elf/sparc64/rtld_machdep.h

Modified: head/libexec/rtld-elf/amd64/rtld_machdep.h
==============================================================================
--- head/libexec/rtld-elf/amd64/rtld_machdep.h	Tue Jan 25 21:06:49 2011	(r217850)
+++ head/libexec/rtld-elf/amd64/rtld_machdep.h	Tue Jan 25 21:12:31 2011	(r217851)
@@ -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

Modified: head/libexec/rtld-elf/arm/rtld_machdep.h
==============================================================================
--- head/libexec/rtld-elf/arm/rtld_machdep.h	Tue Jan 25 21:06:49 2011	(r217850)
+++ head/libexec/rtld-elf/arm/rtld_machdep.h	Tue Jan 25 21:12:31 2011	(r217851)
@@ -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

Modified: head/libexec/rtld-elf/i386/rtld_machdep.h
==============================================================================
--- head/libexec/rtld-elf/i386/rtld_machdep.h	Tue Jan 25 21:06:49 2011	(r217850)
+++ head/libexec/rtld-elf/i386/rtld_machdep.h	Tue Jan 25 21:12:31 2011	(r217851)
@@ -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

Modified: head/libexec/rtld-elf/ia64/rtld_machdep.h
==============================================================================
--- head/libexec/rtld-elf/ia64/rtld_machdep.h	Tue Jan 25 21:06:49 2011	(r217850)
+++ head/libexec/rtld-elf/ia64/rtld_machdep.h	Tue Jan 25 21:12:31 2011	(r217851)
@@ -65,4 +65,7 @@ void call_initfini_pointer(const struct 
 
 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

Modified: head/libexec/rtld-elf/map_object.c
==============================================================================
--- head/libexec/rtld-elf/map_object.c	Tue Jan 25 21:06:49 2011	(r217850)
+++ head/libexec/rtld-elf/map_object.c	Tue Jan 25 21:12:31 2011	(r217851)
@@ -101,7 +101,7 @@ map_object(int fd, const char *path, con
     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) {
 

Modified: head/libexec/rtld-elf/mips/rtld_machdep.h
==============================================================================
--- head/libexec/rtld-elf/mips/rtld_machdep.h	Tue Jan 25 21:06:49 2011	(r217850)
+++ head/libexec/rtld-elf/mips/rtld_machdep.h	Tue Jan 25 21:12:31 2011	(r217851)
@@ -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

Modified: head/libexec/rtld-elf/powerpc/rtld_machdep.h
==============================================================================
--- head/libexec/rtld-elf/powerpc/rtld_machdep.h	Tue Jan 25 21:06:49 2011	(r217850)
+++ head/libexec/rtld-elf/powerpc/rtld_machdep.h	Tue Jan 25 21:12:31 2011	(r217851)
@@ -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

Modified: head/libexec/rtld-elf/powerpc64/rtld_machdep.h
==============================================================================
--- head/libexec/rtld-elf/powerpc64/rtld_machdep.h	Tue Jan 25 21:06:49 2011	(r217850)
+++ head/libexec/rtld-elf/powerpc64/rtld_machdep.h	Tue Jan 25 21:12:31 2011	(r217851)
@@ -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

Modified: head/libexec/rtld-elf/rtld.c
==============================================================================
--- head/libexec/rtld-elf/rtld.c	Tue Jan 25 21:06:49 2011	(r217850)
+++ head/libexec/rtld-elf/rtld.c	Tue Jan 25 21:12:31 2011	(r217851)
@@ -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;
 
 /*

Modified: head/libexec/rtld-elf/sparc64/rtld_machdep.h
==============================================================================
--- head/libexec/rtld-elf/sparc64/rtld_machdep.h	Tue Jan 25 21:06:49 2011	(r217850)
+++ head/libexec/rtld-elf/sparc64/rtld_machdep.h	Tue Jan 25 21:12:31 2011	(r217851)
@@ -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


More information about the svn-src-all mailing list