[Bug 8211] New: pthread_atfork handlers not removed during dlclose

bugzilla at busybox.net bugzilla at busybox.net
Thu Jul 9 23:08:32 UTC 2015


           Summary: pthread_atfork handlers not removed during dlclose
           Product: uClibc
          Platform: PC
        OS/Version: Other
            Status: NEW
          Severity: minor
          Priority: P5
         Component: Threads
        AssignedTo: unassigned at uclibc.org
        ReportedBy: john.ata at baesystems.com
                CC: uclibc-cvs at uclibc.org
   Estimated Hours: 0.0

Created attachment 6096
  --> https://bugs.busybox.net/attachment.cgi?id=6096
Invoke pthread_atfork handler cleanup when removing the associated DSO...

If a program loads a DSO (dlopen) that sets up a pthread_atfork handler(s), and
then subsequently closes the DSO, the handler(s) are left in place.  If fork()
is subsequently called, the handlers are invoked even though the DSO has been
removed causing crashes or unpredictable code execution.  This is because the
code in __cxa_finalize(atexit.c)to invoke the unregister_atfork() routine is
ifdef'd out with the comment that it hasn't been "looked into this yet...".  I
have added the code in and it seems to work properly.

--- libc/stdlib/_atexit.c    2015-07-09 13:08:22.080550119 -040
+++ libc/stdlib/_atexit.c        2015-07-08 18:12:06.476077
601 -0400
@@ -42,6 +42,7 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <atomic.h>
+#include <fork.h>

 #include <bits/uClibc_mutex.h>
@@ -207,17 +208,15 @@

-#if 0 /* haven't looked into this yet... */
      * Remove the registered fork handlers. We do not have to
      * unregister anything if the program is going to terminate anyway.
-    if (d != NULL) {
+    if (dso_handle != NULL) {
+        UNREGISTER_ATFORK(dso_handle);

Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the uClibc-cvs mailing list