]> git.itanic.dy.fi Git - linux-stable/commit
SUNRPC: Don't call connect() more than once on a TCP socket
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Wed, 16 Mar 2022 23:10:43 +0000 (19:10 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 May 2022 08:23:48 +0000 (10:23 +0200)
commitdbe6974a39ac3cee16ab59de8bdff1f0991994dd
treec5de6a764449cafb61098c11b94e5503bd47620a
parent47541ed4d47b0c456ab4915380ba57623d844107
SUNRPC: Don't call connect() more than once on a TCP socket

commit 89f42494f92f448747bd8a7ab1ae8b5d5520577d upstream.

Avoid socket state races due to repeated calls to ->connect() using the
same socket. If connect() returns 0 due to the connection having
completed, but we are in fact in a closing state, then we may leave the
XPRT_CONNECTING flag set on the transport.

Reported-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Fixes: 3be232f11a3c ("SUNRPC: Prevent immediate close+reconnect")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
[meenashanmugam: Backported to 5.10: Fixed merge conflict in xs_tcp_setup_socket]
Signed-off-by: Meena Shanmugam <meenashanmugam@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/sunrpc/xprtsock.h
net/sunrpc/xprtsock.c