diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2018-11-20 01:39:00 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2018-11-20 01:39:00 +0000 |
commit | a7b6be0e9cb5f21dcee0f4ece038127c2382eb39 (patch) | |
tree | 07ba4097bee1a2a0a54f0cca0dbb7e5fdb6db753 /libexec/ld.so | |
parent | a9e2211fb3c82cacb244b704c1971bdf48a07336 (diff) |
On mips64, DT_DEBUG doesn't need mprotecting if it's in the GNU_RELRO segment
ok visa@
Diffstat (limited to 'libexec/ld.so')
-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; } |