]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: connection/http-reuse: fix address collision on unhandled address families
authorAurelien DARRAGON <adarragon@haproxy.com>
Wed, 23 Oct 2024 08:42:19 +0000 (10:42 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Wed, 23 Oct 2024 09:48:16 +0000 (11:48 +0200)
commitb5b40a9843e505ed84153327ab897ca0e8d9a571
tree627d05b517129e0bf61c314aa022bcf924b5b387
parentb74fb1325e60a2573f1ed8a460129bc6c0c9e53f
BUG/MEDIUM: connection/http-reuse: fix address collision on unhandled address families

As described in GH #2765, there were situations where http connections
would be re-used for requests to different endpoints, which is obviously
unexpected. In GH #2765, this occured with httpclient and UNIX socket
combination, but later code analysis revealed that while disabling http
reuse on httpclient proxy helped, it didn't fix the underlying issue since
it was found that conn_calculate_hash_sockaddr() didn't take into account
families such as AF_UNIX or AF_CUST_SOCKPAIR, and because of that the
sock_addr part of the connection wasn't hashed.

To properly fix the issue, let's explicly handle UNIX (both regular and
ABNS) and AF_CUST_SOCKPAIR families, so that the destination address is
properly hashed. To prevent this bug from re-appearing: when the family
isn't known, instead of doing nothing like before, let's fall back to a
generic (unoptimal) hashing which hashes the whole sockaddr_storage struct

As a workaround, http-reuse may be disabled on impacted proxies.
(unfortunately this doesn't help for httpclient since reuse policy
defaults to safe and cannot be modified from the config)

It should be backported to all stable versions.

Shout out to @christopherhibbert for having reported the issue and
provided a trivial reproducer.

[ada: prior to 3.0, ctx adjt is required because conn_hash_update()'s
 prototype is slightly different]
src/connection.c