Date: Sun, 30 Jul 2023 00:29:51 GMT From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 05e7db731d56 - stable/13 - rtld: fix dlopen() for an object that is already mapped but not yet initialized Message-ID: <202307300029.36U0Tp09069400@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=05e7db731d564b276f126465e90f22534dbfd61d commit 05e7db731d564b276f126465e90f22534dbfd61d Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2023-07-14 13:38:03 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2023-07-30 00:29:09 +0000 rtld: fix dlopen() for an object that is already mapped but not yet initialized (cherry picked from commit 1005d3d05362de368b1ea7aeb8eb20cee993e122) --- libexec/rtld-elf/rtld.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index db53fbeb7d08..d6697711eece 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -3758,7 +3758,6 @@ static Obj_Entry * dlopen_object(const char *name, int fd, Obj_Entry *refobj, int lo_flags, int mode, RtldLockState *lockstate) { - Obj_Entry *old_obj_tail; Obj_Entry *obj; Objlist initlist; RtldLockState mlockstate; @@ -3775,7 +3774,6 @@ dlopen_object(const char *name, int fd, Obj_Entry *refobj, int lo_flags, } GDB_STATE(RT_ADD,NULL); - old_obj_tail = globallist_curr(TAILQ_LAST(&obj_list, obj_entry_q)); obj = NULL; if (name == NULL && fd == -1) { obj = obj_main; @@ -3788,9 +3786,9 @@ dlopen_object(const char *name, int fd, Obj_Entry *refobj, int lo_flags, obj->dl_refcount++; if (mode & RTLD_GLOBAL && objlist_find(&list_global, obj) == NULL) objlist_push_tail(&list_global, obj); - if (globallist_next(old_obj_tail) != NULL) { - /* We loaded something new. */ - assert(globallist_next(old_obj_tail) == obj); + + if (!obj->init_done) { + /* We loaded something new and have to init something. */ if ((lo_flags & RTLD_LO_DEEPBIND) != 0) obj->symbolic = true; result = 0;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202307300029.36U0Tp09069400>