From nobody Wed Jan 05 17:23:26 2022 X-Original-To: dev-commits-src-branches@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 C600A1947DB8; Wed, 5 Jan 2022 17:23:26 +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 4JTbt63fhgz3GWx; Wed, 5 Jan 2022 17:23:26 +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 5D9A5106B3; Wed, 5 Jan 2022 17:23:26 +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 205HNQFW096568; Wed, 5 Jan 2022 17:23:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 205HNQ6c096567; Wed, 5 Jan 2022 17:23:26 GMT (envelope-from git) Date: Wed, 5 Jan 2022 17:23:26 GMT Message-Id: <202201051723.205HNQ6c096567@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 4191c1c4a058 - stable/13 - librtld_db: Handle shlibs with discontiguous mappings. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 4191c1c4a058292e84a9bd7eb60a7fb9f1d3ceb3 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1641403406; 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=uhR/nx/JUBmZYBciJA3yIrT6YnpqMC0REf7hnwrzTtk=; b=ilfsdB/zWwj751rBySIct18hHKFVRmv22dqctj7MVqxo6IOHnzxDYC6WjxikS3DNyJcJYX uN62oqA8SUbEEIY4P+3ZA4GfN1eofYtF4SdXEDrMKQXHXXqihcZuyQoGqP3AzgeKaNYm2f ZENdhz88QOztxlJOWHBfmzC7xHJKX/K9VM/ytYRKkDGqfvFjwFkmREXBc24B1U2GwPIHOK bfXv2Eom2ZErks+l7PuQ6+bcPui0a/YEtRgHdEKWI3Xw6WaMUNfB5CwAUFCX+d4WwPxgAw ysM7RuiXnwhxzUal5TqouwCbEinjnGQmrpv98qkZuKndqHpFIEHoRUs8z+wSUg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1641403406; a=rsa-sha256; cv=none; b=GrOxYrgB9cVqC3q5PjR7JKCzushtX+eFTRxbir7BTWSTeaDJ8Kq1zpsvUxjsIsgh3f02MR grAUIUqNtis+6We2W9SzvKnxY/AHCQn/R0hzL1UY4n6pvqVq3SdLsMI8CVLOaHgd1dXx0U 6nToBYuArLQ6Ollz8D1+C/MBzYh5iu/VBMFh7gPRcMJZ19Ws22rFajOPKOCwVqdI4e/fWt s/BxDgF/sbMTBYPJtzHIdgwdvb/XOWaCN5x7RxBi1LG7DdjLzXx63DP2tI8Jy6Z3UAB8PC 28KaBUaIRiW7XButb/5tMfH0YD2uB0T5NNlDWphICzW76xN4nw35D5umpb3bkQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=4191c1c4a058292e84a9bd7eb60a7fb9f1d3ceb3 commit 4191c1c4a058292e84a9bd7eb60a7fb9f1d3ceb3 Author: Chuck Silvers AuthorDate: 2021-12-03 19:03:32 +0000 Commit: Mark Johnston CommitDate: 2022-01-05 17:23:04 +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 (cherry picked from commit dfd00261c95a9839ba528f7e052d9bcac19f2b14) --- 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)