]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: proxy: fix deinit crash on defaults with duplicate name
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 22 Jan 2026 14:20:31 +0000 (15:20 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 22 Jan 2026 14:40:01 +0000 (15:40 +0100)
commitac877a25ddf5f4a4dc1fbc0c5d225f806006e053
treece10dada36218f6f95289b5a3490eaaad10a1de8
parentb3f7d43248c7f9e7fdd586831e60349042406067
BUG/MINOR: proxy: fix deinit crash on defaults with duplicate name

A defaults proxy instance may be move into the orphaned list when it is
replaced by a newer section with the same name. This is attached via
<next> member as a single linked list entry. However, proxy free does
not clear <next> attach point.

This causes a crash on deinit if orphaned list is not empty. First, all
frontend/backend instances are freed. This triggers the release of every
referenced defaults instances as their refcount reach zero, but orphaned
list is not clean up. A loop is then conducted on orphaned list via
proxy_destroy_all_unref_defaults(). This causes a segfault due to access
on already freed entries.

To fix this, this patch extends proxy_destroy_defaults(). If orphaned
list is not empty, a loop is performed to remove a possible entry of the
currently released defaults instance. This ensures that loop over
orphaned list won't be able to access to already freed entries.

This bug is pretty rare as it requires to have duplicate name in
defaults sections, and also to use settings which forces defaults
referencing, such as TCP/HTTP rules. This can be reproduced with the
minimal config here :

defaults def
    http-request return status 200
frontend fe
    bind :20080
defaults def

Note that in fact orphaned list looping is not strictly necessary, as
defaults instances are automatically removed via refcounting. This will
be the purpose of a future patch. However, to limit the risk of
regression on stable releases during backport, this patch uses the more
direct approach for now.

This must be backported up to 3.1.
src/proxy.c