Home Home > GIT Browse > SLE11-SP4
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.com>2019-01-07 11:53:49 +1100
committerNeilBrown <neilb@suse.com>2019-01-07 14:04:50 +1100
commitc8f4732de4a13dab304aec867bf6316f989bca7f (patch)
tree2c25c49bc4d498a154348baf0e7f4a2ac84eb3e6
parentb44650b2354ea7252ad45b2c4a5ef43fd8d8a67d (diff)
SUNRPC: Fix a potential race in xprt_connect() (git-fixes).
-rw-r--r--patches.fixes/SUNRPC-Fix-a-potential-race-in-xprt_connect.patch42
-rw-r--r--series.conf1
2 files changed, 43 insertions, 0 deletions
diff --git a/patches.fixes/SUNRPC-Fix-a-potential-race-in-xprt_connect.patch b/patches.fixes/SUNRPC-Fix-a-potential-race-in-xprt_connect.patch
new file mode 100644
index 0000000000..fd7fd84de0
--- /dev/null
+++ b/patches.fixes/SUNRPC-Fix-a-potential-race-in-xprt_connect.patch
@@ -0,0 +1,42 @@
+From: Trond Myklebust <trond.myklebust@hammerspace.com>
+Date: Sat, 1 Dec 2018 23:18:00 -0500
+Subject: [PATCH] SUNRPC: Fix a potential race in xprt_connect()
+Git-commit: 0a9a4304f3614e25d9de9b63502ca633c01c0d70
+Patch-mainline: v4.20
+References: git-fixes
+
+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>
+Acked-by: NeilBrown <neilb@suse.com>
+
+---
+ net/sunrpc/xprt.c | 11 +++++++++--
+ 1 file changed, 9 insertions(+), 2 deletions(-)
+
+--- a/net/sunrpc/xprt.c
++++ b/net/sunrpc/xprt.c
+@@ -742,8 +742,15 @@ void xprt_connect(struct rpc_task *task)
+ return;
+ if (xprt_test_and_set_connecting(xprt))
+ return;
+- xprt->stat.connect_start = jiffies;
+- xprt->ops->connect(task);
++ /* Race breaker */
++ if (!xprt_connected(xprt)) {
++ xprt->stat.connect_start = jiffies;
++ xprt->ops->connect(task);
++ } else {
++ xprt_clear_connecting(xprt);
++ task->tk_status = 0;
++ rpc_wake_up_queued_task(&xprt->pending, task);
++ }
+ }
+ }
+
diff --git a/series.conf b/series.conf
index 6199475857..92bb4fd5a0 100644
--- a/series.conf
+++ b/series.conf
@@ -6911,6 +6911,7 @@
patches.fixes/svc-Avoid-garbage-replies-when-pc_func-returns-rpc_d.patch
patches.fixes/svcrpc-don-t-leak-contexts-on-PROC_DESTROY.patch
patches.fixes/NFSv4-Don-t-exit-the-state-manager-without-clearing-.patch
+ patches.fixes/SUNRPC-Fix-a-potential-race-in-xprt_connect.patch
########################################################
# Netfilter