提交 71bdcf80 编写于 作者: C Chuck Lever 提交者: Linus Torvalds

[PATCH] SUNRPC: fix race in in-kernel RPC portmapper client

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: NChuck Lever <chuck.lever@oracle.com>
Signed-off-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 b87c0adf
......@@ -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;
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册