git: 8d0740e8b9dd - stable/14 - RTLD_DEEPBIND: make lookup not just symbolic, but walk all refobj' DAGs
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 07 Dec 2023 00:27:25 UTC
The branch stable/14 has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=8d0740e8b9dd05513ef23e2dee7194f32551df13
commit 8d0740e8b9dd05513ef23e2dee7194f32551df13
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-11-29 18:30:59 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-12-07 00:27:19 +0000
RTLD_DEEPBIND: make lookup not just symbolic, but walk all refobj' DAGs
PR: 275393
(cherry picked from commit 9daf6cd0f46416d9c6eb0411ea6042cd42b8a9bc)
---
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 f8c4c18b5d5e..0bbd8104e11b 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -3745,7 +3745,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)) {
@@ -4571,7 +4571,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) {
@@ -4587,6 +4588,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 7fe9d837d6f1..c2676f59f32d 100644
--- a/libexec/rtld-elf/rtld.h
+++ b/libexec/rtld-elf/rtld.h
@@ -239,6 +239,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 */