syzbot


KASAN: use-after-free Write in tty_buffer_cancel_work

Status: closed as dup on 2020/03/07 20:06
Subsystems: serial
[Documentation on labels]
Reported-by: syzbot+712f841d2144563deebe@syzkaller.appspotmail.com
First crash: 1847d, last: 1757d
Cause bisection: the issue happens on the oldest tested release (bisect log)
Crash: no output from test machine (log)
Repro: C syz .config
  
Duplicate of
Title Repro Cause bisect Fix bisect Count Last Reported
KASAN: use-after-free Write in release_tty C done 591 1728d 1850d
Discussions (1)
Title Replies (including bot) Last reply
KASAN: use-after-free Write in tty_buffer_cancel_work 0 (1) 2019/12/06 15:55

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in test_and_set_bit include/asm-generic/bitops/instrumented-atomic.h:70 [inline]
BUG: KASAN: use-after-free in try_to_grab_pending kernel/workqueue.c:1251 [inline]
BUG: KASAN: use-after-free in try_to_grab_pending+0x115/0x910 kernel/workqueue.c:1229
Write of size 8 at addr ffff888092f37008 by task syz-executor776/10657

CPU: 0 PID: 10657 Comm: syz-executor776 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+0x197/0x210 lib/dump_stack.c:118
 print_address_description.constprop.0.cold+0xd4/0x30b mm/kasan/report.c:374
 __kasan_report.cold+0x1b/0x32 mm/kasan/report.c:506
 kasan_report+0x12/0x20 mm/kasan/common.c:641
 check_memory_region_inline mm/kasan/generic.c:185 [inline]
 check_memory_region+0x134/0x1a0 mm/kasan/generic.c:192
 __kasan_check_write+0x14/0x20 mm/kasan/common.c:101
 test_and_set_bit include/asm-generic/bitops/instrumented-atomic.h:70 [inline]
 try_to_grab_pending kernel/workqueue.c:1251 [inline]
 try_to_grab_pending+0x115/0x910 kernel/workqueue.c:1229
 __cancel_work_timer+0xc4/0x540 kernel/workqueue.c:3087
 cancel_work_sync+0x18/0x20 kernel/workqueue.c:3164
 tty_buffer_cancel_work+0x16/0x20 drivers/tty/tty_buffer.c:613
 release_tty+0x261/0x470 drivers/tty/tty_io.c:1520
 tty_release_struct+0x3c/0x50 drivers/tty/tty_io.c:1629
 tty_release+0xbcb/0xe90 drivers/tty/tty_io.c:1789
 __fput+0x2ff/0x890 fs/file_table.c:280
 ____fput+0x16/0x20 fs/file_table.c:313
 task_work_run+0x145/0x1c0 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0xba9/0x2f50 kernel/exit.c:801
 do_group_exit+0x135/0x360 kernel/exit.c:899
 __do_sys_exit_group kernel/exit.c:910 [inline]
 __se_sys_exit_group kernel/exit.c:908 [inline]
 __x64_sys_exit_group+0x44/0x50 kernel/exit.c:908
 do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x43ff38
Code: 00 00 be 3c 00 00 00 eb 19 66 0f 1f 84 00 00 00 00 00 48 89 d7 89 f0 0f 05 48 3d 00 f0 ff ff 77 21 f4 48 89 d7 44 89 c0 0f 05 <48> 3d 00 f0 ff ff 76 e0 f7 d8 64 41 89 01 eb d8 0f 1f 84 00 00 00
RSP: 002b:00007ffe97e49478 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 000000000043ff38
RDX: 0000000000000000 RSI: 000000000000003c RDI: 0000000000000000
RBP: 00000000004bf950 R08: 00000000000000e7 R09: ffffffffffffffd0
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
R13: 00000000006d2180 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 10657:
 save_stack+0x23/0x90 mm/kasan/common.c:72
 set_track mm/kasan/common.c:80 [inline]
 __kasan_kmalloc mm/kasan/common.c:515 [inline]
 __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:488
 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:529
 kmem_cache_alloc_trace+0x158/0x790 mm/slab.c:3551
 kmalloc include/linux/slab.h:555 [inline]
 kzalloc include/linux/slab.h:669 [inline]
 vc_allocate drivers/tty/vt/vt.c:1096 [inline]
 vc_allocate+0x1fc/0x760 drivers/tty/vt/vt.c:1077
 con_install+0x52/0x410 drivers/tty/vt/vt.c:3240
 tty_driver_install_tty drivers/tty/tty_io.c:1228 [inline]
 tty_init_dev drivers/tty/tty_io.c:1341 [inline]
 tty_init_dev+0xf9/0x470 drivers/tty/tty_io.c:1318
 tty_open_by_driver drivers/tty/tty_io.c:1987 [inline]
 tty_open+0x4a5/0xbb0 drivers/tty/tty_io.c:2035
 chrdev_open+0x245/0x6b0 fs/char_dev.c:414
 do_dentry_open+0x4e6/0x1380 fs/open.c:797
 vfs_open+0xa0/0xd0 fs/open.c:914
 do_last fs/namei.c:3490 [inline]
 path_openat+0x12ee/0x3490 fs/namei.c:3607
 do_filp_open+0x192/0x260 fs/namei.c:3637
 do_sys_openat2+0x5eb/0x7e0 fs/open.c:1149
 do_sys_open+0xf2/0x180 fs/open.c:1165
 ksys_open include/linux/syscalls.h:1386 [inline]
 __do_sys_open fs/open.c:1171 [inline]
 __se_sys_open fs/open.c:1169 [inline]
 __x64_sys_open+0x7e/0xc0 fs/open.c:1169
 do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 10658:
 save_stack+0x23/0x90 mm/kasan/common.c:72
 set_track mm/kasan/common.c:80 [inline]
 kasan_set_free_info mm/kasan/common.c:337 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/common.c:476
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:485
 __cache_free mm/slab.c:3426 [inline]
 kfree+0x10a/0x2c0 mm/slab.c:3757
 vt_disallocate_all+0x2bd/0x3e0 drivers/tty/vt/vt_ioctl.c:323
 vt_ioctl+0xc38/0x26c0 drivers/tty/vt/vt_ioctl.c:816
 tty_ioctl+0xa37/0x14f0 drivers/tty/tty_io.c:2660
 vfs_ioctl fs/ioctl.c:47 [inline]
 ksys_ioctl+0x123/0x180 fs/ioctl.c:763
 __do_sys_ioctl fs/ioctl.c:772 [inline]
 __se_sys_ioctl fs/ioctl.c:770 [inline]
 __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:770
 do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff888092f37000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 8 bytes inside of
 2048-byte region [ffff888092f37000, ffff888092f37800)
The buggy address belongs to the page:
page:ffffea00024bcdc0 refcount:1 mapcount:0 mapping:ffff8880aa400e00 index:0x0
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffffea0002a265c8 ffffea000245e488 ffff8880aa400e00
raw: 0000000000000000 ffff888092f37000 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff888092f36f00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff888092f36f80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff888092f37000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                      ^
 ffff888092f37080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888092f37100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (16):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/03/05 16:29 upstream 63623fd44972 c88c7b75 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2020/01/09 22:24 upstream b07f636fca1c 4de4e9f0 .config console log report syz C ci-upstream-kasan-gce-root
2019/12/10 16:24 upstream 6794862a16ef 5a5826a1 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2019/12/10 10:43 upstream 6794862a16ef 4b83c8fb .config console log report syz C ci-upstream-kasan-gce-root
2019/12/10 10:15 upstream 6794862a16ef 4b83c8fb .config console log report syz C ci-upstream-kasan-gce
2019/12/09 19:29 upstream e42617b825f8 b31eda3d .config console log report syz C ci-upstream-kasan-gce-root
2019/12/06 14:44 upstream b0d4beaa5a4b 98b4ef2d .config console log report syz C ci-upstream-kasan-gce-selinux-root
2019/12/12 14:57 upstream 687dec9b9459 d973f528 .config console log report syz C ci-upstream-kasan-gce-386
2019/12/07 03:51 upstream 7ada90eb9c7a 85f26751 .config console log report syz C ci-upstream-kasan-gce-386
2019/12/23 01:21 linux-next 7ddd09fc4b74 8b967267 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2019/12/22 20:09 linux-next 7ddd09fc4b74 8b967267 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2019/12/18 06:31 linux-next fca4fe890ea0 a6bc9c88 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2019/12/23 10:42 linux-next 7ddd09fc4b74 8b967267 .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/02/05 16:57 upstream 6992ca0dd017 662cf49a .config console log report ci-upstream-kasan-gce-selinux-root
2020/01/30 17:55 upstream 39bed42de2e7 5ed23f9a .config console log report ci-upstream-kasan-gce-selinux-root
2020/01/06 05:13 upstream c79f46a28239 438e1227 .config console log report ci-upstream-kasan-gce-root
* Struck through repros no longer work on HEAD.