BUG/MINOR: peers: Use after free of "peers" section.
authorFrédéric Lécaille <flecaille@haproxy.com>
Tue, 24 Mar 2020 19:08:30 +0000 (20:08 +0100)
committerWilliam Lallemand <wlallemand@haproxy.org>
Tue, 24 Mar 2020 19:49:38 +0000 (20:49 +0100)
commit87eacbb12fb819adb3acd68a221ead27c70efb43
tree64ecfff6a8573af50865824dd985a3eabf045b53
parent3ef2d565303af6dd7c24b62fdb22e43f1d1638bf
BUG/MINOR: peers: Use after free of "peers" section.

When a "peers" section has not any local peer, it is removed of the list
of "peers" sections by check_config_validity(). But a stick-table which
refers to a "peers" section stores a pointer to this peers section.
These pointer must be reset to NULL value for each stick-table refering to
such a "peers" section to prevent stktable_init() to start the peers frontend
attached to the peers section dereferencing the invalid pointer.

Furthemore this patch stops the peers frontend as this is done for other
configurations invalidated by check_config_validity().

Thank you to Olivier D for having reported this issue with such a
simple configuration file which made haproxy crash when started with
-c option for configuration file validation.

  defaults
    mode http

  peers mypeers
    peer toto 127.0.0.1:1024

  backend test
    stick-table type ip size 10k expire 1h store http_req_rate(1h) peers mypeers

Must be backported to 2.1 and 2.0.
src/cfgparse.c