BUG/MINOR: ssl/cli: use the right list member in "add ssl crt-list" release
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.