From owner-dev-commits-src-all@freebsd.org Tue Jun 22 08:33:34 2021 Return-Path: Delivered-To: dev-commits-src-all@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 D2F816590D8; Tue, 22 Jun 2021 08:33:34 +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 4G8KRf5Q3gz3QdX; Tue, 22 Jun 2021 08:33:34 +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 A20C65B27; Tue, 22 Jun 2021 08:33:34 +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 15M8XYA4017289; Tue, 22 Jun 2021 08:33:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15M8XY6f017288; Tue, 22 Jun 2021 08:33:34 GMT (envelope-from git) Date: Tue, 22 Jun 2021 08:33:34 GMT Message-Id: <202106220833.15M8XY6f017288@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alex Richardson Subject: git: e3be51b2bc7c - main - rtld-elf: Check the return value of obj_enforce_relro() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e3be51b2bc7cb41eb9a238cced2ee650d9bb2d41 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Jun 2021 08:33:34 -0000 The branch main has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=e3be51b2bc7cb41eb9a238cced2ee650d9bb2d41 commit e3be51b2bc7cb41eb9a238cced2ee650d9bb2d41 Author: Alex Richardson AuthorDate: 2021-06-22 08:09:44 +0000 Commit: Alex Richardson CommitDate: 2021-06-22 08:10:48 +0000 rtld-elf: Check the return value of obj_enforce_relro() The mprotect() call was failing on CheriBSD when changing rtld's relro page permissions due to missing CHERI capability permissions on the mprotect() argument but did not report an error since the return value was being ignored. It should never fail on any supported FreeBSD architecture, but checking the return value seems like a good sanity check to me. Reviewed By: kib, imp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D30820 --- 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 9897248bffbb..f60872f12c52 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -2288,7 +2288,8 @@ init_rtld(caddr_t mapbase, Elf_Auxinfo **aux_info) obj_rtld.path = xstrdup(ld_path_rtld); parse_rtld_phdr(&obj_rtld); - obj_enforce_relro(&obj_rtld); + if (obj_enforce_relro(&obj_rtld) == -1) + rtld_die(); r_debug.r_version = R_DEBUG_VERSION; r_debug.r_brk = r_debug_state;