]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MEDIUM: ssl/cli: reset the transaction on interrupted CA/CRL commits
authorOlivier Houchard <ohouchard@haproxy.com>
Wed, 25 Nov 2026 16:35:16 +0000 (17:35 +0100)
committerOlivier Houchard <cognet@ci0.org>
Wed, 25 Nov 2026 16:23:12 +0000 (17:23 +0100)
As was fixed for certificates in commit ca42c37bc ("BUG/MEDIUM: ssl/cli:
reset the ongoing transaction when "commit ssl cert" is interrupted"),
when a "commit ssl ca-file" or "commit ssl crl-file" applet is released
before the end, e.g. because the CLI client left while it was yielding,
the release function frees the new entry but the transaction still
references it, or the old entry, already freed once the new one is
inserted. The next "show", "set", "commit" or "abort" on that file then
uses freed memory, which crashes the process.

Let's reset the transaction in the release functions when the applet did
not reach CACRL_ST_FIN. This was introduced in 2.5 with the commands, by
commits a32a68bd3 ("MEDIUM: ssl: Add "set+commit ssl ca-file" CLI
commands") and a51b339d9 ("MEDIUM: ssl: Add "set+commit ssl crl-file" CLI
commands"), so this should be backported to all stable branches.

src/ssl_ckch.c

index 2e41acd16156969ca26ded90b705ca6c8e12d0a9..84b3d6fcbbc36a0d211fd94daf0f527653d8bbb7 100644 (file)
@@ -4017,6 +4017,13 @@ static void cli_release_commit_cafile(struct appctx *appctx)
        struct commit_cacrlfile_ctx *ctx = appctx->svcctx;
        struct cafile_entry *new_cafile_entry = ctx->new_entry;
 
+       /* the transaction is over, e.g. if the client left before the end of the commit */
+       if (ctx->state != CACRL_ST_FIN) {
+               cafile_transaction.new_cafile_entry = NULL;
+               cafile_transaction.old_cafile_entry = NULL;
+               cafile_transaction.path = NULL;
+       }
+
        /* Remove the uncommitted cafile_entry from the tree. */
        if (new_cafile_entry) {
                ebmb_delete(&new_cafile_entry->node);
@@ -4516,6 +4523,13 @@ static void cli_release_commit_crlfile(struct appctx *appctx)
        struct commit_cacrlfile_ctx *ctx = appctx->svcctx;
        struct cafile_entry *new_crlfile_entry = ctx->new_entry;
 
+       /* the transaction is over, e.g. if the client left before the end of the commit */
+       if (ctx->state != CACRL_ST_FIN) {
+               crlfile_transaction.new_crlfile_entry = NULL;
+               crlfile_transaction.old_crlfile_entry = NULL;
+               crlfile_transaction.path = NULL;
+       }
+
        /* Remove the uncommitted cafile_entry from the tree. */
        if (new_crlfile_entry) {
                ebmb_delete(&new_crlfile_entry->node);