]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: ssl/cli: use the right list member in "add ssl crt-list" release
authorWilliam Lallemand <wlallemand@haproxy.com>
Fri, 20 Nov 2026 10:49:08 +0000 (10:49 +0000)
committerWilliam Lallemand <wlallemand@haproxy.com>
Fri, 20 Nov 2026 10:52:20 +0000 (11:52 +0100)
cli_release_add_crtlist() walks the crtlist_entry's list of ckch_inst with
the "by_ckchs" list member instead of "by_crtlist_entry". Since
list_for_each_entry_safe() re-bases each node with the offset of the given
member, walking a list whose elements are chained through
"by_crtlist_entry" using the offset of "by_ckchs" produces a bogus struct
ckch_inst pointer, which is then passed to ckch_inst_free(). The latter
writes through it (LIST_DELETE on both members and free()), so this is
not just a wild read but real memory corruption.

This happens when "add ssl crt-list" fails after at least one ckch_inst
was already generated and appended to the entry being added (e.g. a later
bind_conf failing to instantiate), in which case the worker dies with a
SIGSEGV during the cleanup of the discarded entry. This requires ADMIN
CLI access so it stays out of the threat model, but it is a crash of the
worker triggered by a legitimate command.

Use "by_crtlist_entry" like every other walk of this list in the same
file (crtlist_entry_free() and both loops of the delete handler). The bug
is present since the introduction of the command in 2.2 (e67c80be7f
"MEDIUM: ssl/cli: 'add ssl crt-list' command"), so every maintained
branch is affected, but the fix applies cleanly everywhere as this code
never changed since.

This should be backported in every stable branches.

Reported by Bruno Henc (@brhenc).

Fixes issue #3586.

src/ssl_crtlist.c

index 7319b130739fecbaefb1e2c87ce6b6c71f62c2a9..7f7ef65d11cb3a450d4ec264e1e2e0a3f2cd8808 100644 (file)
@@ -1186,7 +1186,7 @@ static void cli_release_add_crtlist(struct appctx *appctx)
                LIST_DELETE(&entry->by_crtlist);
                LIST_DELETE(&entry->by_ckch_store);
 
-               list_for_each_entry_safe(inst, inst_s, &entry->ckch_inst, by_ckchs) {
+               list_for_each_entry_safe(inst, inst_s, &entry->ckch_inst, by_crtlist_entry) {
                        ckch_inst_free(inst);
                }
                crtlist_free_filters(entry->filters);