]> git.itanic.dy.fi Git - linux-stable/commit
tls: fix race between async notify and socket close
authorJakub Kicinski <kuba@kernel.org>
Wed, 7 Feb 2024 01:18:19 +0000 (17:18 -0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 10 Feb 2024 21:38:19 +0000 (21:38 +0000)
commitaec7961916f3f9e88766e2688992da6980f11b8d
tree242e2246f9fb2c26a93dcde3bd597bd5f8100fad
parentc57ca512f3b68ddcd62bda9cc24a8f5584ab01b1
tls: fix race between async notify and socket close

The submitting thread (one which called recvmsg/sendmsg)
may exit as soon as the async crypto handler calls complete()
so any code past that point risks touching already freed data.

Try to avoid the locking and extra flags altogether.
Have the main thread hold an extra reference, this way
we can depend solely on the atomic ref counter for
synchronization.

Don't futz with reiniting the completion, either, we are now
tightly controlling when completion fires.

Reported-by: valis <sec@valis.email>
Fixes: 0cada33241d9 ("net/tls: fix race condition causing kernel panic")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/tls.h
net/tls/tls_sw.c