KTLS: Check for unprocessed receive records in ktls_configure_crypto.
authorJohn Baldwin <jhb@FreeBSD.org>
Thu, 24 Feb 2022 18:12:07 +0000 (10:12 -0800)
committerTomas Mraz <tomas@openssl.org>
Wed, 6 Apr 2022 11:15:27 +0000 (13:15 +0200)
commit85773128d0e80cd8dcc772a6931d385b8cf4acd1
treeea03d88474e6837280b084a245f2637d3cb2e613
parentdedb1927751bc9a7ada08cfc4dcc481b8ce1ad81
KTLS: Check for unprocessed receive records in ktls_configure_crypto.

KTLS implementations currently assume that the start of the in-kernel
socket buffer is aligned with the start of a TLS record for the
receive side.  The socket option to enable KTLS specifies the TLS
sequence number of this initial record.

When read ahead is enabled, data can be pending in the SSL read buffer
after negotiating session keys.  This pending data must be examined to
ensurs that the kernel's socket buffer does not contain a partial TLS
record as well as to determine the correct sequence number of the
first TLS record to be processed by the kernel.

In preparation for enabling receive kernel offload for TLS 1.3, move
the existing logic to handle read ahead from t1_enc.c into ktls.c and
invoke it from ktls_configure_crypto().

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17942)
ssl/ktls.c
ssl/ssl_local.h
ssl/t1_enc.c
ssl/tls13_enc.c