aboutsummaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2024-02-13 01:09:03 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2024-02-13 14:24:01 +0000
commit968a18975adc9c2a619bb52aa2f009de99fc9e24 (patch)
treebf194353c33db735fcc0e70c70345e144d2af975 /libexec
parent30b5f6b33b35623e6b6aa1d27a78311e199fa602 (diff)
downloadsrc-968a18975adc9c2a619bb52aa2f009de99fc9e24.tar.gz
src-968a18975adc9c2a619bb52aa2f009de99fc9e24.zip
rtld: ignore load_filtees() calls if we already loading filtees for the obj
in addition to avoiding it for already loaded filtees. Issue is that during load, rtld needs to resolve some special ABI symbols, like executable stack fixer and static TLS initializer, which might trigger recursion. Example is libthr which is filter for libsys, and which exports __pthread_distribute_static_tls. Tested by: kevans, krion Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D43858
Diffstat (limited to 'libexec')
-rw-r--r--libexec/rtld-elf/rtld.c4
-rw-r--r--libexec/rtld-elf/rtld.h1
2 files changed, 4 insertions, 1 deletions
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index dfd9e74407ed..7d6b8ae52703 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -2582,12 +2582,14 @@ load_filtee1(Obj_Entry *obj, Needed_Entry *needed, int flags,
static void
load_filtees(Obj_Entry *obj, int flags, RtldLockState *lockstate)
{
- if (obj->filtees_loaded)
+ if (obj->filtees_loaded || obj->filtees_loading)
return;
lock_restart_for_upgrade(lockstate);
+ obj->filtees_loading = true;
load_filtee1(obj, obj->needed_filtees, flags, lockstate);
load_filtee1(obj, obj->needed_aux_filtees, flags, lockstate);
obj->filtees_loaded = true;
+ obj->filtees_loading = false;
}
static int
diff --git a/libexec/rtld-elf/rtld.h b/libexec/rtld-elf/rtld.h
index e8b15095812b..6311b3e6cc7f 100644
--- a/libexec/rtld-elf/rtld.h
+++ b/libexec/rtld-elf/rtld.h
@@ -263,6 +263,7 @@ typedef struct Struct_Obj_Entry {
bool on_fini_list: 1; /* Object is already on fini list. */
bool dag_inited : 1; /* Object has its DAG initialized. */
bool filtees_loaded : 1; /* Filtees loaded */
+ bool filtees_loading : 1; /* In process of filtees loading */
bool irelative : 1; /* Object has R_MACHDEP_IRELATIVE relocs */
bool irelative_nonplt : 1; /* Object has R_MACHDEP_IRELATIVE non-plt relocs */
bool gnu_ifunc : 1; /* Object has references to STT_GNU_IFUNC */