git: 065f8cea1b8e - stable/12 - rtld: map without PROT_EXEC for relocation
Ed Maste
emaste at FreeBSD.org
Tue Jan 19 02:46:37 UTC 2021
The branch stable/12 has been updated by emaste:
URL: https://cgit.FreeBSD.org/src/commit/?id=065f8cea1b8edc1e99cd247784002295c40b3760
commit 065f8cea1b8edc1e99cd247784002295c40b3760
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-19 01:00:29 +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
Differential Revision: https://reviews.freebsd.org/D27953
(cherry picked from commit 613a08cfa2e0fb1b99906961c7a676d527e17f05)
---
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 b6fcf8216cef..73177fc0c931 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -2954,7 +2954,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-all
mailing list