All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] l2tp: prevent lockdep issue in l2tp_tunnel_register()
@ 2023-01-17 11:01 Eric Dumazet
  2023-01-17 11:20 ` Guillaume Nault
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eric Dumazet @ 2023-01-17 11:01 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: netdev, eric.dumazet, Eric Dumazet, syzbot+bbd35b345c7cab0d9a08,
	Cong Wang, Guillaume Nault

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.

Fixes: 0b2c59720e65 ("l2tp: close all race conditions in l2tp_tunnel_register()")
Reported-by: syzbot+bbd35b345c7cab0d9a08@syzkaller.appspotmail.com
Signed-off-by: Eric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/netdev/20230114030137.672706-1-xiyou.wangcong@gmail.com/T/#m1164ff20628671b0f326a24cb106ab3239c70ce3
Cc: Cong Wang <cong.wang@bytedance.com>
Cc: Guillaume Nault <gnault@redhat.com>
---
 net/l2tp/l2tp_core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
index b6554e32bb12ae7813cc06c01e4d1380af667375..03608d3ded4b83d1e59e064e482f54cffcdf5240 100644
--- a/net/l2tp/l2tp_core.c
+++ b/net/l2tp/l2tp_core.c
@@ -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);
-- 
2.39.0.314.g84b9a713c41-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net] l2tp: prevent lockdep issue in l2tp_tunnel_register()
  2023-01-17 11:01 [PATCH net] l2tp: prevent lockdep issue in l2tp_tunnel_register() Eric Dumazet
@ 2023-01-17 11:20 ` Guillaume Nault
  2023-01-18 14:50 ` patchwork-bot+netdevbpf
  2023-01-18 17:10 ` Cong Wang
  2 siblings, 0 replies; 4+ messages in thread
From: Guillaume Nault @ 2023-01-17 11:20 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, netdev,
	eric.dumazet, syzbot+bbd35b345c7cab0d9a08, Cong Wang

On Tue, Jan 17, 2023 at 11:01:31AM +0000, Eric Dumazet 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);
> 
> We need to swap [1] and [2] to fix this issue.

Reviewed-by: Guillaume Nault <gnault@redhat.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] l2tp: prevent lockdep issue in l2tp_tunnel_register()
  2023-01-17 11:01 [PATCH net] l2tp: prevent lockdep issue in l2tp_tunnel_register() Eric Dumazet
  2023-01-17 11:20 ` Guillaume Nault
@ 2023-01-18 14:50 ` patchwork-bot+netdevbpf
  2023-01-18 17:10 ` Cong Wang
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-01-18 14:50 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: davem, kuba, pabeni, netdev, eric.dumazet,
	syzbot+bbd35b345c7cab0d9a08, cong.wang, gnault

Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] l2tp: prevent lockdep issue in l2tp_tunnel_register()
  2023-01-17 11:01 [PATCH net] l2tp: prevent lockdep issue in l2tp_tunnel_register() Eric Dumazet
  2023-01-17 11:20 ` Guillaume Nault
  2023-01-18 14:50 ` patchwork-bot+netdevbpf
@ 2023-01-18 17:10 ` Cong Wang
  2 siblings, 0 replies; 4+ messages in thread
From: Cong Wang @ 2023-01-18 17:10 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, netdev,
	eric.dumazet, syzbot+bbd35b345c7cab0d9a08, Cong Wang,
	Guillaume Nault

On Tue, Jan 17, 2023 at 11:01:31AM +0000, Eric Dumazet 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);
> 
> We need to swap [1] and [2] to fix this issue.
> 
> Fixes: 0b2c59720e65 ("l2tp: close all race conditions in l2tp_tunnel_register()")
> Reported-by: syzbot+bbd35b345c7cab0d9a08@syzkaller.appspotmail.com
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Link: https://lore.kernel.org/netdev/20230114030137.672706-1-xiyou.wangcong@gmail.com/T/#m1164ff20628671b0f326a24cb106ab3239c70ce3
> Cc: Cong Wang <cong.wang@bytedance.com>
> Cc: Guillaume Nault <gnault@redhat.com>

Oops, my bad.

Acked-by: Cong Wang <cong.wang@bytedance.com>

Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-18 17:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-17 11:01 [PATCH net] l2tp: prevent lockdep issue in l2tp_tunnel_register() Eric Dumazet
2023-01-17 11:20 ` Guillaume Nault
2023-01-18 14:50 ` patchwork-bot+netdevbpf
2023-01-18 17:10 ` Cong Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.