From nobody Fri Dec 03 19:09:08 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D910918A82D8; Fri, 3 Dec 2021 19:09:08 +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 4J5MnJ4WVZz3pk2; Fri, 3 Dec 2021 19:09:08 +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 70EB91668B; Fri, 3 Dec 2021 19:09:08 +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 1B3J98tW019174; Fri, 3 Dec 2021 19:09:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B3J98hd019173; Fri, 3 Dec 2021 19:09:08 GMT (envelope-from git) Date: Fri, 3 Dec 2021 19:09:08 GMT Message-Id: <202112031909.1B3J98hd019173@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Chuck Silvers Subject: git: dfd00261c95a - main - librtld_db: Handle shlibs with discontiguous mappings. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: chs X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: dfd00261c95a9839ba528f7e052d9bcac19f2b14 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638558548; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LksL+0SLzdyqfFOme2h/4/dy4kOz8lfx36JghXDgz4I=; b=j3U4w3Nw5JnYdksR61PAizOrxhyglG5XknNndrilAoKTveLSGAcoTvTSgkqFD5e6j2NtoZ cRT2Rr+gqekJ9Dk82d4iVVGsW7trs1uTag8Bz5jZ4ZEXlS/oNICjnPg5lGne/g2dAu9NgE tF5Ejg7VAugFMnb9cC962kJjCOb1qC1+ccyTjp+DG6TOhn9cHOnY84rxqM+6Exr8l8497b vpTh6fBLDZbGXfrlOjYoNnAuuv0XEoCloBCpy3rnMol6E3r+uHdGfaWAvmnZhzLRgsXQ6l e5WqKnbZT/I67qNidXOQXIOwLAQ8BrS9Fw6qMT4oBQ79UlQ7xThCTPuZMFJVvw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638558548; a=rsa-sha256; cv=none; b=oZ2xhhJuTYnV9wQrMyrPxKUk+1g3vpJU+8WFjCLa3zD9oiawLjQJMJGP4TRAxBvVBCa1zk GEYCxTv4gDA2Cm2qkwAv1tQhYPAAHYgcsgmKbwXsKoic7L+xv8AuNKcDpa9eeR4Draf/T2 Mr1sZ1yYlo5687OJtEtS/fMAdw+1w//bST70bi2gpMY4J7YM4bjL3onD1T6y75XFUPb632 9eOVdaSqfa7psFUFtQCJxe3wTOZcb9bkNqB+g2UY5CGt4+wb0ixYtc441Jml7+10DZ04c/ KSdXNiyz3QChnol80yPweQwSsMOnl/pdeldsu7PrDxgyNYVpQmGJ4OXaKz/2/Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by chs: URL: https://cgit.FreeBSD.org/src/commit/?id=dfd00261c95a9839ba528f7e052d9bcac19f2b14 commit dfd00261c95a9839ba528f7e052d9bcac19f2b14 Author: Chuck Silvers AuthorDate: 2021-12-03 19:03:32 +0000 Commit: Chuck Silvers CommitDate: 2021-12-03 19:07:30 +0000 librtld_db: Handle shlibs with discontiguous mappings. Some shared libraries specify mappings that leave a gap (actually a MAP_GUARD mapping) in between the file mappings (libcrypto.so was the one I found), and this would cause rd_loadobj_iter() to report the mapping info incorrectly, leaving out rdl_path and misreporting rdl_offset for file mappings after the gap. Fix rd_loadobj_iter() to handle this situation. Reviewed by: markj Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D32950 --- lib/librtld_db/rtld_db.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/librtld_db/rtld_db.c b/lib/librtld_db/rtld_db.c index 9edeecfb95c5..18e16f36e62c 100644 --- a/lib/librtld_db/rtld_db.c +++ b/lib/librtld_db/rtld_db.c @@ -165,6 +165,7 @@ rd_loadobj_iter(rd_agent_t *rdap, rl_iter_f *cb, void *clnt_data) rd_loadobj_t rdl; rd_err_e ret; uintptr_t base; + uint32_t offset; int cnt, i; DPRINTF("%s\n", __func__); @@ -190,11 +191,12 @@ rd_loadobj_iter(rd_agent_t *rdap, rl_iter_f *cb, void *clnt_data) if (kve->kve_vn_fileid != fileid) { base = kve->kve_start; fileid = kve->kve_vn_fileid; - path = kve->kve_path; } + path = kve->kve_path; + offset = kve->kve_start - base; } else { - base = 0; path = NULL; + offset = 0; } memset(&rdl, 0, sizeof(rdl)); /* @@ -202,7 +204,7 @@ rd_loadobj_iter(rd_agent_t *rdap, rl_iter_f *cb, void *clnt_data) */ rdl.rdl_saddr = kve->kve_start; rdl.rdl_eaddr = kve->kve_end; - rdl.rdl_offset = kve->kve_start - base; + rdl.rdl_offset = offset; if (kve->kve_protection & KVME_PROT_READ) rdl.rdl_prot |= RD_RDL_R; if (kve->kve_protection & KVME_PROT_WRITE)