From nobody Wed Apr 23 18:09:56 2025 X-Original-To: current@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 4ZjRw936K8z5thrD for ; Wed, 23 Apr 2025 18:10:01 +0000 (UTC) (envelope-from avg@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 "smtp.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZjRw86Nshz4862; Wed, 23 Apr 2025 18:10:00 +0000 (UTC) (envelope-from avg@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1745431800; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=ScOr8ad3CFgM0bqIqoEcGCigV4dSpvEyjlBkfQKGFsk=; b=VDqM70/+Bltzwmj0AkMfJ4YxuXgbKXVLafqRQKwYz5pYvBSZ4mzIzth0TZCacrOlLDK3Uq yZlKrTXaiplDRH0nM6wR8OGC51CZ8L+xyGluV6rth7OxUx/tKOuVCJ1QmczKrSyx5AjTCg BO07qZT2l6La0tp/UOqGS+RDxXqOp4KQyNo09P/UnJCCKwQIzB/Dwn2M3SUWNR8Jsic7B/ Y4c9yC1BZ/lsEJmNIeGSREeESxeoTTOVcErFnyUcVGbd3P7tFkOdL0XUBXg7IY0A9BR/oB lny0BjC12RPdQb5x0sbD174mCC7K/oTIjHvDOlElkVe97VsIS4SOzsl/CnGunQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1745431800; a=rsa-sha256; cv=none; b=FW6JrRxekqrLNFBsPKQKhgAslEI0yFB+imW0CUkTbFoNghw5Gx+bo8jCpEBN+eKyvrs8e9 H4caw5rgWeaRux2aiWXpQe3Sz0fjBsHQ3/4Kdn7JSbjKxqhMqMpNxLflMFzFR6ETDjYbsv 2M+939UHEa4Yst7BXvNUiHAkxsGCXmYn6FkozCC31ao/dk4wqwOeHADRF2HLBjyz4bNDyi lE3C1AUMMXMLaXI8HbSViAlzTmCFLombd7/NUESd1uMfQ1TdU3bfJwplLQo6OWuQ/D5KzZ SIhW82Uq7+82pW3pLDa8RFHTTQ7g0RqV78Dv6l3CG44etZxbyK7mI5yCpJZjBA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1745431800; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=ScOr8ad3CFgM0bqIqoEcGCigV4dSpvEyjlBkfQKGFsk=; b=Yy/0qETE0jouBWaTQ2ocr/heSuGcQHkJPMVGSlITMXE8MB8YO4ZKGlvb7FIQPoxPqmKCpg uR/4tSbhickGKcIZtobv2o8ExGd2sNCJHSd9F3Hip+zhw60ApGIKIzdEkAz9hSjWJGmxvJ 8+tmsiZ9QxwDgu50ThkuC6InIhR0FJ73QZ3q9I8jiEqYnTsCnOb/xLFcH2mHgO6HtfvEmO FRzjoPyazcvK0HV0qnTMgXnYAgsoBy3ZMIpCDJ/YjlBMS4yJbMaDYOjXWbH2iTOCAHlX4q J12jO8xe0GB5VX/sUB+CZlH0qJyMaSxGilNMFz1qFzWC4cI4SMxo3n9GbMGQWg== Received: from [192.168.0.88] (unknown [93.188.39.137]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: avg/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 4ZjRw836SWzmQB; Wed, 23 Apr 2025 18:10:00 +0000 (UTC) (envelope-from avg@freebsd.org) Message-ID: Date: Wed, 23 Apr 2025 21:09:56 +0300 List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@FreeBSD.org MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Andriy Gapon Subject: Re: RTLD_DEEPBIND question To: Konstantin Belousov Cc: FreeBSD Current References: <0b3dda4e-53e4-40e5-9484-8b5ffb84e658@FreeBSD.org> <900c8521-559a-47b5-acaa-ae941f6852c4@freebsd.org> <7c4e1682-d797-493c-8326-08d51dde3359@FreeBSD.org> Content-Language: en-US Autocrypt: addr=avg@freebsd.org; keydata= xsDNBGcKrHEBDADRvwQOK0b/yo4ys5cs6bOQMhEh4xtfbaZ/CU00cpPgUip3sOZCdrtMWlRC g25z97prxE9pKueZi+HXDhIPpa9xl14ghqF4oYScuJ1i18HyiOH2y5Q3Vv/TtFiSzicd3EAu QgS3jVidpgDSPDdj2Yz3UxYpZ+PuFl6nOnvCvqOFcjUlzKCyPaiN2b86l1Nscmhnc+zQ/faB erUOEFEDQbWMA5YfXi8HrbeR16hfRfGt7E0aMDlIj9FIPIq71UWMN9CimPgs4+rbNr1MAlLa z4GxSDhVYZEY5rqtCzr+PLXboRQWnaUwXl0/biw9enf17NHdYv1SNAFTX2eC4dZ3qBVI74dS PgNprm+PMfz+6Hhs/dAv+Nan5nVhg3EFIjYTiy0MnjMSq8uI0v0ykpAGAcJJ5xl6d23aLxgN 6f0z6pJRCO0hGPgU7UzvFD0MxJxmbzqdT1R51KDan1oD41b+tjl2LMBuCDCoB0U44Pu0zLdp xMfFTxCXtwIYKIUxwd28jwMAEQEAAc0eQW5kcml5IEdhcG9uIDxhdmdARnJlZUJTRC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cmrBeWy/ofDqZPVqneAx0LRm eldDS9msXDW4KXODyPZ+9unvmHAcoH0xaBYaSH44CDZDQDg4LNcmbOvuu1TEXBJhjQARAQAB wsD8BBgBCAAmFiEEmXvSmjiQFHPVOpLnzDOt5NLj67sFAmcKrHMFCQeEzgACGwwACgkQzDOt 5NLj67sUCAv5AXqgWnYN9EblapMbZjkiqL8pZQ0GNqh+Pg9FwbyULxjtRTO6rD4D0IxizByb ef+neeUNyYlagt5nfKMysEr0SU/gHKCi8vyTF/63ukMrGUNGmJJxrndl5ZYKC6j6eX7twrZF L1Uvlmn6FnQ22red5kHO93fDjG4zaDIZvHfwj7kzjZ4tpC7Byinf88s14mdZeScc0PnU2hj4 UGYju/wg2FF4YxaZYhcmdTiRYY0Wx85XSMZv19pnn78sadEuRvfRd4JTmw++j1xGXeqQGWzz /CTG5/Ex9GAkQ02hZbmi236byDXoet4G8TEyOph9QFVkV9bNd0jQZaFZPGEj4PSPUYGAF7s5 xJaNGgctC3aZ7WjEv1FBoo44XCU4xcjJ1wZQUrHxRhx6TW0Jtcl0U9qfKFW30TSPo6RyiXuj X4ltWKAtjoXB8nUmEJckaz7IRu2b4pXDeazZuz5JBygUs10yJjDxh2vFQZo0KaBAPx9MZlPn gpPTjT15L8xGftEjQXF6 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 19/04/2025 13:29, Konstantin Belousov wrote: > On Sat, Apr 19, 2025 at 01:25:28PM +0300, Andriy Gapon wrote: >> On 19/04/2025 12:39, Andriy Gapon wrote: >>> From a quick look at the code, should we try to resolve the symbol in >>> refobj itself when it's marked with deepbind? >> Oh, and it looks like objects loaded under the "deepbind" object (e.g., >> needed objects) may not be aware that they are in the deepbind sub-tree? > > But should they? That's a right question. I have been reading about RTLD_DEEPBIND and Solaris flags like RTLD_GROUP, etc at the same time. I guess that's why some things got "fused" in my mind. So, I started believing that the concept of shared object dependency groups also applies to RTLD_DEEPBIND. But that's not documented to be so, at least, in the documentation that I could find. There are some in-depth documentation on Solaris run-time linker and its handling of various options. But for Linux RTLD_DEEPBIND I could find only manual page references and they only say that deep-binding applies to to the object being dlopen-ed. I am not sure if that's how the option actually works on Linux. I allow for possibility that the manual pages omit (or, at least, do not spell out) some details for brevity. In any case, I believe that the proposed patch is correct. But I think that it would not help in my case. I have: mdb -[dlopen]-> dtrace.so -[needs]-> libdtrace.so. And it's a symbol in libdtrace.so that gets resolved to mdb instead of libdtrace.so itself. The patch would affect how symbols in dtrace.so are resolved if I understand correctly. > Lets start with some minimal intrusive change: > > commit b4f4feb883a1be1d4ca3867f49baa20ce0c13d8d > Author: Konstantin Belousov > Date: Sat Apr 19 13:26:58 2025 +0300 > > rtld: symbolic and deepbind are equivalent for the refobj > > Reported by: avg > > diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c > index 2346c6eae9f6..8ea6afb43752 100644 > --- a/libexec/rtld-elf/rtld.c > +++ b/libexec/rtld-elf/rtld.c > @@ -4679,12 +4679,13 @@ symlook_default(SymLook *req, const Obj_Entry *refobj) > */ > res = symlook_obj(&req1, refobj); > if (res == 0 && (refobj->symbolic || > - ELF_ST_VISIBILITY(req1.sym_out->st_other) == STV_PROTECTED)) { > + ELF_ST_VISIBILITY(req1.sym_out->st_other) == STV_PROTECTED || > + refobj->deepbind)) { > req->sym_out = req1.sym_out; > req->defobj_out = req1.defobj_out; > assert(req->defobj_out != NULL); > } > - if (refobj->symbolic || req->defobj_out != NULL) > + if (refobj->symbolic || req->defobj_out != NULL || refobj->deepbind) > donelist_check(&donelist, refobj); > > if (!refobj->deepbind) -- Andriy Gapon