]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: quic: work around NEW_TOKEN parsing error on backend side
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 12 Jun 2025 15:39:31 +0000 (17:39 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 12 Jun 2025 15:47:15 +0000 (17:47 +0200)
NEW_TOKEN frame is never emitted by a client, hence parsing was not
tested on frontend side.

On backend side, an issue can occur, as expected token length is static,
based on the token length used internally by haproxy. This is not
sufficient for most server implementation which uses larger token. This
causes a parsing error, which may cause skipping of following frames in
the same packet. This issue was detected using ngtcp2 as server.

As for now tokens are unused by haproxy, simply discard test on token
length during NEW_TOKEN frame parsing. The token itself is merely
skipped without being stored. This is sufficient for now to continue on
experimenting with QUIC backend implementation.

This does not need to be backported.

src/quic_frame.c
src/quic_rx.c

index d7a081e1aa352cd2abf9c7f4306ac16a8677f35b..7e1dbba544986d42de02b0ce82e3e4fb3176550a 100644 (file)
@@ -500,11 +500,19 @@ static int quic_parse_new_token_frame(struct quic_frame *frm, struct quic_conn *
 {
        struct qf_new_token *new_token_frm = &frm->new_token;
 
-       if (!quic_dec_int(&new_token_frm->len, pos, end) || end - *pos < new_token_frm->len ||
-           sizeof(new_token_frm->data) < new_token_frm->len)
+       if (!quic_dec_int(&new_token_frm->len, pos, end) || end - *pos < new_token_frm->len)
                return 0;
 
+       /* TODO token length is unknown as it is dependent from the peer. Hence
+        * dynamic allocation should be implemented for token storage, albeit
+        * with constraint to ensure memory usage remains reasonable.
+        */
+#if 0
+       if (sizeof(new_token_frm->data) < new_token_frm->len)
+               return 0;
        memcpy(new_token_frm->data, *pos, new_token_frm->len);
+#endif
+
        *pos += new_token_frm->len;
 
        return 1;
index b705d414d2c52275e5d478cd161d67bc05f3414e..e659bef9ec7d9b2c285c42c7e0f61c86d9115e08 100644 (file)
@@ -949,7 +949,11 @@ static int qc_parse_pkt_frms(struct quic_conn *qc, struct quic_rx_packet *pkt,
                                goto err;
                        }
                        else {
-                               /* TODO */
+                               /* TODO NEW_TOKEN not implemented on client side.
+                                * Note that for now token is not copied into <data> field
+                                * of qf_new_token frame. See quic_parse_new_token_frame()
+                                * for further explanations.
+                                */
                        }
                        break;
                case QUIC_FT_STREAM_8 ... QUIC_FT_STREAM_F: