Message ID | 20220404183439.3537837-1-eric.dumazet@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 1946014ca3b19be9e485e780e862c375c6f98bad |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net] rxrpc: fix a race in rxrpc_exit_net() | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Clearly marked for net |
netdev/fixes_present | success | Fixes tag present in non-next series |
netdev/subject_prefix | success | Link |
netdev/cover_letter | success | Single patches do not need cover letters |
netdev/patch_count | success | Link |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/cc_maintainers | success | CCed 7 of 7 maintainers |
netdev/build_clang | success | Errors and warnings before: 0 this patch: 0 |
netdev/module_param | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/verify_fixes | success | Fixes tag looks correct |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/checkpatch | warning | WARNING: Possible repeated word: 'Google' |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
Hello: This patch was applied to netdev/net.git (master) by David S. Miller <davem@davemloft.net>: On Mon, 4 Apr 2022 11:34:39 -0700 you wrote: > From: Eric Dumazet <edumazet@google.com> > > Current code can lead to the following race: > > CPU0 CPU1 > > rxrpc_exit_net() > rxrpc_peer_keepalive_worker() > if (rxnet->live) > > [...] Here is the summary with links: - [net] rxrpc: fix a race in rxrpc_exit_net() https://git.kernel.org/netdev/net/c/1946014ca3b1 You are awesome, thank you!
Hi Eric, [Note that your patch is appl/octet-stream for some reason.] > rxnet->live = false; > - del_timer_sync(&rxnet->peer_keepalive_timer); > cancel_work_sync(&rxnet->peer_keepalive_work); > + del_timer_sync(&rxnet->peer_keepalive_timer); That fixes that problem, but introduces another. The timer could be in the throes of queueing the worker: CPU 1 CPU 2 ==================== ===================== if (rxnet->live) <INTERRUPT> rxnet->live = false; cancel_work_sync(&rxnet->peer_keepalive_work); rxrpc_queue_work(&rxnet->peer_keepalive_work); del_timer_sync(&rxnet->peer_keepalive_timer); I think keeping the first del_timer_sync() that you removed and the one after the cancel would be sufficient. David
Do you have a syzbot ref for this? David
On 4/12/22 01:06, David Howells wrote: > Do you have a syzbot ref for this? Try: https://syzkaller.appspot.com/bug?extid=724378c4bb58f703b09a > David >
diff --git a/net/rxrpc/net_ns.c b/net/rxrpc/net_ns.c index 25bbc4cc8b1359f7b895f181dad227de088ed31d..f15d6942da45306e4fa15399473044281dcbfed9 100644 --- a/net/rxrpc/net_ns.c +++ b/net/rxrpc/net_ns.c @@ -113,8 +113,8 @@ static __net_exit void rxrpc_exit_net(struct net *net) struct rxrpc_net *rxnet = rxrpc_net(net); rxnet->live = false; - del_timer_sync(&rxnet->peer_keepalive_timer); cancel_work_sync(&rxnet->peer_keepalive_work); + del_timer_sync(&rxnet->peer_keepalive_timer); rxrpc_destroy_all_calls(rxnet); rxrpc_destroy_all_connections(rxnet); rxrpc_destroy_all_peers(rxnet);