Skip to content

Commit e5ed4e0

Browse files
dhowellsgregkh
authored andcommitted
rxrpc: Fix deadlock around release of dst cached on udp tunnel
[ Upstream commit 5399d52 ] AF_RXRPC sockets use UDP ports in encap mode. This causes socket and dst from an incoming packet to get stolen and attached to the UDP socket from whence it is leaked when that socket is closed. When a network namespace is removed, the wait for dst records to be cleaned up happens before the cleanup of the rxrpc and UDP socket, meaning that the wait never finishes. Fix this by moving the rxrpc (and, by dependence, the afs) private per-network namespace registrations to the device group rather than subsys group. This allows cached rxrpc local endpoints to be cleared and their UDP sockets closed before we try waiting for the dst records. The symptom is that lines looking like the following: unregister_netdevice: waiting for lo to become free get emitted at regular intervals after running something like the referenced syzbot test. Thanks to Vadim for tracking this down and work out the fix. Reported-by: syzbot+df400f2f24a1677cd7e0@syzkaller.appspotmail.com Reported-by: Vadim Fedorenko <vfedorenko@novek.ru> Fixes: 5271953 ("rxrpc: Use the UDP encap_rcv hook") Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: Vadim Fedorenko <vfedorenko@novek.ru> Link: https://lore.kernel.org/r/161196443016.3868642.5577440140646403533.stgit@warthog.procyon.org.uk Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 7fc1a5a commit e5ed4e0

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

‎fs/afs/main.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static int __init afs_init(void)
193193
goto error_cache;
194194
#endif
195195

196-
ret = register_pernet_subsys(&afs_net_ops);
196+
ret = register_pernet_device(&afs_net_ops);
197197
if (ret < 0)
198198
goto error_net;
199199

@@ -213,7 +213,7 @@ static int __init afs_init(void)
213213
error_proc:
214214
afs_fs_exit();
215215
error_fs:
216-
unregister_pernet_subsys(&afs_net_ops);
216+
unregister_pernet_device(&afs_net_ops);
217217
error_net:
218218
#ifdef CONFIG_AFS_FSCACHE
219219
fscache_unregister_netfs(&afs_cache_netfs);
@@ -244,7 +244,7 @@ static void __exit afs_exit(void)
244244

245245
proc_remove(afs_proc_symlink);
246246
afs_fs_exit();
247-
unregister_pernet_subsys(&afs_net_ops);
247+
unregister_pernet_device(&afs_net_ops);
248248
#ifdef CONFIG_AFS_FSCACHE
249249
fscache_unregister_netfs(&afs_cache_netfs);
250250
#endif

‎net/rxrpc/af_rxrpc.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ static int __init af_rxrpc_init(void)
990990
goto error_security;
991991
}
992992

993-
ret = register_pernet_subsys(&rxrpc_net_ops);
993+
ret = register_pernet_device(&rxrpc_net_ops);
994994
if (ret)
995995
goto error_pernet;
996996

@@ -1035,7 +1035,7 @@ static int __init af_rxrpc_init(void)
10351035
error_sock:
10361036
proto_unregister(&rxrpc_proto);
10371037
error_proto:
1038-
unregister_pernet_subsys(&rxrpc_net_ops);
1038+
unregister_pernet_device(&rxrpc_net_ops);
10391039
error_pernet:
10401040
rxrpc_exit_security();
10411041
error_security:
@@ -1057,7 +1057,7 @@ static void __exit af_rxrpc_exit(void)
10571057
unregister_key_type(&key_type_rxrpc);
10581058
sock_unregister(PF_RXRPC);
10591059
proto_unregister(&rxrpc_proto);
1060-
unregister_pernet_subsys(&rxrpc_net_ops);
1060+
unregister_pernet_device(&rxrpc_net_ops);
10611061
ASSERTCMP(atomic_read(&rxrpc_n_tx_skbs), ==, 0);
10621062
ASSERTCMP(atomic_read(&rxrpc_n_rx_skbs), ==, 0);
10631063

0 commit comments

Comments
 (0)