Date: Tue, 19 Jan 2021 02:46:36 GMT From: Ed Maste <emaste@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 065f8cea1b8e - stable/12 - rtld: map without PROT_EXEC for relocation Message-ID: <202101190246.10J2kaV1002593@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=065f8cea1b8edc1e99cd247784002295c40b3760 commit 065f8cea1b8edc1e99cd247784002295c40b3760 Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2021-01-04 18:55:44 +0000 Commit: Ed Maste <emaste@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@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",
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202101190246.10J2kaV1002593>