syzbot


WARNING: refcount bug in chrdev_open

Status: fixed on 2020/02/18 14:31
Subsystems: fs
[Documentation on labels]
Reported-by: syzbot+1c85a21f1c6bc88eb388@syzkaller.appspotmail.com
Fix commit: 68faa679b8be chardev: Avoid potential use-after-free in 'chrdev_open()'
First crash: 1685d, last: 1579d
Cause bisection: the issue happens on the oldest tested release (bisect log)
Crash: WARNING in kobject_get (log)
Repro: C syz .config
  
Fix bisection: fixed by (bisect log) :
commit 68faa679b8be1a74e6663c21c3a9d25d32f1c079
Author: Will Deacon <will@kernel.org>
Date: Thu Dec 19 12:02:03 2019 +0000

  chardev: Avoid potential use-after-free in 'chrdev_open()'

  
Discussions (1)
Title Replies (including bot) Last reply
WARNING: refcount bug in chrdev_open 1 (3) 2020/01/14 12:47

Sample crash report:
------------[ cut here ]------------
refcount_t: addition on 0; use-after-free.
WARNING: CPU: 1 PID: 8266 at lib/refcount.c:25 refcount_warn_saturate+0x147/0x1b0 lib/refcount.c:25
Kernel panic - not syncing: panic_on_warn set ...
CPU: 1 PID: 8266 Comm: syz-executor922 Not tainted 5.4.0-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+0x1fb/0x318 lib/dump_stack.c:118
 panic+0x264/0x7a9 kernel/panic.c:221
 __warn+0x20e/0x210 kernel/panic.c:582
 report_bug+0x1b6/0x2f0 lib/bug.c:195
 fixup_bug arch/x86/kernel/traps.c:174 [inline]
 do_error_trap+0xd7/0x440 arch/x86/kernel/traps.c:267
 do_invalid_op+0x36/0x40 arch/x86/kernel/traps.c:286
 invalid_op+0x23/0x30 arch/x86/entry/entry_64.S:1027
RIP: 0010:refcount_warn_saturate+0x147/0x1b0 lib/refcount.c:25
Code: c7 11 65 c8 88 31 c0 e8 37 3c bb fd 0f 0b eb a1 e8 de 22 e9 fd c6 05 25 54 b2 05 01 48 c7 c7 48 65 c8 88 31 c0 e8 19 3c bb fd <0f> 0b eb 83 e8 c0 22 e9 fd c6 05 08 54 b2 05 01 48 c7 c7 74 65 c8
RSP: 0018:ffff88808a52f998 EFLAGS: 00010246
RAX: 7079bd3142f4ac00 RBX: 0000000000000002 RCX: ffff888099424340
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000000
RBP: ffff88808a52f9a8 R08: ffffffff815fa274 R09: fffffbfff13c7f29
R10: fffffbfff13c7f29 R11: 0000000000000000 R12: dffffc0000000000
R13: ffff8880a01ea628 R14: 0000000000000002 R15: ffff8880a01ea628
 refcount_add include/linux/refcount.h:193 [inline]
 refcount_inc include/linux/refcount.h:228 [inline]
 kref_get include/linux/kref.h:45 [inline]
 kobject_get+0xfb/0x120 lib/kobject.c:644
 cdev_get fs/char_dev.c:355 [inline]
 chrdev_open+0x17e/0x590 fs/char_dev.c:400
 do_dentry_open+0x740/0x10c0 fs/open.c:797
 vfs_open+0x73/0x80 fs/open.c:914
 do_last fs/namei.c:3408 [inline]
 path_openat+0x1397/0x4420 fs/namei.c:3525
 do_filp_open+0x192/0x3d0 fs/namei.c:3555
 do_sys_open+0x29f/0x560 fs/open.c:1097
 __do_sys_open fs/open.c:1115 [inline]
 __se_sys_open fs/open.c:1110 [inline]
 __x64_sys_open+0x87/0x90 fs/open.c:1110
 do_syscall_64+0xf7/0x1c0 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x4033f0
Code: 48 83 c4 08 48 3d 01 f0 ff ff 0f 83 3a 0e 00 00 c3 66 0f 1f 84 00 00 00 00 00 83 3d 5d 09 2e 00 00 75 14 b8 02 00 00 00 0f 05 <48> 3d 01 f0 ff ff 0f 83 14 0e 00 00 c3 48 83 ec 08 e8 7a 03 00 00
RSP: 002b:00007ffe74514048 EFLAGS: 00000246 ORIG_RAX: 0000000000000002
RAX: ffffffffffffffda RBX: 000000000000000a RCX: 00000000004033f0
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00007ffe74514060
RBP: 0000000000000000 R08: 000000000000000f R09: 0000000000000004
R10: 0000000000000075 R11: 0000000000000246 R12: 000000000000000d
R13: 0000000000000003 R14: 0000000000000004 R15: 00007ffe74514760
Kernel Offset: disabled
Rebooting in 86400 seconds..

Crashes (15):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/11/30 20:42 upstream 81b6b96475ac 3a75be00 .config console log report syz C ci-upstream-kasan-gce-smack-root
2019/09/23 16:10 upstream 619e17cf75dd 1e9788a0 .config console log report syz C ci-upstream-kasan-gce-smack-root
2019/08/16 20:04 upstream a69e90512d9d 8fd428a1 .config console log report syz C ci-upstream-kasan-gce-smack-root
2019/09/14 06:44 upstream a7f89616b737 32d59357 .config console log report syz ci-upstream-kasan-gce-smack-root
2019/11/18 05:00 upstream cbb104f91dfe d5696d51 .config console log report ci-upstream-kasan-gce-smack-root
2019/10/24 16:46 upstream f116b96685a0 d01bb02a .config console log report ci-upstream-kasan-gce-smack-root
2019/10/04 13:27 upstream cc3a7bfe62b9 b2f369e5 .config console log report ci-upstream-kasan-gce-smack-root
2019/09/14 04:16 upstream a7f89616b737 32d59357 .config console log report ci-upstream-kasan-gce-smack-root
2019/09/12 09:40 upstream 3120b9a6a3f7 f4e53c10 .config console log report ci-upstream-kasan-gce-smack-root
2019/09/10 02:41 upstream 56037cadf604 a60cb4cd .config console log report ci-upstream-kasan-gce-smack-root
2019/09/09 22:46 upstream 56037cadf604 a60cb4cd .config console log report ci-upstream-kasan-gce-smack-root
2019/08/30 05:37 upstream 6525771f58cb fd37b39e .config console log report ci-upstream-kasan-gce-smack-root
2019/08/25 08:22 upstream 361469211f87 d21c5d9d .config console log report ci-upstream-kasan-gce-smack-root
2019/08/23 17:25 upstream e3fb13b7e47c 78ded196 .config console log report ci-upstream-kasan-gce-smack-root
2019/08/16 18:05 upstream a69e90512d9d 8fd428a1 .config console log report ci-upstream-kasan-gce-smack-root
* Struck through repros no longer work on HEAD.