]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: quic: do not reject CRYPTO data exactly fitting in buffer
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 18 Nov 2026 15:50:24 +0000 (16:50 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 19 Nov 2026 14:08:35 +0000 (15:08 +0100)
CRYPTO data buffering does not support wrapping of data. A BUG_ON()
ensures data never wraps during SSL read operations. This can never fire
as a similar comparison exists first in CRYPTO parsing to reject
wrapping content.

However, this code uses an incorrect greater-than-or-equal operator on
buffer wrapping. This incorrectly rejects CRYPTO content that exactly
fits in the receive buffer and closes connection. Fixes the comparison
operators so that CRYPTO data ending exactly at the buffer end can now
be normally handled.

This should be backported up to 2.6 after a period of observation.

src/quic_rx.c
src/quic_ssl.c

index 2cc920d8e1b67d19ce07d80dee972ac827bf214b..6eaaf646ce7cabb4f23ee6c71ba928543b4b9e4e 100644 (file)
@@ -766,7 +766,7 @@ static int qc_handle_crypto_frm(struct quic_conn *qc,
                 * ha_quic_ossl_crypto_recv_rcd()/qc_ssl_provide_all_quic_data().
                 * TODO implement proper support for CRYPTO wrapping.
                 */
-               if (ncbmb_head(ncbuf) + data >= ncbmb_wrap(ncbuf)) {
+               if (ncbmb_head(ncbuf) + data > ncbmb_wrap(ncbuf)) {
                        TRACE_ERROR("unsupported wrapping CRYPTO frames", QUIC_EV_CONN_PRSHPKT, qc);
                        COUNT("connection closed on unsupported wrapping CRYPTO content");
                        quic_set_connection_close(qc, quic_err_transport(QC_ERR_CRYPTO_BUFFER_EXCEEDED));
index 425a4333a9a8fb642fb3f352168c50ef5b2a0169..5f1fc9687acfc652653d24176d5798e6bce2819a 100644 (file)
@@ -507,7 +507,7 @@ static int ha_quic_ossl_crypto_recv_rcd(SSL *ssl,
                /* <ncbuf> must not be released at this time. */
                cdata = (const unsigned char *)ncbmb_head(ncbuf);
                /* Currently wrapping CRYPTO content is not supported and rejected on frame reception. */
-               BUG_ON(cdata + data >= (const unsigned char *)ncbmb_wrap(ncbuf));
+               BUG_ON(cdata + data > (const unsigned char *)ncbmb_wrap(ncbuf));
 
                cstream->rx.offset += data;
                TRACE_DEVEL("buffered crypto data were provided to TLS stack",
@@ -1202,7 +1202,7 @@ int qc_ssl_provide_all_quic_data(struct quic_conn *qc, struct ssl_sock_ctx *ctx)
                while ((data = ncbmb_data(ncbuf, 0))) {
                        const unsigned char *cdata = (const unsigned char *)ncbmb_head(ncbuf);
                        /* Currently wrapping CRYPTO content is not supported and rejected on frame reception. */
-                       BUG_ON(cdata + data >= (const unsigned char *)ncbmb_wrap(ncbuf));
+                       BUG_ON(cdata + data > (const unsigned char *)ncbmb_wrap(ncbuf));
 
                        if (!qc_ssl_provide_quic_data(&qel->cstream->rx.ncbuf, qel->level,
                                                      ctx, cdata, data))