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.
/*
* Just ignore new session tickets
*/
- b_del(buf, ret);
+ b_sub(buf, ret);
continue;
} else if (record_type != SSL3_RT_APPLICATION_DATA) {
*/
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;