From owner-dev-commits-src-branches@freebsd.org Tue Jan 19 02:46:37 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 264124DF126; Tue, 19 Jan 2021 02:46:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DKY2P0XY6z3sgp; Tue, 19 Jan 2021 02:46:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0517E1EBE9; Tue, 19 Jan 2021 02:46:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 10J2ka7b002594; Tue, 19 Jan 2021 02:46:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 10J2kaV1002593; Tue, 19 Jan 2021 02:46:36 GMT (envelope-from git) Date: Tue, 19 Jan 2021 02:46:36 GMT Message-Id: <202101190246.10J2kaV1002593@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 065f8cea1b8e - stable/12 - rtld: map without PROT_EXEC for relocation MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 065f8cea1b8edc1e99cd247784002295c40b3760 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jan 2021 02:46:37 -0000 The branch stable/12 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=065f8cea1b8edc1e99cd247784002295c40b3760 commit 065f8cea1b8edc1e99cd247784002295c40b3760 Author: Ed Maste AuthorDate: 2021-01-04 18:55:44 +0000 Commit: Ed Maste 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 (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",