syzbot


WARNING: refcount bug in sk_psock_get (2)

Status: upstream: reported C repro on 2022/06/03 15:34
Reported-by: syzbot+5f26f85569bd179c18ce@syzkaller.appspotmail.com
Fix commit: 2a0133723f9e net: fix refcount bug in sk_psock_get (2)
Patched on: [ci-qemu-upstream ci-qemu-upstream-386 ci-qemu2-arm32 ci-qemu2-arm64 ci-qemu2-arm64-compat ci-qemu2-arm64-mte ci-upstream-bpf-kasan-gce ci-upstream-bpf-next-kasan-gce ci-upstream-gce-arm64 ci-upstream-gce-leak ci-upstream-kasan-gce ci-upstream-kasan-gce-386 ci-upstream-kasan-gce-root ci-upstream-kasan-gce-selinux-root ci-upstream-kasan-gce-smack-root ci-upstream-kmsan-gce ci-upstream-kmsan-gce-386 ci-upstream-linux-next-kasan-gce-root ci-upstream-net-kasan-gce ci-upstream-net-this-kasan-gce ci2-upstream-fs ci2-upstream-kcsan-gce ci2-upstream-usb], missing on: [ci-qemu2-riscv64]
First crash: 125d, last: 83d

Cause bisection: introduced by (bisect log) :
commit 341adeec9adad0874f29a0a1af35638207352a39
Author: Wen Gu <guwen@linux.alibaba.com>
Date: Wed Jan 26 15:33:04 2022 +0000

  net/smc: Forward wakeup to smc socket waitqueue after fallback

Crash: WARNING: refcount bug in sk_psock_get (log)
Repro: C syz .config
similar bugs (1):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream WARNING: refcount bug in sk_psock_get C done 8 517d 544d 22/24 fixed on 2021/11/10 00:50
Patch testing requests:
Created Duration User Patch Repo Result
2022/08/03 07:23 16m yin31149@gmail.com patch upstream OK log
2022/08/03 07:07 9m yin31149@gmail.com patch https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git master error
2022/08/03 06:51 9m yin31149@gmail.com patch https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git master error
2022/07/30 04:08 15m yin31149@gmail.com patch upstream OK log
2022/07/01 13:48 16m yin31149@gmail.com patch upstream OK log
2022/07/01 12:50 0m yin31149@gmail.com patch upstream error

Sample crash report:
------------[ cut here ]------------
refcount_t: saturated; leaking memory.
WARNING: CPU: 1 PID: 3607 at lib/refcount.c:19 refcount_warn_saturate+0xf4/0x1e0 lib/refcount.c:19
Modules linked in:
CPU: 0 PID: 3607 Comm: syz-executor332 Not tainted 5.19.0-rc6-syzkaller-00115-g4a57a8400075 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/29/2022
RIP: 0010:refcount_warn_saturate+0xf4/0x1e0 lib/refcount.c:19
Code: 1d 4a 59 aa 09 31 ff 89 de e8 28 e7 7d fd 84 db 75 ab e8 1f eb 7d fd 48 c7 c7 a0 20 28 8a c6 05 2a 59 aa 09 01 e8 16 ef 35 05 <0f> 0b eb 8f e8 03 eb 7d fd 0f b6 1d 14 59 aa 09 31 ff 89 de e8 f3
RSP: 0018:ffffc9000301f9d0 EFLAGS: 00010282
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: ffff888024cd9d80 RSI: ffffffff8160d028 RDI: fffff52000603f2c
RBP: 0000000000000000 R08: 0000000000000005 R09: 0000000000000000
R10: 0000000080000000 R11: 0000000000000001 R12: 1ffff92000603f3d
R13: 00000000912cc501 R14: ffff888072fa8000 R15: ffffc9000301fa08
FS:  0000555555cb3300(0000) GS:ffff8880b9b00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000642040 CR3: 0000000024c61000 CR4: 0000000000350ee0
Call Trace:
 <TASK>
 __refcount_add_not_zero include/linux/refcount.h:163 [inline]
 __refcount_inc_not_zero include/linux/refcount.h:227 [inline]
 refcount_inc_not_zero include/linux/refcount.h:245 [inline]
 sk_psock_get+0x3bc/0x410 include/linux/skmsg.h:439
 tls_data_ready+0x6d/0x1b0 net/tls/tls_sw.c:2091
 tcp_data_ready+0x106/0x520 net/ipv4/tcp_input.c:4986
 tcp_data_queue+0x1bb2/0x4c60 net/ipv4/tcp_input.c:5060
 tcp_rcv_state_process+0x1798/0x4eb0 net/ipv4/tcp_input.c:6662
 tcp_v4_do_rcv+0x339/0x9b0 net/ipv4/tcp_ipv4.c:1682
 sk_backlog_rcv include/net/sock.h:1047 [inline]
 __release_sock+0x134/0x3b0 net/core/sock.c:2849
 release_sock+0x54/0x1b0 net/core/sock.c:3404
 inet_shutdown+0x1e0/0x430 net/ipv4/af_inet.c:909
 __sys_shutdown_sock net/socket.c:2326 [inline]
 __sys_shutdown_sock net/socket.c:2320 [inline]
 __sys_shutdown+0xf1/0x1b0 net/socket.c:2338
 __do_sys_shutdown net/socket.c:2346 [inline]
 __se_sys_shutdown net/socket.c:2344 [inline]
 __x64_sys_shutdown+0x50/0x70 net/socket.c:2344
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fd3d30b8969
Code: 28 c3 e8 4a 15 00 00 66 2e 0f 1f 84 00 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 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffe39ca75d8 EFLAGS: 00000246 ORIG_RAX: 0000000000000030
RAX: ffffffffffffffda RBX: 00007ffe39ca75e8 RCX: 00007fd3d30b8969
RDX: 00007fd3d30b8969 RSI: 0000000000000001 RDI: 0000000000000003
RBP: 0000000000000003 R08: bb1414ac00000000 R09: bb1414ac00000000
R10: 0000000000000028 R11: 0000000000000246 R12: 00007ffe39ca75f0
R13: 00007ffe39ca75e4 R14: 0000000000000003 R15: 0000000000000000
 </TASK>

Fix bisection attempts:
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce 2022/07/04 22:57 upstream c1084b6c5620 5783034f .config log report syz C
* Struck through repros no longer work on HEAD.
Crashes (4):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce-root 2022/07/14 13:20 upstream 4a57a8400075 5d921b08 .config log report syz C WARNING: refcount bug in sk_psock_get
ci-upstream-kasan-gce 2022/06/02 19:57 upstream d1dc87763f40 5783034f .config log report syz C WARNING: refcount bug in sk_psock_get
ci-upstream-net-kasan-gce 2022/06/02 14:25 net-next 7e062cda7d90 5783034f .config log report syz C WARNING: refcount bug in sk_psock_get
ci-upstream-net-this-kasan-gce 2022/06/04 22:36 net 58f9d52ff689 c8857892 .config log report info WARNING: refcount bug in sk_psock_get
* Struck through repros no longer work on HEAD.