syzbot


WARNING: refcount bug in sock_wfree

Status: fixed on 2020/04/20 22:55
Reported-by: syzbot+59dc1aa392e0d829104b@syzkaller.appspotmail.com
Fix commit: 6ce6aea362d4 sctp: fix refcount bug in sctp_wfree
First crash: 1826d, last: 1706d
Cause bisection: introduced by (bisect log) :
commit cbf23d40cece0a1631c5b6b4bcc937f49650439f
Author: Xin Long <lucien.xin@gmail.com>
Date: Mon Jan 21 18:42:09 2019 +0000

  sctp: set chunk transport correctly when it's a new asoc

Crash: WARNING: refcount bug in sock_wfree (log)
Repro: C syz .config
  
Fix bisection: fixed by (bisect log) :
commit 6ce6aea362d46781d4f5f03cfda16f0a395445d2
Author: Qiujun Huang <hqjagain@gmail.com>
Date: Fri Mar 27 03:07:51 2020 +0000

  sctp: fix refcount bug in sctp_wfree

  
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 WARNING: refcount bug in sock_wfree C done done 3 1705d 1826d 1/1 fixed on 2020/04/20 22:55
upstream WARNING: refcount bug in sock_wfree (2) C done 606 1692d 1865d 1/28 closed as invalid on 2020/06/27 23:36
upstream WARNING: refcount bug in sock_wfree sctp syz error 24 2184d 2464d 0/28 closed as invalid on 2019/04/09 10:51
Fix bisection attempts (5)
Created Duration User Patch Repo Result
2020/04/20 15:22 3h25m bisect fix linux-4.19.y OK (1) job log
2020/03/21 14:57 25m bisect fix linux-4.19.y OK (0) job log log
2020/02/20 14:31 25m bisect fix linux-4.19.y OK (0) job log log
2020/01/21 14:05 26m bisect fix linux-4.19.y OK (0) job log log
2019/12/22 13:41 24m bisect fix linux-4.19.y OK (0) job log log

Sample crash report:
audit: type=1400 audit(1574429880.357:35): avc:  denied  { map } for  pid=7746 comm="bash" path="/bin/bash" dev="sda1" ino=1457 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=system_u:object_r:file_t:s0 tclass=file permissive=1
audit: type=1400 audit(1574429887.077:36): avc:  denied  { map } for  pid=7758 comm="syz-executor818" path="/root/syz-executor818180628" dev="sda1" ino=16483 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=1
------------[ cut here ]------------
refcount_t: underflow; use-after-free.
WARNING: CPU: 1 PID: 7758 at lib/refcount.c:187 refcount_sub_and_test_checked lib/refcount.c:187 [inline]
WARNING: CPU: 1 PID: 7758 at lib/refcount.c:187 refcount_sub_and_test_checked+0x1c5/0x1f0 lib/refcount.c:177
Kernel panic - not syncing: panic_on_warn set ...

CPU: 1 PID: 7758 Comm: syz-executor818 Not tainted 4.19.85-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+0x197/0x210 lib/dump_stack.c:118
 panic+0x26a/0x50e kernel/panic.c:186
 __warn.cold+0x20/0x53 kernel/panic.c:541
 report_bug+0x263/0x2b0 lib/bug.c:186
 fixup_bug arch/x86/kernel/traps.c:178 [inline]
 fixup_bug arch/x86/kernel/traps.c:173 [inline]
 do_error_trap+0x204/0x360 arch/x86/kernel/traps.c:296
 do_invalid_op+0x1b/0x20 arch/x86/kernel/traps.c:316
 invalid_op+0x14/0x20 arch/x86/entry/entry_64.S:1037
RIP: 0010:refcount_sub_and_test_checked lib/refcount.c:187 [inline]
RIP: 0010:refcount_sub_and_test_checked+0x1c5/0x1f0 lib/refcount.c:177
Code: 1d 99 37 14 06 31 ff 89 de e8 d7 af 47 fe 84 db 75 1a e8 8e ae 47 fe 48 c7 c7 80 2c 82 87 c6 05 79 37 14 06 01 e8 d9 2c 1b fe <0f> 0b 45 31 e4 eb 90 e8 6f ae 47 fe e9 ce fe ff ff 48 89 df e8 12
RSP: 0018:ffff88809e6e7550 EFLAGS: 00010286
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffffffff815595d6 RDI: ffffed1013cdce9c
RBP: ffff88809e6e75e0 R08: ffff88809fca4540 R09: ffffed1015d23ee3
R10: ffffed1015d23ee2 R11: ffff8880ae91f717 R12: 00000000ffffff01
R13: 0000000000008001 R14: 1ffff11013cdceab R15: ffff88809e6e75b8
 sock_wfree+0xb6/0x180 net/core/sock.c:1819
 sctp_wfree+0x395/0x960 net/sctp/socket.c:8467
 skb_release_head_state+0x15d/0x2d0 net/core/skbuff.c:616
 skb_release_all+0x16/0x60 net/core/skbuff.c:629
 __kfree_skb net/core/skbuff.c:645 [inline]
 consume_skb net/core/skbuff.c:705 [inline]
 consume_skb+0xe2/0x380 net/core/skbuff.c:699
 sctp_chunk_destroy net/sctp/sm_make_chunk.c:1467 [inline]
 sctp_chunk_put+0x192/0x280 net/sctp/sm_make_chunk.c:1494
 sctp_chunk_free+0x56/0x70 net/sctp/sm_make_chunk.c:1481
 __sctp_outq_teardown+0x1d0/0xc60 net/sctp/outqueue.c:234
 sctp_outq_free+0x16/0x20 net/sctp/outqueue.c:291
 sctp_association_free+0x208/0x79a net/sctp/associola.c:360
 sctp_cmd_delete_tcb net/sctp/sm_sideeffect.c:944 [inline]
 sctp_cmd_interpreter net/sctp/sm_sideeffect.c:1332 [inline]
 sctp_side_effects net/sctp/sm_sideeffect.c:1199 [inline]
 sctp_do_sm+0x3a73/0x5190 net/sctp/sm_sideeffect.c:1170
 sctp_primitive_ABORT+0xa0/0xd0 net/sctp/primitive.c:119
 sctp_close+0x259/0x860 net/sctp/socket.c:1558
 inet_release+0xff/0x1e0 net/ipv4/af_inet.c:428
 __sock_release+0xce/0x2a0 net/socket.c:579
 sock_close+0x1b/0x30 net/socket.c:1140
 __fput+0x2dd/0x8b0 fs/file_table.c:278
 ____fput+0x16/0x20 fs/file_table.c:309
 task_work_run+0x145/0x1c0 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0x994/0x2fa0 kernel/exit.c:876
 do_group_exit+0x135/0x370 kernel/exit.c:979
 __do_sys_exit_group kernel/exit.c:990 [inline]
 __se_sys_exit_group kernel/exit.c:988 [inline]
 __x64_sys_exit_group+0x44/0x50 kernel/exit.c:988
 do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x43f268
Code: Bad RIP value.
RSP: 002b:00007ffe2bf71e18 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 000000000043f268
RDX: 0000000000000000 RSI: 000000000000003c RDI: 0000000000000000
RBP: 00000000004bea68 R08: 00000000000000e7 R09: ffffffffffffffd0
R10: 000000002059aff8 R11: 0000000000000246 R12: 0000000000000001
R13: 00000000006d01a0 R14: 0000000000000000 R15: 0000000000000000
Kernel Offset: disabled
Rebooting in 86400 seconds..

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/11/22 13:41 linux-4.19.y c63ee2939dc1 598ca6c8 .config console log report syz C ci2-linux-4-19
* Struck through repros no longer work on HEAD.