diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-10-23 17:50:07 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-10-24 10:46:08 -0400 |
commit | 4bc1e68ed6a8b59be8a79eb719be515a55c7bc68 (patch) | |
tree | 93a4b34c2759a52a1f57850c9f3719296beeee24 /net/sunrpc | |
parent | b9d2bb2ee537424a7f855e1f93eed44eb9ee0854 (diff) |
SUNRPC: Prevent races in xs_abort_connection()
The call to xprt_disconnect_done() that is triggered by a successful
connection reset will trigger another automatic wakeup of all tasks
on the xprt->pending rpc_wait_queue. In particular it will cause an
early wake up of the task that called xprt_connect().
All we really want to do here is clear all the socket-specific state
flags, so we split that functionality out of xs_sock_mark_closed()
into a helper that can be called by xs_abort_connection()
Reported-by: Chris Perl <chris.perl@gmail.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: stable@vger.kernel.org
Tested-by: Chris Perl <chris.perl@gmail.com>
Diffstat (limited to 'net/sunrpc')
-rw-r--r-- | net/sunrpc/xprtsock.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 7e2dd0d69f1b..1f105c2d2e15 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c | |||
@@ -1453,7 +1453,7 @@ static void xs_tcp_cancel_linger_timeout(struct rpc_xprt *xprt) | |||
1453 | xprt_clear_connecting(xprt); | 1453 | xprt_clear_connecting(xprt); |
1454 | } | 1454 | } |
1455 | 1455 | ||
1456 | static void xs_sock_mark_closed(struct rpc_xprt *xprt) | 1456 | static void xs_sock_reset_connection_flags(struct rpc_xprt *xprt) |
1457 | { | 1457 | { |
1458 | smp_mb__before_clear_bit(); | 1458 | smp_mb__before_clear_bit(); |
1459 | clear_bit(XPRT_CONNECTION_ABORT, &xprt->state); | 1459 | clear_bit(XPRT_CONNECTION_ABORT, &xprt->state); |
@@ -1461,6 +1461,11 @@ static void xs_sock_mark_closed(struct rpc_xprt *xprt) | |||
1461 | clear_bit(XPRT_CLOSE_WAIT, &xprt->state); | 1461 | clear_bit(XPRT_CLOSE_WAIT, &xprt->state); |
1462 | clear_bit(XPRT_CLOSING, &xprt->state); | 1462 | clear_bit(XPRT_CLOSING, &xprt->state); |
1463 | smp_mb__after_clear_bit(); | 1463 | smp_mb__after_clear_bit(); |
1464 | } | ||
1465 | |||
1466 | static void xs_sock_mark_closed(struct rpc_xprt *xprt) | ||
1467 | { | ||
1468 | xs_sock_reset_connection_flags(xprt); | ||
1464 | /* Mark transport as closed and wake up all pending tasks */ | 1469 | /* Mark transport as closed and wake up all pending tasks */ |
1465 | xprt_disconnect_done(xprt); | 1470 | xprt_disconnect_done(xprt); |
1466 | } | 1471 | } |
@@ -2051,10 +2056,8 @@ static void xs_abort_connection(struct sock_xprt *transport) | |||
2051 | any.sa_family = AF_UNSPEC; | 2056 | any.sa_family = AF_UNSPEC; |
2052 | result = kernel_connect(transport->sock, &any, sizeof(any), 0); | 2057 | result = kernel_connect(transport->sock, &any, sizeof(any), 0); |
2053 | if (!result) | 2058 | if (!result) |
2054 | xs_sock_mark_closed(&transport->xprt); | 2059 | xs_sock_reset_connection_flags(&transport->xprt); |
2055 | else | 2060 | dprintk("RPC: AF_UNSPEC connect return code %d\n", result); |
2056 | dprintk("RPC: AF_UNSPEC connect return code %d\n", | ||
2057 | result); | ||
2058 | } | 2061 | } |
2059 | 2062 | ||
2060 | static void xs_tcp_reuse_connection(struct sock_xprt *transport) | 2063 | static void xs_tcp_reuse_connection(struct sock_xprt *transport) |