]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: server: fix race on servers_list during server deletion
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 23 Oct 2024 16:18:48 +0000 (18:18 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 24 Oct 2024 09:35:57 +0000 (11:35 +0200)
commit7a02fcaf20dbc19db36052bbc7001bcea3912ab5
treecde696676487777653608503030f83f798274047
parent116178563c2fb57e28a76838cf85c4858b185b76
BUG/MEDIUM: server: fix race on servers_list during server deletion

Each server is inserted in a global list named servers_list on
new_server(). This list is then only used to finalize servers
initialization after parsing.

On dynamic server creation, there is no issue as new_server() is under
thread isolation. However, when a server is deleted after its refcount
reached zero, srv_drop() removes it from servers_list without lock
protection. In the longterm, this can cause list corruption and crashes,
especially if multiple adjacent servers are removed in parallel.

To fix this, convert servers_list to a mt_list. This should not impact
performance as servers_list is not used during runtime outside of server
creation/deletion.

This should fix github issue #2733. Thanks to Chris Staite who first
found the issue here.

This must be backported up to 2.6.
include/haproxy/server-t.h
include/haproxy/server.h
src/cfgparse.c
src/server.c