]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MEDIUM: ssl/cli: don't unlock the certificate lock after a failed trylock
authorWilliam Lallemand <wlallemand@irq6.net>
Tue, 3 Nov 2026 16:53:09 +0000 (16:53 +0000)
committerWilliam Lallemand <wlallemand@irq6.net>
Tue, 3 Nov 2026 16:58:36 +0000 (16:58 +0000)
When ckch_store_load_payload() fails to acquire ckch_lock, it jumps to
the common cleanup path, which unconditionally releases the lock. This
unlocks another operation's lock and returns success because errcode is
still zero. When the actual owner subsequently unlocks, the lock state
underflows and later certificate commands remain blocked.

Return ERR_ALERT | ERR_FATAL immediately on failed lock acquisition. No
temporary resources have been allocated at this point, so cleanup is
unnecessary.

This regression was introduced in 3.4-dev11 by commit efe6c97488, which
extracted ckch_store_load_payload() from the CLI parser. This fix should
be backported to 3.4 only. Versions 3.3 and older return directly on
failed lock acquisition and are not affected.

src/ssl_ckch.c

index 2c33bfe4bb0e54583f5b48744b61a186efcfa264..78044e2f2917b4591026796bd50471c852efbdee 100644 (file)
@@ -3221,7 +3221,7 @@ int ckch_store_load_payload(char *path, char *payload, char **err)
         * manipulate ckch_store and ckch_inst */
        if (HA_SPIN_TRYLOCK(CKCH_LOCK, &ckch_lock)) {
                memprintf(err, "Can't update the certificate!\nOperations on certificates are currently locked!\n");
-               goto end;
+               return ERR_ALERT | ERR_FATAL;
        }
 
        pathbuf = alloc_trash_chunk();