From nobody Thu Nov 30 19:35:07 2023 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 4Sh5xm1lCdz52Spd; Thu, 30 Nov 2023 19:35: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 4Sh5xm04Jwz3Kkr; Thu, 30 Nov 2023 19:35:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701372908; 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=ssncpJcupK8H0+eII1tjGvYNor5G9yHf/1JOgfH1iyU=; b=HaJxld/iOwBOUt9egZhBzJQTBick1mCOgzy0HFcFyUK+BcN761ArUeQhC5FB/pxDuhVHkZ HIa2HSuabndv3OqlllcuUJ1i2sq0g+sCbMS8hTeFYUrMjthgst3B+eSjCX3r4EHec1gRIf MGI50npvCRvrdevY1uK+kFGHED8/nioq7QtYzMN9jB8Wnnr9PakNuFZAVtSFWtZrpise9o 2Hl7ZVSKiXCViqSDsx23cK9725ORQhsak0EIPHDTJieZ8hKsIhqcpCNIK2l93lUo9odW+t OvuWfEAUtnDY7XCtNNeB8tQFRah9Q6feoowE3Xz8kBUPl0F/KTBEYavyTEHmgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701372908; 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=ssncpJcupK8H0+eII1tjGvYNor5G9yHf/1JOgfH1iyU=; b=KJ0q+4+vgFIrC2WhoWXqcygyZE5IvyaiJSDYvZSIlmO1HK3/B6fqGJKjXemajXcg2Zq6aI dOEof6mNo+Ma+hasDmRcEnyqJBeABcFQ64R+rRBdR5HU9MfSrHZR7gzxNRS4k/qhQPwjUt jiZOodq547XkFjFllVpPE4oAeIMSTPD/MCdUOSIdR0DVpubvko9nuRxdpoO27tSWgwAg/n haGMfrUynW9A/UR7+Q4fjAlmk4qcaIO+Z+NQMYrc26ZWntI9YtX5mz0liucEW/y88L0z5t 876ft/b8yYHblUf6BMLXC6vDfWrtzckvfmhkYeAS96J95E4kx0ho5/CCaEgV4Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1701372908; a=rsa-sha256; cv=none; b=Wh1aOEUDIIeSm4V5qF+PXVOILRzfbk6cDc4sgHSKpuMfrddSGBrVClVbOkll2G8yV3Qtp0 kUMXddhaY/nh9XHYz/TGfKV7PEA4YxX17t9bdYXfOSArDsafxoytALcArsAM24WdZ9zdOB OX5PFdUyjX+rk/Al6+JwJG2lPd2y1ulx3qdkmcTujYq1z464uVdwt2DsxgEy2dc2EL/Znb aaCFePxRqJgHSgj8vjEVChR2P6QLu/B1nb7/JGjVfGiJVFDoZElilOpykv6gus+PgFS2iz MxiFMPNQtFLUZuIn3BEg/LelY6hFt6uQUTzbe1P2Dnd0Li+3LiXl5TPkIe8nBg== 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 4Sh5xl61LXz136n; Thu, 30 Nov 2023 19:35:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3AUJZ7WE055457; Thu, 30 Nov 2023 19:35:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AUJZ7FD055454; Thu, 30 Nov 2023 19:35:07 GMT (envelope-from git) Date: Thu, 30 Nov 2023 19:35:07 GMT Message-Id: <202311301935.3AUJZ7FD055454@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 9daf6cd0f464 - main - RTLD_DEEPBIND: make lookup not just symbolic, but walk all refobj' DAGs 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: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9daf6cd0f46416d9c6eb0411ea6042cd42b8a9bc Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=9daf6cd0f46416d9c6eb0411ea6042cd42b8a9bc commit 9daf6cd0f46416d9c6eb0411ea6042cd42b8a9bc Author: Konstantin Belousov AuthorDate: 2023-11-29 18:30:59 +0000 Commit: Konstantin Belousov CommitDate: 2023-11-30 19:34:36 +0000 RTLD_DEEPBIND: make lookup not just symbolic, but walk all refobj' DAGs before starting the walk over the global list. Effectively we visit needed objects first as well, instead of just the object itself. This seems to better match the semantic offered by the glibc flag. Reported by: kevans PR: 275393 Reviewed by: kevans Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D42841 --- libexec/rtld-elf/rtld.c | 8 ++++++-- libexec/rtld-elf/rtld.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 49de41f81583..2c4111cc457a 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -3755,7 +3755,7 @@ dlopen_object(const char *name, int fd, Obj_Entry *refobj, int lo_flags, if (!obj->init_done) { /* We loaded something new and have to init something. */ if ((lo_flags & RTLD_LO_DEEPBIND) != 0) - obj->symbolic = true; + obj->deepbind = true; result = 0; if ((lo_flags & (RTLD_LO_EARLY | RTLD_LO_IGNSTLS)) == 0 && obj->static_tls && !allocate_tls_offset(obj)) { @@ -4581,7 +4581,8 @@ symlook_default(SymLook *req, const Obj_Entry *refobj) if (refobj->symbolic || req->defobj_out != NULL) donelist_check(&donelist, refobj); - symlook_global(req, &donelist); + if (!refobj->deepbind) + symlook_global(req, &donelist); /* Search all dlopened DAGs containing the referencing object. */ STAILQ_FOREACH(elm, &refobj->dldags, link) { @@ -4597,6 +4598,9 @@ symlook_default(SymLook *req, const Obj_Entry *refobj) } } + if (refobj->deepbind) + symlook_global(req, &donelist); + /* * Search the dynamic linker itself, and possibly resolve the * symbol from there. This is how the application links to diff --git a/libexec/rtld-elf/rtld.h b/libexec/rtld-elf/rtld.h index c7c17426b38a..e8b15095812b 100644 --- a/libexec/rtld-elf/rtld.h +++ b/libexec/rtld-elf/rtld.h @@ -240,6 +240,7 @@ typedef struct Struct_Obj_Entry { bool ver_checked : 1; /* True if processed by rtld_verify_object_versions */ bool textrel : 1; /* True if there are relocations to text seg */ bool symbolic : 1; /* True if generated with "-Bsymbolic" */ + bool deepbind : 1; /* True if loaded with RTLD_DEEPBIND" */ bool bind_now : 1; /* True if all relocations should be made first */ bool traced : 1; /* Already printed in ldd trace output */ bool jmpslots_done : 1; /* Already have relocated the jump slots */