diff mbox series

[RFC,2/5] tls: build proto after context has been initialized

Message ID 165030057652.5073.10364318727607743572.stgit@oracle-102.nfsv4.dev (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series Implement a TLS handshake upcall | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 5 maintainers not CCed: davem@davemloft.net pabeni@redhat.com daniel@iogearbox.net john.fastabend@gmail.com kuba@kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 15 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply, async

Commit Message

Chuck Lever III April 18, 2022, 4:49 p.m. UTC
From: Hannes Reinecke <hare@suse.de>

We have to build the proto ops only after the context has been
initialized, as otherwise we might crash when I/O is ongoing
during initialisation.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 net/tls/tls_main.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Jakub Kicinski April 25, 2022, 5:11 p.m. UTC | #1
On Mon, 18 Apr 2022 12:49:36 -0400 Chuck Lever wrote:
> From: Hannes Reinecke <hare@suse.de>
> 
> We have to build the proto ops only after the context has been
> initialized, as otherwise we might crash when I/O is ongoing
> during initialisation.

Can you say more about the crash you see? protos are not used until 
at least one socket calls update_sk_prot().
Chuck Lever III April 25, 2022, 5:51 p.m. UTC | #2
> On Apr 25, 2022, at 1:11 PM, Jakub Kicinski <kuba@kernel.org> wrote:
> 
> On Mon, 18 Apr 2022 12:49:36 -0400 Chuck Lever wrote:
>> From: Hannes Reinecke <hare@suse.de>
>> 
>> We have to build the proto ops only after the context has been
>> initialized, as otherwise we might crash when I/O is ongoing
>> during initialisation.
> 
> Can you say more about the crash you see? protos are not used until 
> at least one socket calls update_sk_prot().

Hannes reported the crash and supplied the fix. I didn't have a
problem with this patch series without this patch. Hannes?



--
Chuck Lever
Chuck Lever III May 20, 2022, 4:39 p.m. UTC | #3
> On Apr 18, 2022, at 12:49 PM, Chuck Lever <chuck.lever@oracle.com> wrote:
> 
> From: Hannes Reinecke <hare@suse.de>
> 
> We have to build the proto ops only after the context has been
> initialized, as otherwise we might crash when I/O is ongoing
> during initialisation.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> ---
> net/tls/tls_main.c |    3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c
> index 7b2b0e7ffee4..7eca4d9a83c4 100644
> --- a/net/tls/tls_main.c
> +++ b/net/tls/tls_main.c
> @@ -836,8 +836,6 @@ static int tls_init(struct sock *sk)
> 	struct tls_context *ctx;
> 	int rc = 0;
> 
> -	tls_build_proto(sk);
> -
> #ifdef CONFIG_TLS_TOE
> 	if (tls_toe_bypass(sk))
> 		return 0;
> @@ -862,6 +860,7 @@ static int tls_init(struct sock *sk)
> 
> 	ctx->tx_conf = TLS_BASE;
> 	ctx->rx_conf = TLS_BASE;
> +	tls_build_proto(sk);
> 	update_sk_prot(sk, ctx);
> out:
> 	write_unlock_bh(&sk->sk_callback_lock);
> 
> 

While we're working on a better upcall mechanism, I'm dropping
this one from the series. tls_build_proto() can grab a mutex,
so tls_init() can't call it while holding sk_callback_lock.


--
Chuck Lever
diff mbox series

Patch

diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c
index 7b2b0e7ffee4..7eca4d9a83c4 100644
--- a/net/tls/tls_main.c
+++ b/net/tls/tls_main.c
@@ -836,8 +836,6 @@  static int tls_init(struct sock *sk)
 	struct tls_context *ctx;
 	int rc = 0;
 
-	tls_build_proto(sk);
-
 #ifdef CONFIG_TLS_TOE
 	if (tls_toe_bypass(sk))
 		return 0;
@@ -862,6 +860,7 @@  static int tls_init(struct sock *sk)
 
 	ctx->tx_conf = TLS_BASE;
 	ctx->rx_conf = TLS_BASE;
+	tls_build_proto(sk);
 	update_sk_prot(sk, ctx);
 out:
 	write_unlock_bh(&sk->sk_callback_lock);