git: 19fa964bda24 - stable/15 - rtld: explain the use of rtld_bind_lock in rtld_get_addr_slow()

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sat, 12 Sep 2026 00:28:05 UTC
The branch stable/15 has been updated by kib:

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

commit 19fa964bda24a3388090418b4fbc196ad9ce2d5f
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-08-30 05:20:46 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-09-11 06:59:52 +0000

    rtld: explain the use of rtld_bind_lock in rtld_get_addr_slow()
    
    (cherry picked from commit 5d9e5f49647e129bf814e7887b8201bfce8b53e3)
---
 libexec/rtld-elf/rtld.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index 864148df99ba..1cc30e27fa0e 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -5458,6 +5458,11 @@ unref_dag(Obj_Entry *root)
 
 /*
  * Common code for MD __tls_get_addr().
+ *
+ * The tcb->tcb_dtv data structure is thread-local.  The reason that
+ * the function needs to take the rtld_bind_lock exclusive (as opposed
+ * to only shared, to safely access obj_list in allocate_module_tls())
+ * is to protect the rtld_malloc data.
  */
 static void *
 tls_get_addr_slow(struct tcb *tcb, int index, size_t offset, bool locked)