From: Jakub Kicinski <kuba@kernel.org>
To: Sabrina Dubroca <sd@queasysnail.net>
Cc: netdev@vger.kernel.org, Vadim Fedorenko <vfedorenko@novek.ru>,
Frantisek Krenzelok <fkrenzel@redhat.com>,
Kuniyuki Iwashima <kuniyu@amazon.com>,
Apoorv Kothari <apoorvko@amazon.com>,
Boris Pismenny <borisp@nvidia.com>,
John Fastabend <john.fastabend@gmail.com>,
Shuah Khan <shuah@kernel.org>,
linux-kselftest@vger.kernel.org, Gal Pressman <gal@nvidia.com>,
Marcel Holtmann <marcel@holtmann.org>
Subject: Re: [PATCH net-next v2 0/5] tls: implement key updates for TLS1.3
Date: Wed, 22 Mar 2023 12:43:16 -0700 [thread overview]
Message-ID: <20230322124316.7a174e3d@kernel.org> (raw)
In-Reply-To: <ZBsocdkUBlEuAU+I@hog>
On Wed, 22 Mar 2023 17:10:25 +0100 Sabrina Dubroca wrote:
> > Theoretically a rekey op is nicer and cleaner. Practically the quality
> > of the driver implementations will vary wildly*, and it's a significant
> > time investment to review all of them. So for non-technical reasons my
> > intuition is that we'd deliver a better overall user experience if we
> > handled the rekey entirely in the core.
> >
> > Wait for old key to no longer be needed, _del + _add, start using the
> > offload again.
> >
> > * One vendor submitted a driver claiming support for TLS 1.3, when
> > TLS 1.3 offload was rejected by the core. So this is the level of
> > testing and diligence we're working with :(
>
> :(
>
> Ok, _del + _add then.
>
>
> I went over the thread to summarize what we've come up with so far:
>
> RX
> - The existing SW path will handle all records between the KeyUpdate
> message signaling the change of key and the new key becoming known
> to the kernel -- those will be queued encrypted, and decrypted in
> SW as they are read by userspace (once the key is provided, ie same
> as this patchset)
> - Call ->tls_dev_del + ->tls_dev_add immediately during
> setsockopt(TLS_RX)
>
> TX
> - After setsockopt(TLS_TX), switch to the existing SW path (not the
> current device_fallback) until we're able to re-enable HW offload
> - tls_device_{sendmsg,sendpage} will call into
> tls_sw_{sendmsg,sendpage} under lock_sock to avoid changing
> socket ops during the rekey while another thread might be waiting
> on the lock
> - We only re-enable HW offload (call ->tls_dev_add to install the new
> key in HW) once all records sent with the old key have been
> ACKed. At this point, all unacked records are SW-encrypted with the
> new key, and the old key is unused by both HW and retransmissions.
> - If there are no unacked records when userspace does
> setsockopt(TLS_TX), we can (try to) install the new key in HW
> immediately.
> - If yet another key has been provided via setsockopt(TLS_TX), we
> don't install intermediate keys, only the latest.
> - TCP notifies ktls of ACKs via the icsk_clean_acked callback. In
> case of a rekey, tls_icsk_clean_acked will record when all data
> sent with the most recent past key has been sent. The next call
> to sendmsg/sendpage will install the new key in HW.
> - We close and push the current SW record before reenabling
> offload.
>
> If ->tls_dev_add fails to install the new key in HW, we stay in SW
> mode. We can add a counter to keep track of this.
SG!
> In addition:
>
> Because we can't change socket ops during a rekey, we'll also have to
> modify do_tls_setsockopt_conf to check ctx->tx_conf and only call
> either tls_set_device_offload or tls_set_sw_offload. RX already uses
> the same ops for both TLS_HW and TLS_SW, so we could switch between HW
> and SW mode on rekey.
>
> An alternative would be to have a common sendmsg/sendpage which locks
> the socket and then calls the correct implementation. We'll need that
> anyway for the offload under rekey case, so that would only add a test
> to the SW path's ops (compared to the current code). That should allow
> us to make build_protos a lot simpler.
No preference assuming perf is the same.
prev parent reply other threads:[~2023-03-22 19:43 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-14 11:17 [PATCH net-next v2 0/5] tls: implement key updates for TLS1.3 Sabrina Dubroca
2023-02-14 11:17 ` [PATCH net-next v2 1/5] tls: remove tls_context argument from tls_set_sw_offload Sabrina Dubroca
2023-02-14 11:17 ` [PATCH net-next v2 2/5] tls: block decryption when a rekey is pending Sabrina Dubroca
2023-02-15 5:09 ` Jakub Kicinski
2023-02-15 17:37 ` Sabrina Dubroca
2023-02-14 11:17 ` [PATCH net-next v2 3/5] tls: implement rekey for TLS1.3 Sabrina Dubroca
2023-02-14 11:17 ` [PATCH net-next v2 4/5] selftests: tls: add key_generation argument to tls_crypto_info_init Sabrina Dubroca
2023-02-14 11:17 ` [PATCH net-next v2 5/5] selftests: tls: add rekey tests Sabrina Dubroca
2023-02-15 5:08 ` [PATCH net-next v2 0/5] tls: implement key updates for TLS1.3 Jakub Kicinski
2023-02-15 17:29 ` Sabrina Dubroca
2023-02-15 19:10 ` Jakub Kicinski
2023-02-15 23:23 ` Sabrina Dubroca
2023-02-16 3:57 ` Jakub Kicinski
2023-02-16 16:23 ` Sabrina Dubroca
2023-02-22 3:19 ` Jakub Kicinski
2023-02-23 16:27 ` Sabrina Dubroca
2023-02-23 17:29 ` Jakub Kicinski
2023-03-13 15:41 ` Sabrina Dubroca
2023-03-13 18:35 ` Jakub Kicinski
2023-03-22 16:10 ` Sabrina Dubroca
2023-03-22 19:43 ` Jakub Kicinski [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230322124316.7a174e3d@kernel.org \
--to=kuba@kernel.org \
--cc=apoorvko@amazon.com \
--cc=borisp@nvidia.com \
--cc=fkrenzel@redhat.com \
--cc=gal@nvidia.com \
--cc=john.fastabend@gmail.com \
--cc=kuniyu@amazon.com \
--cc=linux-kselftest@vger.kernel.org \
--cc=marcel@holtmann.org \
--cc=netdev@vger.kernel.org \
--cc=sd@queasysnail.net \
--cc=shuah@kernel.org \
--cc=vfedorenko@novek.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).