summaryrefslogtreecommitdiff
path: root/libexec/ld.so/loader.c
diff options
context:
space:
mode:
Diffstat (limited to 'libexec/ld.so/loader.c')
-rw-r--r--libexec/ld.so/loader.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/libexec/ld.so/loader.c b/libexec/ld.so/loader.c
index c23ea6d7ad1..1a34127ab81 100644
--- a/libexec/ld.so/loader.c
+++ b/libexec/ld.so/loader.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: loader.c,v 1.199 2022/11/06 11:43:19 deraadt Exp $ */
+/* $OpenBSD: loader.c,v 1.200 2022/11/06 12:00:20 deraadt Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -757,6 +757,18 @@ _dl_rtld(elf_object_t *object)
}
}
+ /*
+ * TEXTREL binaries are loaded without immutable on un-writeable sections.
+ * After text relocations are finished, these regions can become
+ * immutable. OPENBSD_MUTABLE section always overlaps writeable LOADs,
+ * so don't be afraid.
+ */
+ if (object->dyn.textrel) {
+ for (llist = object->load_list; llist != NULL; llist = llist->next)
+ if ((llist->prot & PROT_WRITE) == 0)
+ _dl_mimmutable(llist->start, llist->size);
+ }
+
if (fails == 0)
object->status |= STAT_RELOC_DONE;