]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: conn/muxes/ssl: add ASSUME_NONNULL() prior to _srv_add_idle
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 1 Sep 2025 11:32:24 +0000 (13:32 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 1 Sep 2025 13:35:22 +0000 (15:35 +0200)
When manipulating idle backend connections for input/output processing,
special care is taken to ensure the connection cannot be accessed by
another thread, for example via a takeover. When processing is over,
connection is reinserted in its original list.

A connection can either be attached to a session (private ones) or a
server idle tree. In the latter case, <srv> is guaranteed to be non null
prior to _srv_add_idle() thanks to CO_FL_LIST_MASK comparison with conn
flags. This patch adds an ASSUME_NONNULL() to better reflect this.

This should fix coverity reports from github issue #3095.

src/connection.c
src/mux_fcgi.c
src/mux_h1.c
src/mux_h2.c
src/mux_spop.c
src/ssl_sock.c

index 4f0b5c342b7120ef0e1250ec86e972029c4e171b..e3e5040ba0ccc39fb7425f945c374c8ae6d8ff6d 100644 (file)
@@ -234,6 +234,7 @@ int conn_notify_mux(struct connection *conn, int old_flags, int forced_wake)
                                }
                        }
                        else {
+                               ASSUME_NONNULL(srv); /* srv is guaranteed by CO_FL_LIST_MASK */
                                HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
                                _srv_add_idle(srv, conn, conn_in_list == CO_FL_SAFE_LIST);
                                HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
index 83a2a1446a67a8565e6bb92f6d1d689f8bfb319c..caac5450d512009a45f3d04d9815247375b1e3cf 100644 (file)
@@ -3106,6 +3106,7 @@ struct task *fcgi_io_cb(struct task *t, void *ctx, unsigned int state)
                                }
                        }
                        else {
+                               ASSUME_NONNULL(srv); /* srv is guaranteed by CO_FL_LIST_MASK */
                                HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
                                _srv_add_idle(srv, conn, conn_in_list == CO_FL_SAFE_LIST);
                                HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
index 457ae45f8dec29f2c4234fc15b968cd3e1d7be62..86de1149c91ca7d3dfbed8c827e1529dcebbf530 100644 (file)
@@ -4351,6 +4351,7 @@ struct task *h1_io_cb(struct task *t, void *ctx, unsigned int state)
                                }
                        }
                        else {
+                               ASSUME_NONNULL(srv); /* srv is guaranteed by CO_FL_LIST_MASK */
                                HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
                                _srv_add_idle(srv, conn, conn_in_list == CO_FL_SAFE_LIST);
                                HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
index 876b199641d8897fb0ba6c52a81395de1bb850b5..fe68a4cdfe0588c65f6a734d2c91268f44eca57e 100644 (file)
@@ -5010,6 +5010,7 @@ struct task *h2_io_cb(struct task *t, void *ctx, unsigned int state)
                                }
                        }
                        else {
+                               ASSUME_NONNULL(srv); /* srv is guaranteed by CO_FL_LIST_MASK */
                                HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
                                _srv_add_idle(srv, conn, conn_in_list == CO_FL_SAFE_LIST);
                                HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
index 8fc2faeb2d4db225dccab22ab7eeab592e703fab..b1cb2676c72208af036a335f02d4d1cf7f0d3e1f 100644 (file)
@@ -2602,6 +2602,7 @@ static struct task *spop_io_cb(struct task *t, void *ctx, unsigned int state)
                                }
                        }
                        else {
+                               ASSUME_NONNULL(srv); /* srv is guaranteed by CO_FL_LIST_MASK */
                                HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
                                _srv_add_idle(srv, conn, conn_in_list == CO_FL_SAFE_LIST);
                                HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
index c1dd67c5387a443eaef80f24c2fe8097ea6a7603..5e7865e52d122da7e2effa1da7585d0c16fd5f8d 100644 (file)
@@ -6505,6 +6505,7 @@ leave:
                                }
                        }
                        else {
+                               ASSUME_NONNULL(srv); /* srv is guaranteed by CO_FL_LIST_MASK */
                                TRACE_DEVEL("adding conn back to idle list", SSL_EV_CONN_IO_CB, conn);
                                HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
                                _srv_add_idle(srv, conn, conn_in_list == CO_FL_SAFE_LIST);