From: Olivier Houchard Date: Tue, 24 Nov 2026 17:33:04 +0000 (+0100) Subject: BUG/MEDIUM: ssl: trim dropped kTLS records from the end of the buffer X-Git-Tag: v3.5-dev14~26 X-Git-Url: https://git.kaiwu.me/http/ngx_http_ssi_module.html?a=commitdiff_plain;h=035691b1abdb2adcdc7da3e13d5a4b3f034948ca;p=haproxy.git BUG/MEDIUM: ssl: trim dropped kTLS records from the end of the buffer With AWS-LC and kTLS, ssl_sock_to_buf() reads the records itself, and drops the NewSessionTicket and close_notify ones it has just received using b_del(). But this removes data from the head of the buffer, while the record was appended at its tail. When the buffer already contains data, their beginning is lost and the record stays in the buffer, resulting in a corrupted stream, typically an invalid HTTP response when a server sends a close_notify right after its response. This rarely shows up for now, because a kTLS read is almost always the last one of a call. Let's use b_sub() to remove the record from the tail. This was introduced in 3.3-dev7 by commit 5da354098 ("MEDIUM: ssl: Handle non-Application data record with AWS-LC"). It must be backported to 3.3. --- diff --git a/src/ssl_sock.c b/src/ssl_sock.c index 048d61c88..34b646f9f 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -7714,7 +7714,7 @@ static size_t ssl_sock_to_buf(struct connection *conn, void *xprt_ctx, struct bu /* * Just ignore new session tickets */ - b_del(buf, ret); + b_sub(buf, ret); continue; } else if (record_type != SSL3_RT_APPLICATION_DATA) { @@ -7724,7 +7724,7 @@ static size_t ssl_sock_to_buf(struct connection *conn, void *xprt_ctx, struct bu */ if (record_type == SSL3_RT_ALERT && ret == 2 && tmpbuf[0] == SSL_TLSEXT_ERR_ALERT_WARNING && tmpbuf[1] == SSL_AD_CLOSE_NOTIFY) { - b_del(buf, ret); + b_sub(buf, ret); goto read0; } else { conn->err_code = CO_ER_SSL_FATAL;