rds: tcp: atomically purge entries from rds_tcp_conn_list during netns delete
authorSowmini Varadhan <sowmini.varadhan@oracle.com>
Thu, 30 Nov 2017 19:11:29 +0000 (11:11 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 25 Feb 2018 10:07:51 +0000 (11:07 +0100)
commit83ee02de2c8d958b598498a81323635f02bc4b1e
treef5be76e88065c7905d59993198a32c5fed0c5cae
parentc64534f82608a8f9d58d7c74d4a12122bdb2c3fe
rds: tcp: atomically purge entries from rds_tcp_conn_list during netns delete

commit f10b4cff98c6977668434fbf5dd58695eeca2897 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/rds/tcp.c
net/rds/tcp.h