From 8d373da6e9b3b819d4a74311ac233b8311e919f5 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Mon, 17 May 2021 10:18:50 +0800 Subject: [PATCH] SUNRPC: Don't let RPC_SOFTCONN tasks time out if the transport is connected mainline inclusion from mainline-5.1-rc3 commit d84dd3fb82fa7a094de7f08f10610d55a70cf0ca category: bugfix bugzilla: 51818 CVE: NA ------------------------------------------------- If the transport is still connected, then we do want to allow RPC_SOFTCONN tasks to retry. They should time out if and only if the connection is broken. Signed-off-by: Trond Myklebust Conflicts: net/sunrpc/clnt.c Signed-off-by: Zhang Changzhong Reviewed-by: Hou Tao Signed-off-by: Yang Yingliang --- net/sunrpc/clnt.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index abdae040d229..b560ae4aef44 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -2196,6 +2196,15 @@ call_status(struct rpc_task *task) } } +static bool +rpc_check_connected(const struct rpc_rqst *req) +{ + /* No allocated request or transport? return true */ + if (!req || !req->rq_xprt) + return true; + return xprt_connected(req->rq_xprt); +} + /* * 6a. Handle RPC timeout * We do not release the request slot, so we keep using the @@ -2214,10 +2223,11 @@ call_timeout(struct rpc_task *task) dprintk("RPC: %5u call_timeout (major)\n", task->tk_pid); task->tk_timeouts++; - if (RPC_IS_SOFTCONN(task)) { + if (RPC_IS_SOFTCONN(task) && !rpc_check_connected(task->tk_rqstp)) { rpc_exit(task, -ETIMEDOUT); return; } + if (RPC_IS_SOFT(task)) { if (clnt->cl_chatty) { printk(KERN_NOTICE "%s: server %s not responding, timed out\n", -- GitLab