haproxy/src
Willy Tarreau 44cf545000 BUG/MAJOR: cli: explicitly call cli_release_handler() upon error
Dmitry Sivachenko reported an embarrassing problem where haproxy
would sometimes segfault upon reload. After careful analysis and
code inspection, what happens is related to the "show sess" command
on the CLI, and it is not limited to reload operations only.

When a "show sess" is running, once the output buffer is full, the
stats applet grabs a reference to the session being dumped in order
for the current pointer to be able to advance by itself should this
session disappear while the buffer is full. The applet also uses a
release handler that is called when the applet terminates to release
such references.

The problem is that upon error, the command line parser sets the
applet state to STAT_CLI_O_END indicating it wants to terminate the
processing. Unfortunately, the release handler which is called later
to clean everything up relies on the applet's state to know what
operations were in progress, and as such it does not release the
reference. A later "show sess" or the completion of the task being
watched lead to a LIST_DEL() on the task's list which point to a
location that does not match the applet's reference list anymore
and the process dies.

One solution to this would be to add a flag to the current applet's
state mentionning it must leave, without affecting the state indicating
the current operation. It's a bit invasive but could be the long term
solution. The short term solution simply consists in calling the
release handler just before changing the state to STAT_CLI_O_END.
That way everything that must be released is released in time.

Note that the probability to encounter this issue is very low.
It requires a lot of "show sess" or "show sess all" calls, and
that one of them dies before being completed. That can happen
if "show sess" is run in scripts which truncate the output (eg:
"echo show sess|socat|head"). This could be the worst case as it
almost ensures that haproxy fills a buffer, grabs a reference and
detects the error on the socket.

There's no config-based workaround to this issue, except refraining
from issuing "show sess" on large connection counts or "show sess all".
If that's not possible to block everyone, restricting permissions on
the stats socket ensures only authorized tools can connect.

This fix must be backported to 1.5 and to 1.4 (with some changes in
1.4 since the release function does not exist so the LIST_DEL sequence
must be open-coded).

Special thanks to Dmitry for the fairly complete report.
2014-10-22 19:25:30 +02:00
..
acl.c CLEANUP: acl: cleanup some of the redundancy and spaghetti after last fix 2014-08-29 19:13:32 +02:00
appsession.c BUILD: definitely silence some stupid GCC warnings 2013-12-13 15:21:36 +01:00
arg.c MINOR: arg: improve wording on error reporting 2013-12-13 00:38:47 +01:00
auth.c BUG/MEDIUM: auth: fix segfault with http-auth and a configuration with an unknown encryption algorithm 2014-08-29 21:06:31 +02:00
backend.c BUG/MEDIUM: backend: fix URI hash when a query string is present 2014-10-17 12:11:50 +02:00
base64.c [MINOR] add encode/decode function for 30-bit integers from/to base64 2010-10-30 19:04:33 +02:00
buffer.c MINOR: buffer: align the last output line if there are less than 8 characters left 2013-11-21 08:07:04 +01:00
cfgparse.c BUG/MEDIUM: config: avoid skipping disabled proxies 2014-10-10 14:58:52 +02:00
channel.c BUG/MEDIUM: channel: bi_putblk() must not wrap before the end of buffer 2014-04-24 17:19:21 +02:00
checks.c BUG/MINOR: tcp-check: report the correct failed step in the status 2014-10-02 14:51:02 +02:00
chunk.c BUG/MINOR: chunk: Fix function chunk_strcmp and chunk_strcasecmp match a substring. 2014-05-09 19:16:13 +02:00
compression.c BUG/MINOR: compression: correctly report incoming byte count 2014-04-23 19:31:17 +02:00
connection.c MEDIUM: connection: add new bit in Proxy Protocol V2 2014-08-23 07:35:29 +02:00
cttproxy.c CLEANUP: cttproxy: remove a warning on undeclared close() 2012-10-05 22:18:07 +02:00
dumpstats.c BUG/MAJOR: cli: explicitly call cli_release_handler() upon error 2014-10-22 19:25:30 +02:00
ev_epoll.c BUG/MEDIUM: polling: fix possible CPU hogging of worker processes after receiving SIGUSR1. 2014-05-20 14:57:36 +02:00
ev_kqueue.c MINOR: polling: create function fd_compute_new_polled_status() 2014-01-26 00:42:32 +01:00
ev_poll.c MINOR: polling: create function fd_compute_new_polled_status() 2014-01-26 00:42:32 +01:00
ev_select.c MINOR: polling: create function fd_compute_new_polled_status() 2014-01-26 00:42:32 +01:00
fd.c BUG/MEDIUM: polling: fix possible CPU hogging of worker processes after receiving SIGUSR1. 2014-05-20 14:57:36 +02:00
freq_ctr.c BUG/MINOR: time: frequency counters are not totally accurate 2012-12-29 21:50:07 +01:00
frontend.c MINOR: logs: don't limit HTTP header captures to HTTP frontends 2014-06-13 16:32:48 +02:00
haproxy-systemd-wrapper.c BUG/MEDIUM: remove debugging code from systemd-wrapper 2014-09-24 12:59:25 +02:00
haproxy.c MINOR: deinit: fix memory leak 2014-09-05 17:22:54 +02:00
hash.c BUG/MEDIUM: backend: Update hash to use unsigned int throughout 2014-07-08 22:00:21 +02:00
hdr_idx.c OPTIM/MINOR: move the hdr_idx pools out of the proxy struct 2011-10-24 18:15:04 +02:00
i386-linux-vsys.c MEDIUM: listener: add support for linux's accept4() syscall 2012-10-08 20:11:03 +02:00
lb_chash.c REORG/MEDIUM: server: split server state and flags in two different variables 2014-05-22 11:27:00 +02:00
lb_fas.c REORG/MEDIUM: server: split server state and flags in two different variables 2014-05-22 11:27:00 +02:00
lb_fwlc.c REORG/MEDIUM: server: split server state and flags in two different variables 2014-05-22 11:27:00 +02:00
lb_fwrr.c REORG/MEDIUM: server: split server state and flags in two different variables 2014-05-22 11:27:00 +02:00
lb_map.c MINOR: server: make use of srv_is_usable() instead of checking eweight 2014-05-23 14:29:11 +02:00
listener.c MEDIUM: listener: support rebinding during resume() 2014-07-08 01:13:35 +02:00
log.c MINOR: log: add a new field "%lc" to implement a per-frontend log counter 2014-08-28 15:08:14 +02:00
map.c BUG/MEDIUM: patterns: last fix was still not enough 2014-04-28 14:19:17 +02:00
memory.c MINOR: cli: add the new "show pools" command 2014-01-28 16:50:35 +01:00
pattern.c BUG/MINOR: pattern: remove useless allocation of unused trash in pat_parse_reg() 2014-08-29 15:19:33 +02:00
payload.c BUG/MINOR: acl: req_ssl_sni fails with SSLv3 record version 2014-04-10 23:30:59 +02:00
peers.c BUG/MEDIUM: peers: fix key consistency for integer stick tables 2014-02-16 08:14:16 +01:00
pipe.c BUILD/MINOR: silent a build warning in src/pipe.c (fcntl) 2011-10-24 17:09:22 +02:00
proto_http.c BUG/MEDIUM: http: don't dump debug headers on MSG_ERROR 2014-10-22 19:25:09 +02:00
proto_tcp.c BUG/MINOR: config: do not accept more track-sc than configured 2014-10-17 11:53:05 +02:00
proto_uxst.c BUG/MEDIUM: unix: completely unbind abstract sockets during a pause() 2014-07-08 01:13:35 +02:00
protocol.c REORG: split "protocols" files into protocol and listener 2012-09-15 22:29:32 +02:00
proxy.c BUG/MEDIUM: http: adjust close mode when switching to backend 2014-09-30 18:44:22 +02:00
queue.c MINOR: server: make use of srv_is_usable() instead of checking eweight 2014-05-23 14:29:11 +02:00
raw_sock.c BUG/MINOR: raw_sock: also consider ENOTCONN in addition to EAGAIN for recv() 2014-03-04 07:27:18 +01:00
rbtree.c [MINOR] imported the rbtree function from Linux kernel 2007-01-07 02:12:57 +01:00
regex.c MINOR: regex: Use native PCRE API. 2014-06-18 15:14:00 +02:00
sample.c BUG/MAJOR: tcp: fix a possible busy spinning loop in content track-sc* 2014-07-30 08:56:35 +02:00
server.c MAJOR: checks: add support for a new "drain" administrative mode 2014-05-23 14:29:11 +02:00
session.c MINOR: session: export the function 'smp_fetch_sc_stkctr' 2014-07-15 19:09:56 +02:00
sessionhash.c [PATCH] appsessions: cleanup DEBUG_HASH and initialize request_counter 2008-08-13 23:43:26 +02:00
shctx.c MINOR: stats: add counters for SSL cache lookups and misses 2014-05-28 16:53:04 +02:00
signal.c BUG/MEDIUM: signal: signal handler does not properly check for signal bounds 2013-01-24 16:19:19 +01:00
ssl_sock.c MINOR: ssl: use SSL_get_ciphers() instead of directly accessing the cipher list. 2014-10-20 18:01:06 +02:00
standard.c MINOR: tools: add new functions to quote-encode strings 2014-06-16 18:20:14 +02:00
stick_table.c BUG/MAJOR: tcp: fix a possible busy spinning loop in content track-sc* 2014-07-30 08:56:35 +02:00
stream_interface.c BUG/CRITICAL: http: don't update msg->sov once data start to leave the buffer 2014-09-02 16:48:54 +02:00
task.c [OPTIM] task: don't scan the run queue if we know it's empty 2011-09-10 20:08:49 +02:00
time.c BUG/MINOR: time: frequency counters are not totally accurate 2012-12-29 21:50:07 +01:00
trace.c MINOR: add a new function call tracer for debugging purposes 2012-05-26 00:12:37 +02:00
uri_auth.c BUG/MEDIUM: uri_auth: missing NULL check and memory leak on memory shortage 2013-01-24 16:19:19 +01:00