netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] ipv6: init the accept_queue's spinlocks in inet6_create
@ 2024-01-22 10:20 Zhengchao Shao
  2024-01-22 12:05 ` Eric Dumazet
  2024-01-23 14:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Zhengchao Shao @ 2024-01-22 10:20 UTC (permalink / raw)
  To: netdev, davem, dsahern, edumazet, kuba, pabeni
  Cc: shaozhengchao, weiyongjun1, yuehaibing

In commit 198bc90e0e73("tcp: make sure init the accept_queue's spinlocks
once"), the spinlocks of accept_queue are initialized only when socket is
created in the inet4 scenario. The locks are not initialized when socket
is created in the inet6 scenario. The kernel reports the following error:
INFO: trying to register non-static key.
The code is fine but needs lockdep annotation, or maybe
you didn't initialize this object before use?
turning off the locking correctness validator.
Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
Call Trace:
<TASK>
	dump_stack_lvl (lib/dump_stack.c:107)
	register_lock_class (kernel/locking/lockdep.c:1289)
	__lock_acquire (kernel/locking/lockdep.c:5015)
	lock_acquire.part.0 (kernel/locking/lockdep.c:5756)
	_raw_spin_lock_bh (kernel/locking/spinlock.c:178)
	inet_csk_listen_stop (net/ipv4/inet_connection_sock.c:1386)
	tcp_disconnect (net/ipv4/tcp.c:2981)
	inet_shutdown (net/ipv4/af_inet.c:935)
	__sys_shutdown (./include/linux/file.h:32 net/socket.c:2438)
	__x64_sys_shutdown (net/socket.c:2445)
	do_syscall_64 (arch/x86/entry/common.c:52)
	entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:129)
RIP: 0033:0x7f52ecd05a3d
Code: 5b 41 5c c3 66 0f 1f 84 00 00 00 00 00 f3 0f 1e fa 48 89 f8 48 89 f7
48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff
ff 73 01 c3 48 8b 0d ab a3 0e 00 f7 d8 64 89 01 48
RSP: 002b:00007f52ecf5dde8 EFLAGS: 00000293 ORIG_RAX: 0000000000000030
RAX: ffffffffffffffda RBX: 00007f52ecf5e640 RCX: 00007f52ecd05a3d
RDX: 00007f52ecc8b188 RSI: 0000000000000000 RDI: 0000000000000004
RBP: 00007f52ecf5de20 R08: 00007ffdae45c69f R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000293 R12: 00007f52ecf5e640
R13: 0000000000000000 R14: 00007f52ecc8b060 R15: 00007ffdae45c6e0

Fixes: 198bc90e0e73 ("tcp: make sure init the accept_queue's spinlocks once")
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
---
 net/ipv6/af_inet6.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 13a1833a4df5..959bfd9f6344 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -199,6 +199,9 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol,
 	if (INET_PROTOSW_REUSE & answer_flags)
 		sk->sk_reuse = SK_CAN_REUSE;
 
+	if (INET_PROTOSW_ICSK & answer_flags)
+		inet_init_csk_locks(sk);
+
 	inet = inet_sk(sk);
 	inet_assign_bit(IS_ICSK, sk, INET_PROTOSW_ICSK & answer_flags);
 
-- 
2.34.1


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

* Re: [PATCH net] ipv6: init the accept_queue's spinlocks in inet6_create
  2024-01-22 10:20 [PATCH net] ipv6: init the accept_queue's spinlocks in inet6_create Zhengchao Shao
@ 2024-01-22 12:05 ` Eric Dumazet
  2024-01-23 14:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2024-01-22 12:05 UTC (permalink / raw)
  To: Zhengchao Shao
  Cc: netdev, davem, dsahern, kuba, pabeni, weiyongjun1, yuehaibing

On Mon, Jan 22, 2024 at 11:10 AM Zhengchao Shao
<shaozhengchao@huawei.com> wrote:
>
> In commit 198bc90e0e73("tcp: make sure init the accept_queue's spinlocks
> once"), the spinlocks of accept_queue are initialized only when socket is
> created in the inet4 scenario. The locks are not initialized when socket
> is created in the inet6 scenario. The kernel reports the following error:
> INFO: trying to register non-static key.
> The code is fine but needs lockdep annotation, or maybe
> you didn't initialize this object before use?
> turning off the locking correctness validator.
> Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
> Call Trace:
> <TASK>
>         dump_stack_lvl (lib/dump_stack.c:107)
>         register_lock_class (kernel/locking/lockdep.c:1289)
>         __lock_acquire (kernel/locking/lockdep.c:5015)
>         lock_acquire.part.0 (kernel/locking/lockdep.c:5756)
>         _raw_spin_lock_bh (kernel/locking/spinlock.c:178)
>         inet_csk_listen_stop (net/ipv4/inet_connection_sock.c:1386)
>         tcp_disconnect (net/ipv4/tcp.c:2981)
>         inet_shutdown (net/ipv4/af_inet.c:935)
>         __sys_shutdown (./include/linux/file.h:32 net/socket.c:2438)
>         __x64_sys_shutdown (net/socket.c:2445)
>         do_syscall_64 (arch/x86/entry/common.c:52)
>         entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:129)
> RIP: 0033:0x7f52ecd05a3d
> Code: 5b 41 5c c3 66 0f 1f 84 00 00 00 00 00 f3 0f 1e fa 48 89 f8 48 89 f7
> 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff
> ff 73 01 c3 48 8b 0d ab a3 0e 00 f7 d8 64 89 01 48
> RSP: 002b:00007f52ecf5dde8 EFLAGS: 00000293 ORIG_RAX: 0000000000000030
> RAX: ffffffffffffffda RBX: 00007f52ecf5e640 RCX: 00007f52ecd05a3d
> RDX: 00007f52ecc8b188 RSI: 0000000000000000 RDI: 0000000000000004
> RBP: 00007f52ecf5de20 R08: 00007ffdae45c69f R09: 0000000000000000
> R10: 0000000000000000 R11: 0000000000000293 R12: 00007f52ecf5e640
> R13: 0000000000000000 R14: 00007f52ecc8b060 R15: 00007ffdae45c6e0
>
> Fixes: 198bc90e0e73 ("tcp: make sure init the accept_queue's spinlocks once")
> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>

Reviewed-by: Eric Dumazet <edumazet@google.com>

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

* Re: [PATCH net] ipv6: init the accept_queue's spinlocks in inet6_create
  2024-01-22 10:20 [PATCH net] ipv6: init the accept_queue's spinlocks in inet6_create Zhengchao Shao
  2024-01-22 12:05 ` Eric Dumazet
@ 2024-01-23 14:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-01-23 14:10 UTC (permalink / raw)
  To: shaozhengchao
  Cc: netdev, davem, dsahern, edumazet, kuba, pabeni, weiyongjun1,
	yuehaibing

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Mon, 22 Jan 2024 18:20:01 +0800 you wrote:
> In commit 198bc90e0e73("tcp: make sure init the accept_queue's spinlocks
> once"), the spinlocks of accept_queue are initialized only when socket is
> created in the inet4 scenario. The locks are not initialized when socket
> is created in the inet6 scenario. The kernel reports the following error:
> INFO: trying to register non-static key.
> The code is fine but needs lockdep annotation, or maybe
> you didn't initialize this object before use?
> turning off the locking correctness validator.
> Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
> Call Trace:
> <TASK>
> 	dump_stack_lvl (lib/dump_stack.c:107)
> 	register_lock_class (kernel/locking/lockdep.c:1289)
> 	__lock_acquire (kernel/locking/lockdep.c:5015)
> 	lock_acquire.part.0 (kernel/locking/lockdep.c:5756)
> 	_raw_spin_lock_bh (kernel/locking/spinlock.c:178)
> 	inet_csk_listen_stop (net/ipv4/inet_connection_sock.c:1386)
> 	tcp_disconnect (net/ipv4/tcp.c:2981)
> 	inet_shutdown (net/ipv4/af_inet.c:935)
> 	__sys_shutdown (./include/linux/file.h:32 net/socket.c:2438)
> 	__x64_sys_shutdown (net/socket.c:2445)
> 	do_syscall_64 (arch/x86/entry/common.c:52)
> 	entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:129)
> RIP: 0033:0x7f52ecd05a3d
> Code: 5b 41 5c c3 66 0f 1f 84 00 00 00 00 00 f3 0f 1e fa 48 89 f8 48 89 f7
> 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff
> ff 73 01 c3 48 8b 0d ab a3 0e 00 f7 d8 64 89 01 48
> RSP: 002b:00007f52ecf5dde8 EFLAGS: 00000293 ORIG_RAX: 0000000000000030
> RAX: ffffffffffffffda RBX: 00007f52ecf5e640 RCX: 00007f52ecd05a3d
> RDX: 00007f52ecc8b188 RSI: 0000000000000000 RDI: 0000000000000004
> RBP: 00007f52ecf5de20 R08: 00007ffdae45c69f R09: 0000000000000000
> R10: 0000000000000000 R11: 0000000000000293 R12: 00007f52ecf5e640
> R13: 0000000000000000 R14: 00007f52ecc8b060 R15: 00007ffdae45c6e0
> 
> [...]

Here is the summary with links:
  - [net] ipv6: init the accept_queue's spinlocks in inet6_create
    https://git.kernel.org/netdev/net/c/435e202d645c

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] 3+ messages in thread

end of thread, other threads:[~2024-01-23 14:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-22 10:20 [PATCH net] ipv6: init the accept_queue's spinlocks in inet6_create Zhengchao Shao
2024-01-22 12:05 ` Eric Dumazet
2024-01-23 14:10 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).