git: 613a08cfa2e0 - main - rtld: map without PROT_EXEC for relocation
Ed Maste
emaste at FreeBSD.org
Tue Jan 5 15:57:49 UTC 2021
The branch main has been updated by emaste:
URL: https://cgit.FreeBSD.org/src/commit/?id=613a08cfa2e0fb1b99906961c7a676d527e17f05
commit 613a08cfa2e0fb1b99906961c7a676d527e17f05
Author: Ed Maste <emaste at FreeBSD.org>
AuthorDate: 2021-01-04 18:55:44 +0000
Commit: Ed Maste <emaste at FreeBSD.org>
CommitDate: 2021-01-05 15:57:14 +0000
rtld: map without PROT_EXEC for relocation
This makes text segment relocation work under W^X.
Submitted by: Greg V <greg at unrelenting.technology> (original version)
Reviewed by: kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D27953
---
libexec/rtld-elf/rtld.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index 27262ab9dbc5..7b8bfba84d7d 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -2982,7 +2982,8 @@ reloc_textrel_prot(Obj_Entry *obj, bool before)
base = obj->relocbase + trunc_page(ph->p_vaddr);
sz = round_page(ph->p_vaddr + ph->p_filesz) -
trunc_page(ph->p_vaddr);
- prot = convert_prot(ph->p_flags) | (before ? PROT_WRITE : 0);
+ prot = before ? (PROT_READ | PROT_WRITE) :
+ convert_prot(ph->p_flags);
if (mprotect(base, sz, prot) == -1) {
_rtld_error("%s: Cannot write-%sable text segment: %s",
obj->path, before ? "en" : "dis",
More information about the dev-commits-src-main
mailing list