Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Kirjanov <dkirjanov@suse.com>2019-05-02 13:49:28 +0200
committerDenis Kirjanov <dkirjanov@suse.com>2019-05-02 13:49:33 +0200
commitafb61f8f3019c8f8b9ab2d1b38a1715d9abd0aa4 (patch)
tree8d1c3a994c31c25bf7af96897dc98ba691af52ab
parent52de60892eae0da1ae21542cd3f6d79181279e2d (diff)
rds: tcp: atomically purge entries from rds_tcp_conn_list
during netns delete (git-fixes).
-rw-r--r--patches.fixes/0001-rds-tcp-atomically-purge-entries-from-rds_tcp_conn_l.patch75
-rw-r--r--series.conf1
2 files changed, 76 insertions, 0 deletions
diff --git a/patches.fixes/0001-rds-tcp-atomically-purge-entries-from-rds_tcp_conn_l.patch b/patches.fixes/0001-rds-tcp-atomically-purge-entries-from-rds_tcp_conn_l.patch
new file mode 100644
index 0000000000..e5c6510ad4
--- /dev/null
+++ b/patches.fixes/0001-rds-tcp-atomically-purge-entries-from-rds_tcp_conn_l.patch
@@ -0,0 +1,75 @@
+From: Sowmini Varadhan <sowmini.varadhan@oracle.com>
+Subject: rds: tcp: atomically purge entries from
+ rds_tcp_conn_list during netns delete
+Patch-mainline: v4.16-rc1
+Git-commit: f10b4cff98c6977668434fbf5dd58695eeca2897
+References: git-fixes
+
+The rds_tcp_kill_sock() function parses the rds_tcp_conn_list
+to find the rds_connection entries marked for deletion as part
+of the netns deletion under the protection of the rds_tcp_conn_lock.
+Since the rds_tcp_conn_list tracks rds_tcp_connections (which
+have a 1:1 mapping with rds_conn_path), multiple tc entries in
+the rds_tcp_conn_list will map to a single rds_connection, and will
+be deleted as part of the rds_conn_destroy() operation that is
+done outside the rds_tcp_conn_lock.
+
+The rds_tcp_conn_list traversal done under the protection of
+rds_tcp_conn_lock should not leave any doomed tc entries in
+the list after the rds_tcp_conn_lock is released, else another
+concurrently executiong netns delete (for a differnt netns) thread
+may trip on these entries.
+
+Reported-by: syzbot <syzkaller@googlegroups.com>
+Signed-off-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
+Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Acked-by: Denis Kirjanov <dkirjanov@suse.com>
+---
+ net/rds/tcp.c | 9 +++++++--
+ net/rds/tcp.h | 1 +
+ 2 files changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/net/rds/tcp.c b/net/rds/tcp.c
+index ad0eaab53da0..b598c81aef69 100644
+--- a/net/rds/tcp.c
++++ b/net/rds/tcp.c
+@@ -306,7 +306,8 @@ static void rds_tcp_conn_free(void *arg)
+ rdsdebug("freeing tc %p\n", tc);
+
+ spin_lock_irqsave(&rds_tcp_conn_lock, flags);
+- list_del(&tc->t_tcp_node);
++ if (!tc->t_tcp_node_detached)
++ list_del(&tc->t_tcp_node);
+ spin_unlock_irqrestore(&rds_tcp_conn_lock, flags);
+
+ kmem_cache_free(rds_tcp_conn_slab, tc);
+@@ -510,8 +511,12 @@ static void rds_tcp_kill_sock(struct net *net)
+
+ if (net != c_net || !tc->t_sock)
+ continue;
+- if (!list_has_conn(&tmp_list, tc->t_cpath->cp_conn))
++ if (!list_has_conn(&tmp_list, tc->t_cpath->cp_conn)) {
+ list_move_tail(&tc->t_tcp_node, &tmp_list);
++ } else {
++ list_del(&tc->t_tcp_node);
++ tc->t_tcp_node_detached = true;
++ }
+ }
+ spin_unlock_irq(&rds_tcp_conn_lock);
+ list_for_each_entry_safe(tc, _tc, &tmp_list, t_tcp_node)
+diff --git a/net/rds/tcp.h b/net/rds/tcp.h
+index f8800b7ce79c..87753497fd4f 100644
+--- a/net/rds/tcp.h
++++ b/net/rds/tcp.h
+@@ -11,6 +11,7 @@ struct rds_tcp_incoming {
+ struct rds_tcp_connection {
+
+ struct list_head t_tcp_node;
++ bool t_tcp_node_detached;
+ struct rds_conn_path *t_cpath;
+ /* t_conn_path_lock synchronizes the connection establishment between
+ * rds_tcp_accept_one and rds_tcp_conn_path_connect
+--
+2.12.3
+
diff --git a/series.conf b/series.conf
index 946853ea46..5dda07dae3 100644
--- a/series.conf
+++ b/series.conf
@@ -12271,6 +12271,7 @@
patches.drivers/vmxnet3-increase-default-rx-ring-sizes.patch
patches.fixes/rds-tcp-remove-redundant-function-rds_tcp_conn_paths.patch
patches.fixes/rds-tcp-correctly-sequence-cleanup-on-netns-deletion.patch
+ patches.fixes/0001-rds-tcp-atomically-purge-entries-from-rds_tcp_conn_l.patch
patches.drivers/net-ethtool-add-support-for-reset-of-AP-inside-NIC-i.patch
patches.drivers/bnxt_en-Add-ETH_RESET_AP-support.patch
patches.suse/msft-hv-1555-hv_netvsc-drop-unused-macros.patch