]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: tools: also protect the library name resolution against concurrent accesses
authorWilly Tarreau <w@1wt.eu>
Fri, 4 Apr 2025 14:56:44 +0000 (16:56 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 17 Apr 2025 14:25:47 +0000 (16:25 +0200)
This is an extension of eb41d768f ("MINOR: tools: use only opportunistic
symbols resolution"). It also makes sure we're not calling dladddr() in
parallel to dladdr_and_size(), as a preventive measure against some
potential deadlocks in the inner layers of the libc.

src/tools.c

index 2e4858854810b42d3e9ec5875c1dce1d9d44d7ad..b0b066a1d834df0432dd03705d5c0d7d5a42df3e 100644 (file)
@@ -5611,11 +5611,12 @@ const void *resolve_sym_name(struct buffer *buf, const char *pfx, const void *ad
                goto use_array;
 
        i = dladdr_and_size(addr, &dli, &size);
-       if (!isolated)
-               HA_SPIN_UNLOCK(OTHER_LOCK, &dladdr_lock);
 
-       if (!i)
+       if (!i) {
+               if (!isolated)
+                       HA_SPIN_UNLOCK(OTHER_LOCK, &dladdr_lock);
                goto use_array;
+       }
 
        /* 1. prefix the library name if it's not the same object as the one
         * that contains the main function. The name is picked between last '/'
@@ -5637,6 +5638,9 @@ const void *resolve_sym_name(struct buffer *buf, const char *pfx, const void *ad
                ha_thread_relax();
        }
 
+       if (!isolated)
+               HA_SPIN_UNLOCK(OTHER_LOCK, &dladdr_lock);
+
        if (dli_main.dli_fbase != dli.dli_fbase) {
                fname = dli.dli_fname;
                p = strrchr(fname, '/');