]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: fd: allow fd_write_frag_line() to run before fdtab allocation
authorFrederic Lecaille <flecaille@haproxy.com>
Thu, 5 Nov 2026 09:18:37 +0000 (10:18 +0100)
committerFrederic Lecaille <flecaille@haproxy.com>
Thu, 5 Nov 2026 15:25:05 +0000 (16:25 +0100)
commita124f2089973cf6c0abd8aff5fd09131252085ac
tree306beba3838963d64be82dda74906f032114f1de
parentc923b3b4e407b0a587d1e926ecb8a1659ba38ed5
BUG/MINOR: fd: allow fd_write_frag_line() to run before fdtab allocation

With traces enabled on the command line using "-dt ssl:developer:clean",
a trace event is emitted during the configuration check if an SSL bind
line uses "generate-certificates".

check_config_validity() calls ->prepare_bind_conf() for every bind line.
For SSL, this is ssl_sock_prepare_bind_conf(). When "generate-certificates"
is set, that function checks that a default certificate exists, and calls
ssl_sock_choose_sni_ctx() for this. This happens long before
init_pollers() is called, so fdtab is still NULL. fd_write_frag_line()
reads fdtab[fd].state to take the per-fd lock and to test FD_INITIALIZED,
and the process segfaults as soon as the trace is written to stderr.

fd_write_frag_line() has read fdtab since 931d8b79a (v2.1), but no trace
could be emitted that early at that time. The crash became possible with
105c1ca13 (v3.2-dev13), which added traces to ssl_sock_choose_sni_ctx();
ssl_sock_prepare_bind_conf() has called this function from the
configuration check since b80635a7e (v3.0).

At this stage the process is still single-threaded, so the per-fd lock is
not needed. Skip the fdtab accesses when fdtab is not allocated yet, and
call writev() directly.

This should be backported to 3.2 and newer.
src/fd.c