summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2016-06-18 02:40:47 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2016-06-18 02:40:47 +0000
commitc17236edfd5406ea283888c576d6ac633b1cbcd6 (patch)
tree8372b09da4c6b169e8809d9aa7f9c4308a869822
parent078b8590f2ecfd93f4d427ea96a820167a438d00 (diff)
Make mips64 like all the others: only make mappings writable during relocation
if DT_TEXTREL was set on the object. If that's needed, only set the mapping to READ+WRITE to avoid W^X violation. ok kettenis@
-rw-r--r--libexec/ld.so/mips64/rtld_machine.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/libexec/ld.so/mips64/rtld_machine.c b/libexec/ld.so/mips64/rtld_machine.c
index 083fb9a09d1..89c30f664d8 100644
--- a/libexec/ld.so/mips64/rtld_machine.c
+++ b/libexec/ld.so/mips64/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.21 2016/03/20 02:29:51 guenther Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.22 2016/06/18 02:40:46 guenther Exp $ */
/*
* Copyright (c) 1998-2004 Opsycon AB, Sweden.
@@ -68,12 +68,12 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz)
* object so we can do relocations in the .rodata section.
* After relocation restore protection.
*/
- load_list = object->load_list;
- while (load_list != NULL) {
- if ((load_list->prot & PROT_WRITE) == 0)
- _dl_mprotect(load_list->start, load_list->size,
- load_list->prot|PROT_WRITE);
- load_list = load_list->next;
+ if (object->dyn.textrel) {
+ for (load_list = object->load_list; load_list != NULL; load_list = load_list->next) {
+ if ((load_list->prot & PROT_WRITE) == 0)
+ _dl_mprotect(load_list->start, load_list->size,
+ PROT_READ | PROT_WRITE);
+ }
}
DL_DEB(("relocating %d\n", numrel));
@@ -147,12 +147,12 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz)
}
}
DL_DEB(("done %d fails\n", fails));
- load_list = object->load_list;
- while (load_list != NULL) {
- if ((load_list->prot & PROT_WRITE) == 0)
- _dl_mprotect(load_list->start, load_list->size,
- load_list->prot);
- load_list = load_list->next;
+ if (object->dyn.textrel) {
+ for (load_list = object->load_list; load_list != NULL; load_list = load_list->next) {
+ if ((load_list->prot & PROT_WRITE) == 0)
+ _dl_mprotect(load_list->start, load_list->size,
+ load_list->prot);
+ }
}
return(fails);
}