Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-9]: src/libexec/ld.elf_so Pull up following revision(s) (requeste...



details:   https://anonhg.NetBSD.org/src/rev/6338fd728f7e
branches:  netbsd-9
changeset: 374113:6338fd728f7e
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Apr 01 16:08:05 2023 +0000

description:
Pull up following revision(s) (requested by riastradh in ticket #1624):

        libexec/ld.elf_so/rtld.c: revision 1.212

ld.elf_so(8): Make fork take a shared, not exclusive, lock.

We only need to ensure that there are no concurrent modifications to
the rtld data structures in flight, since the threads that began
those modifications will not exist in the child and will therefore be
unable to complete them in the child.

A shared lock suffices to ensure there are no such concurrent
modifications in flight; an exclusive lock is not necessary, and can
cause deadlock if fork is executed from a signal handler, which is
explicitly allowed by POSIX (and our own sigaction(2) man page) which
marks fork as async-signal-safe.

PR lib/56979

diffstat:

 libexec/ld.elf_so/rtld.c |  9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diffs (35 lines):

diff -r 6c10e9e44ff2 -r 6338fd728f7e libexec/ld.elf_so/rtld.c
--- a/libexec/ld.elf_so/rtld.c  Sat Apr 01 16:03:48 2023 +0000
+++ b/libexec/ld.elf_so/rtld.c  Sat Apr 01 16:08:05 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtld.c,v 1.197.2.4 2020/05/13 18:08:38 martin Exp $     */
+/*     $NetBSD: rtld.c,v 1.197.2.5 2023/04/01 16:08:05 martin Exp $     */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -40,7 +40,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: rtld.c,v 1.197.2.4 2020/05/13 18:08:38 martin Exp $");
+__RCSID("$NetBSD: rtld.c,v 1.197.2.5 2023/04/01 16:08:05 martin Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -1535,14 +1535,13 @@ pid_t __fork(void);
 __dso_public pid_t
 __locked_fork(int *my_errno)
 {
-       sigset_t mask;
        pid_t result;
 
-       _rtld_exclusive_enter(&mask);
+       _rtld_shared_enter();
        result = __fork();
        if (result == -1)
                *my_errno = errno;
-       _rtld_exclusive_exit(&mask);
+       _rtld_shared_exit();
 
        return result;
 }



Home | Main Index | Thread Index | Old Index