Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 20 Aug 2023 12:31:40 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: b1d3e2b77155 - main - rtld: unlock bind lock when calling into crt __pthread_distribute_static_tls method
Message-ID:  <202308201231.37KCVeKW044373@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=b1d3e2b771552af071bf0964233cc5a76ea25542

commit b1d3e2b771552af071bf0964233cc5a76ea25542
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-08-18 19:52:24 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-08-20 12:30:13 +0000

    rtld: unlock bind lock when calling into crt __pthread_distribute_static_tls method
    
    The method might require resolving and binding symbols, which means
    recursing on the bind lock. It is safe to unlock the bind lock,
    since we operate on the private object list, and user attempting to
    unload an object from the list of not yet fully loaded objects caused
    self-inflicted race.
    
    It is similar to how we treat user' init/fini methods.
    
    Reported by:    stevek
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
---
 libexec/rtld-elf/rtld.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index 886758a5a484..feef5dd0bb5d 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -5897,8 +5897,10 @@ distribute_static_tls(Objlist *list, RtldLockState *lockstate)
 		obj = elm->obj;
 		if (obj->marker || !obj->tls_static || obj->static_tls_copied)
 			continue;
+		lock_release(rtld_bind_lock, lockstate);
 		distrib(obj->tlsoffset, obj->tlsinit, obj->tlsinitsize,
 		    obj->tlssize);
+		wlock_acquire(rtld_bind_lock, lockstate);
 		obj->static_tls_copied = true;
 	}
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202308201231.37KCVeKW044373>