[Zrouter-src-freebsd] ZRouter.org: push to FreeBSD HEAD tree

zrouter-src-freebsd at zrouter.org zrouter-src-freebsd at zrouter.org
Wed Feb 1 10:57:01 UTC 2012


details:   http://zrouter.org/hg/FreeBSD/head//rev/dbcb677ab54f
changeset: 325:dbcb677ab54f
user:      ray at terran.dlink.ua
date:      Wed Feb 01 11:56:07 2012 +0200
description:
Update libexec/rtld-elf

diffstat:

 head/libexec/rtld-elf/amd64/reloc.c |   4 +---
 head/libexec/rtld-elf/i386/reloc.c  |   6 +-----
 head/libexec/rtld-elf/map_object.c  |  14 +++++++++++++-
 head/libexec/rtld-elf/rtld.c        |  15 ++++++++++++++-
 head/libexec/rtld-elf/rtld.h        |   5 ++++-
 5 files changed, 33 insertions(+), 11 deletions(-)

diffs (170 lines):

diff -r e175097c7513 -r dbcb677ab54f head/libexec/rtld-elf/amd64/reloc.c
--- a/head/libexec/rtld-elf/amd64/reloc.c	Wed Feb 01 11:55:53 2012 +0200
+++ b/head/libexec/rtld-elf/amd64/reloc.c	Wed Feb 01 11:56:07 2012 +0200
@@ -22,7 +22,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: head/libexec/rtld-elf/amd64/reloc.c 228503 2011-12-14 16:47:53Z kib $
+ * $FreeBSD: head/libexec/rtld-elf/amd64/reloc.c 230281 2012-01-17 21:55:20Z ed $
  */
 
 /*
@@ -487,10 +487,8 @@
 void *__tls_get_addr(tls_index *ti)
 {
     Elf_Addr** segbase;
-    Elf_Addr* dtv;
 
     __asm __volatile("movq %%fs:0, %0" : "=r" (segbase));
-    dtv = segbase[1];
 
     return tls_get_addr_common(&segbase[1], ti->ti_module, ti->ti_offset);
 }
diff -r e175097c7513 -r dbcb677ab54f head/libexec/rtld-elf/i386/reloc.c
--- a/head/libexec/rtld-elf/i386/reloc.c	Wed Feb 01 11:55:53 2012 +0200
+++ b/head/libexec/rtld-elf/i386/reloc.c	Wed Feb 01 11:56:07 2012 +0200
@@ -22,7 +22,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: head/libexec/rtld-elf/i386/reloc.c 228503 2011-12-14 16:47:53Z kib $
+ * $FreeBSD: head/libexec/rtld-elf/i386/reloc.c 230281 2012-01-17 21:55:20Z ed $
  */
 
 /*
@@ -444,10 +444,8 @@
 void *___tls_get_addr(tls_index *ti)
 {
     Elf_Addr** segbase;
-    Elf_Addr* dtv;
 
     __asm __volatile("movl %%gs:0, %0" : "=r" (segbase));
-    dtv = segbase[1];
 
     return tls_get_addr_common(&segbase[1], ti->ti_module, ti->ti_offset);
 }
@@ -456,10 +454,8 @@
 void *__tls_get_addr(tls_index *ti)
 {
     Elf_Addr** segbase;
-    Elf_Addr* dtv;
 
     __asm __volatile("movl %%gs:0, %0" : "=r" (segbase));
-    dtv = segbase[1];
 
     return tls_get_addr_common(&segbase[1], ti->ti_module, ti->ti_offset);
 }
diff -r e175097c7513 -r dbcb677ab54f head/libexec/rtld-elf/map_object.c
--- a/head/libexec/rtld-elf/map_object.c	Wed Feb 01 11:55:53 2012 +0200
+++ b/head/libexec/rtld-elf/map_object.c	Wed Feb 01 11:56:07 2012 +0200
@@ -22,7 +22,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: head/libexec/rtld-elf/map_object.c 225699 2011-09-20 21:49:54Z kib $
+ * $FreeBSD: head/libexec/rtld-elf/map_object.c 230784 2012-01-30 19:52:17Z kib $
  */
 
 #include <sys/param.h>
@@ -84,6 +84,8 @@
     Elf_Addr bss_vlimit;
     caddr_t bss_addr;
     Elf_Word stack_flags;
+    Elf_Addr relro_page;
+    size_t relro_size;
 
     hdr = get_elf_header(fd, path);
     if (hdr == NULL)
@@ -100,6 +102,8 @@
     nsegs = -1;
     phdyn = phinterp = phtls = NULL;
     phdr_vaddr = 0;
+    relro_page = 0;
+    relro_size = 0;
     segs = alloca(sizeof(segs[0]) * hdr->e_phnum);
     stack_flags = RTLD_DEFAULT_STACK_PF_EXEC | PF_R | PF_W;
     while (phdr < phlimit) {
@@ -134,6 +138,11 @@
 	case PT_GNU_STACK:
 	    stack_flags = phdr->p_flags;
 	    break;
+
+	case PT_GNU_RELRO:
+	    relro_page = phdr->p_vaddr;
+	    relro_size = phdr->p_memsz;
+	    break;
 	}
 
 	++phdr;
@@ -269,6 +278,9 @@
 	obj->tlsinit = mapbase + phtls->p_vaddr;
     }
     obj->stack_flags = stack_flags;
+    obj->relro_page = obj->relocbase + trunc_page(relro_page);
+    obj->relro_size = round_page(relro_size);
+
     return obj;
 }
 
diff -r e175097c7513 -r dbcb677ab54f head/libexec/rtld-elf/rtld.c
--- a/head/libexec/rtld-elf/rtld.c	Wed Feb 01 11:55:53 2012 +0200
+++ b/head/libexec/rtld-elf/rtld.c	Wed Feb 01 11:56:07 2012 +0200
@@ -24,7 +24,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: head/libexec/rtld-elf/rtld.c 229768 2012-01-07 10:33:01Z kib $
+ * $FreeBSD: head/libexec/rtld-elf/rtld.c 230784 2012-01-30 19:52:17Z kib $
  */
 
 /*
@@ -1114,6 +1114,11 @@
 	case PT_GNU_STACK:
 	    obj->stack_flags = ph->p_flags;
 	    break;
+
+	case PT_GNU_RELRO:
+	    obj->relro_page = obj->relocbase + trunc_page(ph->p_vaddr);
+	    obj->relro_size = round_page(ph->p_memsz);
+	    break;
 	}
     }
     if (nsegs < 1) {
@@ -2007,6 +2012,14 @@
 	    if (reloc_jmpslots(obj, lockstate) == -1)
 		return -1;
 
+	if (obj->relro_size > 0) {
+	    if (mprotect(obj->relro_page, obj->relro_size, PROT_READ) == -1) {
+		_rtld_error("%s: Cannot enforce relro protection: %s",
+		  obj->path, strerror(errno));
+		return -1;
+	    }
+	}
+
 	/*
 	 * Set up the magic number and version in the Obj_Entry.  These
 	 * were checked in the crt1.o from the original ElfKit, so we
diff -r e175097c7513 -r dbcb677ab54f head/libexec/rtld-elf/rtld.h
--- a/head/libexec/rtld-elf/rtld.h	Wed Feb 01 11:55:53 2012 +0200
+++ b/head/libexec/rtld-elf/rtld.h	Wed Feb 01 11:56:07 2012 +0200
@@ -22,7 +22,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: head/libexec/rtld-elf/rtld.h 229780 2012-01-07 16:09:54Z uqs $
+ * $FreeBSD: head/libexec/rtld-elf/rtld.h 230784 2012-01-30 19:52:17Z kib $
  */
 
 #ifndef RTLD_H /* { */
@@ -168,6 +168,9 @@
     size_t tlsoffset;		/* Offset of static TLS block for this module */
     size_t tlsalign;		/* Alignment of static TLS block */
 
+    caddr_t relro_page;
+    size_t relro_size;
+
     /* Items from the dynamic section. */
     Elf_Addr *pltgot;		/* PLT or GOT, depending on architecture */
     const Elf_Rel *rel;		/* Relocation entries */


More information about the Zrouter-src-freebsd mailing list