diff options
-rw-r--r-- | libexec/ld.so/loader.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/libexec/ld.so/loader.c b/libexec/ld.so/loader.c index abbe1f05051..1703c202b20 100644 --- a/libexec/ld.so/loader.c +++ b/libexec/ld.so/loader.c @@ -1,4 +1,4 @@ -/* $OpenBSD: loader.c,v 1.175 2018/11/16 21:15:47 guenther Exp $ */ +/* $OpenBSD: loader.c,v 1.176 2018/11/20 01:38:59 guenther Exp $ */ /* * Copyright (c) 1998 Per Fogelstrom, Opsycon AB @@ -582,16 +582,18 @@ _dl_boot(const char **argv, char **envp, const long dyn_loff, long *dl_data) debug_map->r_ldbase = dyn_loff; _dl_debug_map = debug_map; #ifdef __mips__ - if (dynp->d_tag == DT_DEBUG) + Elf_Addr relro_addr = exe_obj->relro_addr; + if (dynp->d_tag == DT_DEBUG && + ((Elf_Addr)map_link + sizeof(*map_link) <= relro_addr || + (Elf_Addr)map_link >= relro_addr + exe_obj->relro_size)) { _dl_mprotect(map_link, sizeof(*map_link), PROT_READ|PROT_WRITE); -#endif - *map_link = _dl_debug_map; -#ifdef __mips__ - if (dynp->d_tag == DT_DEBUG) + *map_link = _dl_debug_map; _dl_mprotect(map_link, sizeof(*map_link), PROT_READ|PROT_EXEC); + } else #endif + *map_link = _dl_debug_map; } |