SUNRPC: Fix a potential race in xprt_connect()
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Sun, 2 Dec 2018 04:18:00 +0000 (23:18 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Dec 2018 13:15:17 +0000 (14:15 +0100)
commit20595815b058dc7d7ae9d16169e20407f71be2d6
tree0b6289c29dec3e5a9e7dba0f9b0c09fa0f084b44
parentde956d40781191903c7eb8e6843b0cb506ab1f43
SUNRPC: Fix a potential race in xprt_connect()

[ Upstream commit 0a9a4304f3614e25d9de9b63502ca633c01c0d70 ]

If an asynchronous connection attempt completes while another task is
in xprt_connect(), then the call to rpc_sleep_on() could end up
racing with the call to xprt_wake_pending_tasks().
So add a second test of the connection state after we've put the
task to sleep and set the XPRT_CONNECTING flag, when we know that there
can be no asynchronous connection attempts still in progress.

Fixes: 0b9e79431377d ("SUNRPC: Move the test for XPRT_CONNECTING into...")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/sunrpc/xprt.c