Eric Dumazet
06669ea346
net: memcg: fix lockdep splat in inet_csk_accept()
...
Locking newsk while still holding the listener lock triggered
a lockdep splat [1]
We can simply move the memcg code after we release the listener lock,
as this can also help if multiple threads are sharing a common listener.
Also fix a typo while reading socket sk_rmem_alloc.
[1]
WARNING: possible recursive locking detected
5.6.0-rc3-syzkaller #0 Not tainted
--------------------------------------------
syz-executor598/9524 is trying to acquire lock:
ffff88808b5b8b90 (sk_lock-AF_INET6){+.+.}, at: lock_sock include/net/sock.h:1541 [inline]
ffff88808b5b8b90 (sk_lock-AF_INET6){+.+.}, at: inet_csk_accept+0x69f/0xd30 net/ipv4/inet_connection_sock.c:492
but task is already holding lock:
ffff88808b5b9590 (sk_lock-AF_INET6){+.+.}, at: lock_sock include/net/sock.h:1541 [inline]
ffff88808b5b9590 (sk_lock-AF_INET6){+.+.}, at: inet_csk_accept+0x8d/0xd30 net/ipv4/inet_connection_sock.c:445
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
----
lock(sk_lock-AF_INET6);
lock(sk_lock-AF_INET6);
*** DEADLOCK ***
May be due to missing lock nesting notation
1 lock held by syz-executor598/9524:
#0 : ffff88808b5b9590 (sk_lock-AF_INET6){+.+.}, at: lock_sock include/net/sock.h:1541 [inline]
#0 : ffff88808b5b9590 (sk_lock-AF_INET6){+.+.}, at: inet_csk_accept+0x8d/0xd30 net/ipv4/inet_connection_sock.c:445
stack backtrace:
CPU: 0 PID: 9524 Comm: syz-executor598 Not tainted 5.6.0-rc3-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x188/0x20d lib/dump_stack.c:118
print_deadlock_bug kernel/locking/lockdep.c:2370 [inline]
check_deadlock kernel/locking/lockdep.c:2411 [inline]
validate_chain kernel/locking/lockdep.c:2954 [inline]
__lock_acquire.cold+0x114/0x288 kernel/locking/lockdep.c:3954
lock_acquire+0x197/0x420 kernel/locking/lockdep.c:4484
lock_sock_nested+0xc5/0x110 net/core/sock.c:2947
lock_sock include/net/sock.h:1541 [inline]
inet_csk_accept+0x69f/0xd30 net/ipv4/inet_connection_sock.c:492
inet_accept+0xe9/0x7c0 net/ipv4/af_inet.c:734
__sys_accept4_file+0x3ac/0x5b0 net/socket.c:1758
__sys_accept4+0x53/0x90 net/socket.c:1809
__do_sys_accept4 net/socket.c:1821 [inline]
__se_sys_accept4 net/socket.c:1818 [inline]
__x64_sys_accept4+0x93/0xf0 net/socket.c:1818
do_syscall_64+0xf6/0x790 arch/x86/entry/common.c:294
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x4445c9
Code: e8 0c 0d 03 00 48 83 c4 18 c3 0f 1f 80 00 00 00 00 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 0f 83 eb 08 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffc35b37608 EFLAGS: 00000246 ORIG_RAX: 0000000000000120
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00000000004445c9
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000003
RBP: 0000000000000000 R08: 0000000000306777 R09: 0000000000306777
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00000000004053d0 R14: 0000000000000000 R15: 0000000000000000
Fixes: d752a4986532 ("net: memcg: late association of sock to memcg")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Shakeel Butt <shakeelb@google.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-03-11 23:57:33 -07:00
..
2019-09-27 15:10:34 -07:00
2019-12-09 10:36:44 -08:00
2020-01-09 12:13:43 -08:00
2019-09-24 16:37:18 +02:00
2020-02-04 03:05:26 +00:00
2020-01-09 18:41:40 -08:00
2020-02-18 09:07:55 +01:00
2020-01-26 10:34:17 +02:00
2019-12-18 17:05:58 -08:00
2020-02-04 01:53:07 +09:00
2020-02-24 11:11:19 -08:00
2020-03-11 22:55:25 -07:00
2019-12-08 11:52:02 +01:00
2020-02-08 13:26:41 -08:00
2020-03-10 15:33:05 -07:00
2019-12-09 10:36:44 -08:00
2020-01-09 18:41:40 -08:00
2020-03-11 23:46:11 -07:00
2020-01-27 11:09:31 +01:00
2020-02-26 11:27:31 -08:00
2020-02-19 10:55:42 -08:00
2020-03-03 13:28:48 -08:00
2019-09-26 08:56:17 +02:00
2020-03-11 23:57:33 -07:00
2020-03-11 23:49:30 -07:00
2019-12-09 10:36:44 -08:00
2019-09-27 10:27:14 +02:00
2020-02-04 12:35:49 +01:00
2019-12-20 21:19:36 -08:00
2020-03-11 09:04:14 +01:00
2019-12-04 12:27:13 -08:00
2020-03-05 21:34:42 -08:00
2020-01-09 18:36:22 -08:00
2020-03-06 18:00:43 +01:00
2020-02-18 12:44:23 -08:00
2020-02-29 21:21:23 -08:00
2019-10-24 14:53:48 -07:00
2020-03-05 21:32:42 -08:00
2020-03-03 13:28:48 -08:00
2020-03-11 23:12:16 -07:00
2020-01-03 12:25:50 -08:00
2019-11-26 14:40:13 -08:00
2020-01-14 18:36:42 -08:00
2020-02-16 18:37:09 -08:00
2019-12-16 10:15:49 +01:00
2020-01-26 10:40:21 +01:00
2020-02-07 11:20:57 +01:00
2020-03-03 13:28:48 -08:00
2020-03-08 21:57:48 -07:00
2020-03-10 15:40:33 -07:00
2020-02-13 15:35:33 -05:00
2020-03-03 13:28:49 -08:00
2020-02-19 16:32:06 -08:00
2020-02-27 11:52:35 -08:00
2020-02-27 12:03:56 -08:00
2019-08-10 15:25:47 -07:00
2020-03-11 08:58:39 +01:00
2020-01-09 18:39:33 -08:00
2020-02-11 15:51:11 +01:00
2020-02-13 14:19:00 -08:00
2019-11-15 14:38:29 +01:00
2020-02-20 15:02:02 -08:00
2020-01-24 13:44:07 +01:00
2020-01-08 15:02:21 -08:00