Skip to content

Commit

Permalink
[PATCH] SUNRPC: fix race in in-kernel RPC portmapper client
Browse files Browse the repository at this point in the history
When submitting a request to a fast portmapper (such as the local rpcbind
daemon), the request can complete before the parent task is even queued up on
xprt->binding.  Fix this by queuing before submitting the rpcbind request.

Test plan:
Connectathon locking test with UDP.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Chuck Lever authored and Linus Torvalds committed Oct 20, 2006
1 parent b87c0ad commit 71bdcf8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions net/sunrpc/pmap_clnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,13 @@ void rpc_getport(struct rpc_task *task)
/* Autobind on cloned rpc clients is discouraged */
BUG_ON(clnt->cl_parent != clnt);

if (xprt_test_and_set_binding(xprt)) {
task->tk_status = -EACCES; /* tell caller to check again */
rpc_sleep_on(&xprt->binding, task, NULL, NULL);
return;
}
/* Put self on queue before sending rpcbind request, in case
* pmap_getport_done completes before we return from rpc_run_task */
rpc_sleep_on(&xprt->binding, task, NULL, NULL);

status = -EACCES; /* tell caller to check again */
if (xprt_test_and_set_binding(xprt))
goto bailout_nofree;

/* Someone else may have bound if we slept */
status = 0;
Expand Down Expand Up @@ -134,8 +136,6 @@ void rpc_getport(struct rpc_task *task)
goto bailout;
rpc_release_task(child);

rpc_sleep_on(&xprt->binding, task, NULL, NULL);

task->tk_xprt->stat.bind_count++;
return;

Expand Down

0 comments on commit 71bdcf8

Please sign in to comment.