From owner-svn-src-all@freebsd.org Tue Jun 16 21:29:03 2020 Return-Path: Delivered-To: svn-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 1D6B2335411; Tue, 16 Jun 2020 21:29:03 +0000 (UTC) (envelope-from kib@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49mhCf740zz3WFT; Tue, 16 Jun 2020 21:29:02 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EDA7A15476; Tue, 16 Jun 2020 21:29:02 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 05GLT2s2089039; Tue, 16 Jun 2020 21:29:02 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 05GLT2GM089038; Tue, 16 Jun 2020 21:29:02 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202006162129.05GLT2GM089038@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 16 Jun 2020 21:29:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r362251 - head/libexec/rtld-elf X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/libexec/rtld-elf X-SVN-Commit-Revision: 362251 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Jun 2020 21:29:03 -0000 Author: kib Date: Tue Jun 16 21:29:02 2020 New Revision: 362251 URL: https://svnweb.freebsd.org/changeset/base/362251 Log: rtld: Allow to load ET_DYN && DF_1_PIE when tracing. This makes old ldd to still work on newer tagged PIE binaries. Also move debug line for hashes before both decisions to not load are done, so that the end of digest_dynamic() processing and reason to not load or load is seen in debug trace. Noted by: jhb Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/libexec/rtld-elf/rtld.c Modified: head/libexec/rtld-elf/rtld.c ============================================================================== --- head/libexec/rtld-elf/rtld.c Tue Jun 16 21:25:58 2020 (r362250) +++ head/libexec/rtld-elf/rtld.c Tue Jun 16 21:29:02 2020 (r362251) @@ -2612,12 +2612,13 @@ do_load_object(int fd, const char *name, char *path, s obj->path = path; if (!digest_dynamic(obj, 0)) goto errp; - if (obj->z_pie) { + dbg("%s valid_hash_sysv %d valid_hash_gnu %d dynsymcount %d", obj->path, + obj->valid_hash_sysv, obj->valid_hash_gnu, obj->dynsymcount); + if (obj->z_pie && (flags & RTLD_LO_TRACE) == 0) { + dbg("refusing to load PIE executable \"%s\"", obj->path); _rtld_error("Cannot load PIE binary %s as DSO", obj->path); goto errp; } - dbg("%s valid_hash_sysv %d valid_hash_gnu %d dynsymcount %d", obj->path, - obj->valid_hash_sysv, obj->valid_hash_gnu, obj->dynsymcount); if (obj->z_noopen && (flags & (RTLD_LO_DLOPEN | RTLD_LO_TRACE)) == RTLD_LO_DLOPEN) { dbg("refusing to load non-loadable \"%s\"", obj->path);