git: c4e18a7ba35e - stable/13 - libc posix_spawn(): explain why rtld can be used after fork

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Mon, 11 Mar 2024 00:30:36 UTC
The branch stable/13 has been updated by kib:

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

commit c4e18a7ba35e663d6d0765545ab6fd8377c55366
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-03-06 07:24:22 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-03-11 00:29:51 +0000

    libc posix_spawn(): explain why rtld can be used after fork
    
    (cherry picked from commit 2ce23b1f76721e44646fc98ba4e24a113a6d5972)
---
 lib/libc/gen/posix_spawn.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/libc/gen/posix_spawn.c b/lib/libc/gen/posix_spawn.c
index 67e6e3a19876..064bae186876 100644
--- a/lib/libc/gen/posix_spawn.c
+++ b/lib/libc/gen/posix_spawn.c
@@ -326,6 +326,11 @@ do_posix_spawn(pid_t *pid, const char *path,
 	 * ideal vfork(2) if we get an EINVAL from rfork -- this should only
 	 * happen with newer libc on older kernel that doesn't accept
 	 * RFSPAWN.
+	 *
+	 * Combination of vfork() (or its equivalent rfork() form) and
+	 * a special property of the libthr rtld locks ensure that
+	 * rtld is operational in the child.  In particular, libthr
+	 * rtld locks do not store owner' tid into the lock word.
 	 */
 #ifdef _RFORK_THREAD_STACK_SIZE
 	/*