diff options
| author | Jakub Kicinski <[email protected]> | 2023-05-25 05:17:41 +0000 |
|---|---|---|
| committer | David S. Miller <[email protected]> | 2023-05-26 09:35:58 +0000 |
| commit | 8a0d57df8938e9fd2e99d47a85b7f37d86f91097 (patch) | |
| tree | f3580e647acbd306ee043c6cc59a2c1d7315a423 /net/tls/tls_strp.c | |
| parent | Merge tag 'mlx5-fixes-2023-05-24' of git://git.kernel.org/pub/scm/linux/kerne... (diff) | |
| download | kernel-8a0d57df8938e9fd2e99d47a85b7f37d86f91097.tar.gz kernel-8a0d57df8938e9fd2e99d47a85b7f37d86f91097.zip | |
tls: improve lockless access safety of tls_err_abort()
Most protos' poll() methods insert a memory barrier between
writes to sk_err and sk_error_report(). This dates back to
commit a4d258036ed9 ("tcp: Fix race in tcp_poll").
I guess we should do the same thing in TLS, tcp_poll() does
not hold the socket lock.
Fixes: 3c4d7559159b ("tls: kernel TLS support")
Signed-off-by: Jakub Kicinski <[email protected]>
Reviewed-by: Simon Horman <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Diffstat (limited to 'net/tls/tls_strp.c')
| -rw-r--r-- | net/tls/tls_strp.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/net/tls/tls_strp.c b/net/tls/tls_strp.c index da95abbb7ea3..f37f4a0fcd3c 100644 --- a/net/tls/tls_strp.c +++ b/net/tls/tls_strp.c @@ -20,7 +20,9 @@ static void tls_strp_abort_strp(struct tls_strparser *strp, int err) strp->stopped = 1; /* Report an error on the lower socket */ - strp->sk->sk_err = -err; + WRITE_ONCE(strp->sk->sk_err, -err); + /* Paired with smp_rmb() in tcp_poll() */ + smp_wmb(); sk_error_report(strp->sk); } |
