From nobody Sat May 14 00:10:02 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 54D621AE325D; Sat, 14 May 2022 00:10:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4L0QrC18Lvz4SdX; Sat, 14 May 2022 00:10:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652487003; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Lny6MyEUIVpBvJ0RC01HxhCPRa1UI/PfP3dUDS5o0tY=; b=WsQJprlcj9WwXPTEWw5IaTtwN/blKg0LmaUu43ifgUNZ6mW+o4vanTxr7TOSiaS88xm1YT WEzeZwddPWGH9Ovg/1J0czpwYgMNjP7KanXJ/em41Z5FSkeZjfTy7jTMW5sivsuJmZkHtC c7QyII+2Ipi+tJVnTMwucj4CYzXk2MPpxaH1WJxJdctBoyksABb9+SE1VpYJaRPUNZu2II mKW7J+Z4DyHsV1gBihnwJS8qa30zKOtpRtgVE1/LvpcJV5ptN3mTf1258zfDvNys5qyVqk oun+nARh/D7nQ0M5xPWu0584vZ86bg4Qw9qQf6QtqiOSWciswn/1+sA1wvQOyQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D615A48B5; Sat, 14 May 2022 00:10:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 24E0A2Uu075703; Sat, 14 May 2022 00:10:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24E0A2CZ075700; Sat, 14 May 2022 00:10:02 GMT (envelope-from git) Date: Sat, 14 May 2022 00:10:02 GMT Message-Id: <202205140010.24E0A2CZ075700@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 2e6f247ca49b - stable/13 - OpenSSL: KTLS: Enable KTLS for receiving as well in TLS 1.3 List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2e6f247ca49bf21deb3f6300d6da29544785a20e Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652487003; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Lny6MyEUIVpBvJ0RC01HxhCPRa1UI/PfP3dUDS5o0tY=; b=SSm/LMEzqR6wvu3lEiazvv+eA6x3vrIelXOdMwRLgHdgZFtoX4ws8LTiBI05N9mnBInZmN dkybqOV5C1gq/yAJfD4Uv9iVT3QqfhYfPWlkbj862xnFJYYE19EUtD9HXbzXx+lWUVAoxl OSYGneUdqFCZW7vj08tiQMWY+rPyoB7nM7lDDn5AkmzpdGIRMih0WdL07p8HPFGsOuT77P KNo5RX71PBegkfpoSDnJNcxH1pkNDw3Npj31S1sqSJFAbb4WxQrKM1qCKsp5yUF+0xIglv IYTZItJAxDTWCalA0xUSpWq0PmAnplFzTnsr7ykwulGRUMKP1DZMt0Ib0EpPCg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1652487003; a=rsa-sha256; cv=none; b=ESNBOKU1ShslzRCAQ3YIHttWg87bNgnIKY0f1kf8KQmp9UYWU8X5b+O8N/jUX7sajLz/t9 BCqPJ2deNono1thNVxQSGEbJ2Y/GhJTesfH33dUHGZE3ZwkZ0XWTsrEONKr9bP5tbUHolu JtyIkf+Ng1BGbBNbf/urdc9B6lHibIvSMcOT96uK/BHeXNT26l2Z+YTLr0z3djLsUxsnsy pzt1PuwmXWPCv2OKQGqGh1rDzKZCJBbinUrtZPSIe8R96v2FQuq4BIIhjV2e7UOBVW1O8m XjmrJvl25vXYOnf15IwHWuFhlhKl2fXTcsq4JnwLzUXZEMxa0UokzYW03pLqjA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=2e6f247ca49bf21deb3f6300d6da29544785a20e commit 2e6f247ca49bf21deb3f6300d6da29544785a20e Author: John Baldwin AuthorDate: 2022-05-04 20:08:36 +0000 Commit: John Baldwin CommitDate: 2022-05-13 23:51:34 +0000 OpenSSL: KTLS: Enable KTLS for receiving as well in TLS 1.3 This removes a guard condition that prevents KTLS being enabled for receiving in TLS 1.3. Use the correct sequence number and BIO for receive vs transmit offload. Approved by: jkim Obtained from: OpenSSL commit 7c78932b9a4330fb7c8db72b3fb37cbff1401f8b MFC after: 1 week Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D34976 (cherry picked from commit 913616b88505b2a5ff40f3d0a4b504d39ee563bb) --- crypto/openssl/ssl/tls13_enc.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/crypto/openssl/ssl/tls13_enc.c b/crypto/openssl/ssl/tls13_enc.c index cc1435ec55c2..109227e55666 100644 --- a/crypto/openssl/ssl/tls13_enc.c +++ b/crypto/openssl/ssl/tls13_enc.c @@ -471,6 +471,7 @@ int tls13_change_cipher_state(SSL *s, int which) const EVP_CIPHER *cipher = NULL; #if !defined(OPENSSL_NO_KTLS) && defined(OPENSSL_KTLS_TLS13) ktls_crypto_info_t crypto_info; + void *rl_sequence; BIO *bio; #endif @@ -724,8 +725,7 @@ int tls13_change_cipher_state(SSL *s, int which) s->statem.enc_write_state = ENC_WRITE_STATE_VALID; #ifndef OPENSSL_NO_KTLS # if defined(OPENSSL_KTLS_TLS13) - if (!(which & SSL3_CC_WRITE) - || !(which & SSL3_CC_APPLICATION) + if (!(which & SSL3_CC_APPLICATION) || (s->options & SSL_OP_ENABLE_KTLS) == 0) goto skip_ktls; @@ -741,7 +741,10 @@ int tls13_change_cipher_state(SSL *s, int which) if (!ktls_check_supported_cipher(s, cipher, ciph_ctx)) goto skip_ktls; - bio = s->wbio; + if (which & SSL3_CC_WRITE) + bio = s->wbio; + else + bio = s->rbio; if (!ossl_assert(bio != NULL)) { SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS13_CHANGE_CIPHER_STATE, @@ -750,19 +753,26 @@ int tls13_change_cipher_state(SSL *s, int which) } /* All future data will get encrypted by ktls. Flush the BIO or skip ktls */ - if (BIO_flush(bio) <= 0) - goto skip_ktls; + if (which & SSL3_CC_WRITE) { + if (BIO_flush(bio) <= 0) + goto skip_ktls; + } /* configure kernel crypto structure */ - if (!ktls_configure_crypto(s, cipher, ciph_ctx, - RECORD_LAYER_get_write_sequence(&s->rlayer), - &crypto_info, which & SSL3_CC_WRITE, iv, key, - NULL, 0)) + if (which & SSL3_CC_WRITE) + rl_sequence = RECORD_LAYER_get_write_sequence(&s->rlayer); + else + rl_sequence = RECORD_LAYER_get_read_sequence(&s->rlayer); + + if (!ktls_configure_crypto(s, cipher, ciph_ctx, rl_sequence, &crypto_info, + which & SSL3_CC_WRITE, iv, key, NULL, 0)) goto skip_ktls; /* ktls works with user provided buffers directly */ - if (BIO_set_ktls(bio, &crypto_info, which & SSL3_CC_WRITE)) - ssl3_release_write_buffer(s); + if (BIO_set_ktls(bio, &crypto_info, which & SSL3_CC_WRITE)) { + if (which & SSL3_CC_WRITE) + ssl3_release_write_buffer(s); + } skip_ktls: # endif #endif