l2tp: prevent lockdep issue in l2tp_tunnel_register()
Subsystems (2)
PATCH 1/1 l2tp: prevent lockdep issue in l2tp_tunnel_register()
lockdep complains with the following lock/unlock sequence:
lock_sock(sk);
write_lock_bh(&sk->sk_callback_lock);[1] release_sock(sk);
[2] write_unlock_bh(&sk->sk_callback_lock);
We need to swap [1] and [2] to fix this issue.
--- net/l2tp/l2tp_core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
net/l2tp/l2tp_core.c +2 -3
@@ -1483,10 +1483,8 @@ int l2tp_tunnel_register(struct l2tp_tunnel *tunnel, struct net *net,lock_sock (sk);write_lock_bh (&sk->sk_callback_lock); ret =l2tp_validate_socket (sk, net, tunnel->encap); -if (ret <0 ) { -release_sock (sk); +if (ret <0 ) goto err_inval_sock; - }rcu_assign_sk_user_data (sk, tunnel);write_unlock_bh (&sk->sk_callback_lock);
@@ -1523,6 +1521,7 @@ int l2tp_tunnel_register(struct l2tp_tunnel *tunnel, struct net *net, err_inval_sock:write_unlock_bh (&sk->sk_callback_lock); +release_sock (sk);if (tunnel->fd <0 )sock_release (sock);
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Quoted 8 lines · Eric Dumazet
lockdep complains with the following lock/unlock sequence:
lock_sock(sk); write_lock_bh(&sk->sk_callback_lock);[1]
release_sock(sk);
[2]write_unlock_bh(&sk->sk_callback_lock);We need to swap [1] and [2] to fix this issue.
This patch was applied to netdev/net.git (master) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net.git (master)
by David S. Miller <[email protected]>:
Quoted 8 lines · On Tue, 17 Jan 2023 11:01:31 +0000 you wrote:
lockdep complains with the following lock/unlock sequence:
lock_sock(sk); write_lock_bh(&sk->sk_callback_lock);[1]
release_sock(sk);
[2]write_unlock_bh(&sk->sk_callback_lock);[...]
Here is the summary with links:
- [net] l2tp: prevent lockdep issue in l2tp_tunnel_register()
https://git.kernel.org/netdev/net/c/b9fb10d131b8
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Quoted 7 lines · Eric Dumazet
lockdep complains with the following lock/unlock sequence:
lock_sock(sk); write_lock_bh(&sk->sk_callback_lock);[1]
release_sock(sk);
[2]write_unlock_bh(&sk->sk_callback_lock);
Quoted 8 lines
We need to swap [1] and [2] to fix this issue.
Fixes 0b2c59720e65 ("l2tp: close all race conditions in l2tp_tunnel_register()")Reported-by [email protected]Signed-off-by Eric Dumazet <[email protected]>Link https://lore.kernel.org/netdev/[email protected]/T/#m1164ff20628671b0f326a24cb106ab3239c70ce3 open hereCc Cong Wang <[email protected]>Cc Guillaume Nault <[email protected]>
Oops, my bad.
Thanks.