]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: lb: Always lock the server when calling server_{take,drop}_conn
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 16 Oct 2020 14:27:17 +0000 (16:27 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 17 Oct 2020 07:29:43 +0000 (09:29 +0200)
commit26a52af642c3fcfd6a637aef019b78147c05e126
tree627be92a8adc09175c844d4e12c8c095a1c899cd
parentdb2c17da60e80091615ddbe8d97cb964d1f00ac7
BUG/MEDIUM: lb: Always lock the server when calling server_{take,drop}_conn

The server lock must be held when server_take_conn() and server_drop_conn()
lbprm callback functions are called. It is a documented prerequisite but it is
not always performed. It only affects leastconn and fas lb algorithm. Others
don't use these callback functions.

A race condition on the next pending effecive weight (next_eweight) may be
encountered with the leastconn lb algorithm. An agent check may set it to 0
while fwlc_srv_reposition() is called. The server is locked during the
next_eweight update. But because the server lock is not acquired when
fwlc_srv_reposition() is called, we may use it to recompute the server key,
leading to a division by 0.

This patch must be backported as far as 1.8.
src/backend.c
src/stream.c