]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: quic: fix fd leak on startup check quic-conn owned socket
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 5 Dec 2022 09:24:54 +0000 (10:24 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 5 Dec 2022 09:45:20 +0000 (10:45 +0100)
A startup check is done for first QUIC listener to detect if quic-conn
owned socket is supported by the system. This is done by creating a
dummy socket reusing the listener address. This socket must be closed as
soon as the check is done.

The socket condition is invalid as it excludes zero which is a valid
file-descriptor value. Fix this bug by adjusting this condition.

In theory, this bug could prevent the usage of quic-conn owned socket as
startup check would report a false error. Also, the file-descriptor
would leak as it is not closed. In practice, this cannot happen when
startup check is done after a 'quic4/quic6' listener is instantiated as
file-descriptor are allocated in ascending order by the system.

This should fix github issue #1954.

quic-conn owned socket implementation is scheduled for backport on 2.7.
This commit must be backported with it, more specifically to fix the
following patch :
  75839a44e7e904bd1e332b58bd579e03b6d106f0
  MINOR: quic: startup detect for quic-conn owned socket support

src/proto_quic.c

index 57dafc3c227718524ce7c7234c8cdf5ef66dbcd1..0f2bb2177264a66f3b4bdbb195509c4293fa5971 100644 (file)
@@ -598,7 +598,7 @@ static int quic_test_sock_per_conn_support(struct listener *l)
        if (ret) {
                fdtest = socket(rx->proto->fam->sock_domain,
                                rx->proto->sock_type, rx->proto->sock_prot);
-               if (fdtest > 0) {
+               if (fdtest >= 0) {
                        if (setsockopt(fdtest, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)) &&
                            bind(fdtest, (struct sockaddr *)&rx->addr, rx->proto->fam->sock_addrlen) < 0) {
                                ha_alert("Your platform does not seem to support multiple UDP sockets binded on the same address. "