]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: deviceatlas: fix double-checked locking race in checkinst
authorDavid Carlier <dcarlier@deviceatlas.com>
Sat, 14 Feb 2026 13:24:00 +0000 (13:24 +0000)
committerWilly Tarreau <w@1wt.eu>
Sat, 14 Feb 2026 13:47:22 +0000 (14:47 +0100)
In da_haproxy_checkinst(), base[0] was checked before acquiring the
lock but not re-checked after. Another thread could have already
processed the reload between the initial check and the lock
acquisition, leading to a race condition.

This should be backported to lower branches.

addons/deviceatlas/da.c

index 24b5135922494aa132151a9655078ed659a3f24a..88caefa8b0fe223a7de9a619f940312417cd7b54 100644 (file)
@@ -280,6 +280,10 @@ static void da_haproxy_checkinst(void)
             da_property_decl_t extraprops[1] = {{NULL, 0}};
 #ifdef USE_THREAD
             HA_SPIN_LOCK(OTHER_LOCK, &dadwsch_lock);
+            if (base[0] == 0) {
+                HA_SPIN_UNLOCK(OTHER_LOCK, &dadwsch_lock);
+                return;
+            }
 #endif
             strlcpy2(atlasp, base + sizeof(char), sizeof(atlasp));
             jsonp = fopen(atlasp, "r");