haproxy/src
Aurelien DARRAGON 6b0b9bd39f BUG/MEDIUM: hlua: prevent deadlocks with main lua lock
Main lua lock is used at various places in the code.

Most of the time it is used from unprotected lua environments,
in which case the locking is mandatory.
But there are some cases where the lock is attempted from protected
lua environments, meaning that lock is already owned by the current
thread. Thus new locking attempt should be skipped to prevent any
deadlocks from occuring.

To address this, "already_safe" lock hint was implemented in
hlua_ctx_init() function with commit bf90ce1
("BUG/MEDIUM: lua: dead lock when Lua tasks are trigerred")

But this approach is not very safe, for 2 reasons:

First reason is that there are still some code paths that could lead
to deadlocks.
For instance, in register_task(), hlua_ctx_init() is called with
already_safe set to 1 to prevent deadlock from occuring.

But in case of task init failure, hlua_ctx_destroy() will be called
from the same environment (protected environment), and hlua_ctx_destroy()
does not offer the already_safe lock hint.. resulting in a deadlock.

Second reason is that already_safe hint is used to completely skip
SET_LJMP macros (which manipulates the lock internally), resulting
in some logics in the function being unprotected from lua aborts in
case of unexpected errors when manipulating the lua stack (the lock
does not protect against longjmps)

Instead of leaving the locking responsibility to the caller, which is
quite error prone since we must find out ourselves if we are or not in
a protected environment (and is not robust against code re-use),
we move the deadlock protection logic directly in hlua_lock() function.

Thanks to a thread-local lock hint, we can easily guess if the current
thread already owns the main lua lock, in which case the locking attempt
is skipped. The thread-local lock hint is implemented as a counter so
that the lock is properly dropped when the counter reaches 0.
(to match actual lock() and unlock() calls)

This commit depends on "MINOR: hlua: simplify lua locking"
It may be backported to every stable versions.
[prior to 2.5 lua filter API did not exist, filter-related parts
should be skipped]
2023-04-05 08:58:17 +02:00
..
acl.c
action.c
activity.c MINOR: tree-wide: Simplifiy some tests on SHUT flags by accessing SCs directly 2023-04-05 08:57:06 +02:00
applet.c MINOR: stconn/applet: Add BUG_ON_HOT() to be sure SE_FL_EOS is never set alone 2023-04-05 08:57:06 +02:00
arg.c
auth.c
backend.c MEDIUM: tree-wide: Move flags about shut from the channel to the SC 2023-04-05 08:57:06 +02:00
base64.c
cache.c MEDIUM: cache: Use the sedesc to report and detect end of processing 2023-04-05 08:57:05 +02:00
calltrace.c
cbuf.c
cfgcond.c MINOR: cfgcond: Implement enabled condition expression 2023-02-21 11:44:55 +01:00
cfgdiag.c
cfgparse-global.c BUG/MINOR: haproxy: Fix option to disable the fast-forward 2023-02-21 11:44:55 +01:00
cfgparse-listen.c MEDIUM: proxy/http_ext: implement dynamic http_ext 2023-01-27 15:18:59 +01:00
cfgparse-quic.c MINOR: quic: Add a fake congestion control algorithm named "nocc" 2023-03-31 17:09:03 +02:00
cfgparse-ssl.c MINOR: ssl: Add global options to modify ocsp update min/max delay 2023-03-02 15:37:23 +01:00
cfgparse-tcp.c MINOR: listener: move TCP_FO to bind_conf 2023-02-03 18:00:20 +01:00
cfgparse-unix.c
cfgparse.c MINOR: tinfo: make thread_set functions return nth group/mask instead of first 2023-02-28 10:28:47 +01:00
channel.c MEDIUM: tree-wide: Move flags about shut from the channel to the SC 2023-04-05 08:57:06 +02:00
check.c MINOR: server: correctly free servers on deinit() 2023-04-05 08:58:16 +02:00
chunk.c
cli.c MINOR: tree-wide: Simplifiy some tests on SHUT flags by accessing SCs directly 2023-04-05 08:57:06 +02:00
clock.c MEDIUM: clock: force internal time to wrap early after boot 2023-02-08 11:10:33 +01:00
compression.c
connection.c BUG/MEDIUM: connection: Preserve flags when a conn is removed from an idle list 2023-03-16 15:34:20 +01:00
cpuset.c
debug.c MINOR: tree-wide: Simplifiy some tests on SHUT flags by accessing SCs directly 2023-04-05 08:57:06 +02:00
dgram.c
dict.c
dns.c MEDIUM: dns: Use the sedesc to report and detect end of processing 2023-04-05 08:57:05 +02:00
dynbuf.c
eb32sctree.c
eb32tree.c
eb64tree.c
ebimtree.c
ebistree.c
ebmbtree.c
ebpttree.c
ebsttree.c
ebtree.c
errors.c
ev_epoll.c
ev_evports.c
ev_kqueue.c
ev_poll.c
ev_select.c
event_hdl.c
extcheck.c
fcgi-app.c BUG/MINOR: fcgi-app: prevent 'use-fcgi-app' in default section 2023-01-27 15:18:59 +01:00
fcgi.c
fd.c BUG/MAJOR: fd/threads: close a race on closing connections after takeover 2023-03-09 14:01:48 +01:00
filters.c MEDIUM: tree-wide: Move flags about shut from the channel to the SC 2023-04-05 08:57:06 +02:00
fix.c
flt_bwlim.c MEDIUM: tree-wide: Move flags about shut from the channel to the SC 2023-04-05 08:57:06 +02:00
flt_http_comp.c
flt_spoe.c MEDIUM: spoe: Use the sedesc to report and detect end of processing 2023-04-05 08:57:05 +02:00
flt_trace.c
freq_ctr.c
frontend.c MINOR: stconn/channel: Move CF_READ_DONTWAIT into the SC and rename it 2023-04-05 08:57:05 +02:00
h1.c BUG/CRITICAL: http: properly reject empty http header field names 2023-02-14 08:48:54 +01:00
h1_htx.c BUG/MEDIUM: h1-htx: Never copy more than the max data allowed during parsing 2023-02-27 17:45:45 +01:00
h2.c
h3.c BUG/MINOR: h3: properly handle incomplete remote uni stream type 2023-03-23 14:38:06 +01:00
h3_stats.c
haproxy.c BUG/MINOR: log: free log forward proxies on deinit() 2023-04-05 08:58:16 +02:00
hash.c
hlua.c BUG/MEDIUM: hlua: prevent deadlocks with main lua lock 2023-04-05 08:58:17 +02:00
hlua_fcn.c MEDIUM: hlua_fcn/api: remove some old server and proxy attributes 2023-04-05 08:58:16 +02:00
hpack-dec.c BUG/CRITICAL: http: properly reject empty http header field names 2023-02-14 08:48:54 +01:00
hpack-enc.c
hpack-huff.c BUG/MEDIUM: hpack: fix incorrect huffman decoding of some control chars 2023-01-26 11:36:39 +01:00
hpack-tbl.c
hq_interop.c MINOR: h3/hq-interop: handle no data in decode_qcs() with FIN set 2023-02-17 16:25:00 +01:00
http.c MINOR: http_fetch: add case insensitive support for smp_fetch_url_param 2023-03-30 14:11:10 +02:00
http_acl.c
http_act.c MINOR: http-act: emit a warning when a header field name contains forbidden chars 2023-04-04 05:38:01 +02:00
http_ana.c MEDIUM: tree-wide: Move flags about shut from the channel to the SC 2023-04-05 08:57:06 +02:00
http_client.c MEDIUM: http_client: Use the sedesc to report and detect end of processing 2023-04-05 08:57:06 +02:00
http_conv.c CLEANUP: assorted typo fixes in the code and comments 2023-04-01 18:33:40 +02:00
http_ext.c CLEANUP: assorted typo fixes in the code and comments 2023-04-01 18:33:40 +02:00
http_fetch.c MEDIUM: tree-wide: Move flags about shut from the channel to the SC 2023-04-05 08:57:06 +02:00
http_htx.c MINOR: http_htx: add http_prepend_header() to prepend value to header 2023-01-27 15:18:59 +01:00
http_rules.c
htx.c OPTIM: htx: inline the most common memcpy(8) 2023-02-03 13:39:18 +01:00
init.c
jwt.c MINOR: jwt: Add support for RSA-PSS signatures (PS256 algorithm) 2023-03-08 10:43:04 +01:00
lb_chash.c
lb_fas.c
lb_fwlc.c
lb_fwrr.c
lb_map.c
listener.c CLEANUP: listener: only store conn counts for local threads 2023-02-28 10:28:47 +01:00
log.c MEDIUM: log: Use the sedesc to report and detect end of processing 2023-04-05 08:57:05 +02:00
lru.c
mailers.c
map.c MINOR: tree-wide: Simplifiy some tests on SHUT flags by accessing SCs directly 2023-04-05 08:57:06 +02:00
mjson.c
mqtt.c
mux_fcgi.c BUG/MEDIUM: connection: Preserve flags when a conn is removed from an idle list 2023-03-16 15:34:20 +01:00
mux_h1.c MINOR: mux-h1: Report an error to the SE descriptor on truncated message 2023-04-05 08:57:05 +02:00
mux_h2.c CLEANUP: assorted typo fixes in the code and comments 2023-04-01 18:33:40 +02:00
mux_pt.c CLEANUP: mux-h1/mux-pt: Remove useless test on SE_FL_SHR/SE_FL_SHW flags 2023-04-05 08:57:05 +02:00
mux_quic.c CLEANUP: assorted typo fixes in the code and comments 2023-04-01 18:33:40 +02:00
mworker-prog.c
mworker.c MINOR: tree-wide: Simplifiy some tests on SHUT flags by accessing SCs directly 2023-04-05 08:57:06 +02:00
namespace.c
ncbuf.c
pattern.c MINOR: pattern: use trim_all_pools() instead of a conditional malloc_trim() 2023-03-22 17:30:28 +01:00
payload.c
peers.c MEDIUM: peers: Use the sedesc to report and detect end of processing 2023-04-05 08:57:05 +02:00
pipe.c
pool.c MINOR: pools: report a replaced memory allocator instead of just malloc_trim() 2023-03-22 18:05:02 +01:00
proto_quic.c MINOR: listener: remove the now useless LI_F_QUIC_LISTENER flag 2023-02-03 18:00:20 +01:00
proto_sockpair.c
proto_tcp.c MINOR: listener: move TCP_FO to bind_conf 2023-02-03 18:00:20 +01:00
proto_udp.c BUG/MINOR: listeners: fix suspend/resume of inherited FDs 2023-01-16 14:00:50 +01:00
proto_uxdg.c MINOR: proto_ux: ability to dump ABNS names in error messages 2023-02-23 15:05:05 +01:00
proto_uxst.c MINOR: proto_ux: ability to dump ABNS names in error messages 2023-02-23 15:05:05 +01:00
protocol.c MINOR: listener: pause_listener() becomes suspend_listener() 2023-02-23 15:05:05 +01:00
proxy.c MINOR: tree-wide: Simplifiy some tests on SHUT flags by accessing SCs directly 2023-04-05 08:57:06 +02:00
qmux_http.c MINOR: h3/hq-interop: handle no data in decode_qcs() with FIN set 2023-02-17 16:25:00 +01:00
qmux_trace.c MINOR: mux-quic: add flow-control info to minimal trace level 2023-03-22 16:08:54 +01:00
qpack-dec.c BUG/MAJOR: qpack: fix possible read out of bounds in static table 2023-03-17 16:43:51 +01:00
qpack-enc.c
qpack-tbl.c
queue.c
quic_cc.c
quic_cc_cubic.c BUG/MINOR: quic: Remove useless BUG_ON() in newreno and cubic algo implementation 2023-04-03 13:15:56 +02:00
quic_cc_newreno.c BUG/MINOR: quic: Remove useless BUG_ON() in newreno and cubic algo implementation 2023-04-03 13:15:56 +02:00
quic_cc_nocc.c BUG/MAJOR: quic: Congestion algorithms states shared between the connection 2023-04-02 13:10:13 +02:00
quic_conn.c MINOR: tree-wide: Simplifiy some tests on SHUT flags by accessing SCs directly 2023-04-05 08:57:06 +02:00
quic_frame.c MINOR: quic: Traces adjustments at proto level. 2023-03-31 09:54:59 +02:00
quic_loss.c BUG/MINOR: quic: Possible wrong PTO computing 2023-04-04 18:24:28 +02:00
quic_sock.c MINOR: quic_sock: un-statify quic_conn_sock_fd_iocb() 2023-03-10 14:30:01 +01:00
quic_stats.c
quic_stream.c
quic_tls.c MINOR: quic: Add traces about QUIC TLS key update 2023-03-03 19:12:26 +01:00
quic_tp.c MINOR: quic: Do not accept wrong active_connection_id_limit values 2023-03-08 08:50:54 +01:00
raw_sock.c OPTIM: global: move byte counts out of global and per-thread 2023-01-12 16:37:45 +01:00
regex.c
resolvers.c BUG/MEDIUM: resolvers: Properly stop server resolutions on soft-stop 2023-03-14 15:23:55 +01:00
ring.c MINOR: tree-wide: Simplifiy some tests on SHUT flags by accessing SCs directly 2023-04-05 08:57:06 +02:00
sample.c MINOR: jwt: Add support for RSA-PSS signatures (PS256 algorithm) 2023-03-08 10:43:04 +01:00
server.c MINOR: server: correctly free servers on deinit() 2023-04-05 08:58:16 +02:00
server_state.c
session.c BUG/MEDIUM: quic: fix crash when "option nolinger" is set in the frontend 2023-02-09 18:04:10 +01:00
sha1.c
shctx.c
signal.c
sink.c BUG/MINOR: sink: free forward_px on deinit() 2023-04-05 08:58:16 +02:00
slz.c
sock.c CLEANUP: sock: always perform last connection updates before wakeup 2023-03-08 16:07:32 +01:00
sock_inet.c BUG/MEDIUM: listener: duplicate inherited FDs if needed 2023-01-11 11:27:20 +01:00
sock_unix.c MINOR: proto_ux: ability to dump ABNS names in error messages 2023-02-23 15:05:05 +01:00
ssl_ckch.c MINOR: tree-wide: Simplifiy some tests on SHUT flags by accessing SCs directly 2023-04-05 08:57:06 +02:00
ssl_crtlist.c MINOR: tree-wide: Simplifiy some tests on SHUT flags by accessing SCs directly 2023-04-05 08:57:06 +02:00
ssl_ocsp.c BUG/MINOR: ssl: Fix potential leak in cli_parse_update_ocsp_response 2023-03-31 09:10:36 +02:00
ssl_sample.c
ssl_sock.c CLEANUP: assorted typo fixes in the code and comments 2023-04-01 18:33:40 +02:00
ssl_utils.c
stats.c BUG/MINOR: stats: properly handle server stats dumping resumption 2023-04-05 08:58:16 +02:00
stconn.c MINOR: stconn/applet: Add BUG_ON_HOT() to be sure SE_FL_EOS is never set alone 2023-04-05 08:57:06 +02:00
stick_table.c MINOR: tree-wide: Simplifiy some tests on SHUT flags by accessing SCs directly 2023-04-05 08:57:06 +02:00
stream.c MINOR: tree-wide: Simplifiy some tests on SHUT flags by accessing SCs directly 2023-04-05 08:57:06 +02:00
task.c BUG/MEDIUM: sched: allow a bit more TASK_HEAVY to be processed when needed 2023-02-17 16:01:34 +01:00
tcp_act.c
tcp_rules.c MEDIUM: tree-wide: Move flags about shut from the channel to the SC 2023-04-05 08:57:06 +02:00
tcp_sample.c BUG/MINOR: tcp_sample: fix a bug in fc_dst_port and fc_dst_is_local sample fetches 2023-03-16 11:26:53 +01:00
tcpcheck.c BUG/MINOR: tcpcheck: Be able to expect an empty response 2023-04-05 08:46:06 +02:00
thread.c CLEANUP: assorted typo fixes in the code and comments 2023-04-01 18:33:40 +02:00
time.c
tools.c MEDIUM: tools: further relax dlopen() checks too consider grouped symbols 2023-03-22 17:30:28 +01:00
trace.c MEDIUM: applet/trace: Register a new trace source with its events 2023-04-05 08:46:06 +02:00
uri_auth.c
uri_normalizer.c
vars.c
version.c
wdt.c BUG/MEDIUM: wdt: fix wrong thread being checked for sleeping 2023-02-17 16:01:34 +01:00
xprt_handshake.c
xprt_quic.c MEDIUM: quic: trigger fast connection closing on process stopping 2023-02-20 11:20:18 +01:00