syzbot


KASAN: use-after-free Read in alloc_workqueue

Status: fixed on 2019/03/28 12:00
Subsystems: rdma
[Documentation on labels]
Reported-by: syzbot+17335689e239ce135d8b@syzkaller.appspotmail.com
Fix commit: 009bb421b6ce workqueue, lockdep: Fix an alloc_workqueue() error path
First crash: 2054d, last: 2041d
Discussions (3)
Title Replies (including bot) Last reply
[PATCH] kernel/wq: Fix a alloc_workqueue() error path 3 (3) 2019/03/09 14:42
[PATCH] workqueue: unregister wq lockdep on error path in alloc_workqueue() 3 (3) 2019/03/09 04:13
KASAN: use-after-free Read in alloc_workqueue 1 (2) 2019/03/03 21:38
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: slab-use-after-free Read in alloc_workqueue kvm 510 565d 565d 0/28 auto-obsoleted due to no activity on 2023/05/10 04:54

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __read_once_size include/linux/compiler.h:197 [inline]
BUG: KASAN: use-after-free in lockdep_register_key+0x3b9/0x490 kernel/locking/lockdep.c:1023
Read of size 8 at addr ffff888090fc2698 by task syz-executor134/7858

CPU: 1 PID: 7858 Comm: syz-executor134 Not tainted 5.0.0-rc8-next-20190301 #1
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+0x172/0x1f0 lib/dump_stack.c:113
 print_address_description.cold+0x7c/0x20d mm/kasan/report.c:187
 kasan_report.cold+0x1b/0x40 mm/kasan/report.c:317
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:132
 __read_once_size include/linux/compiler.h:197 [inline]
 lockdep_register_key+0x3b9/0x490 kernel/locking/lockdep.c:1023
 wq_init_lockdep kernel/workqueue.c:3444 [inline]
 alloc_workqueue+0x427/0xe70 kernel/workqueue.c:4263
 ucma_open+0x76/0x290 drivers/infiniband/core/ucma.c:1732
 misc_open+0x398/0x4c0 drivers/char/misc.c:141
 chrdev_open+0x247/0x6b0 fs/char_dev.c:417
 do_dentry_open+0x488/0x1160 fs/open.c:771
 vfs_open+0xa0/0xd0 fs/open.c:880
 do_last fs/namei.c:3416 [inline]
 path_openat+0x10e9/0x46e0 fs/namei.c:3533
 do_filp_open+0x1a1/0x280 fs/namei.c:3563
 do_sys_open+0x3fe/0x5d0 fs/open.c:1063
 __do_sys_openat fs/open.c:1090 [inline]
 __se_sys_openat fs/open.c:1084 [inline]
 __x64_sys_openat+0x9d/0x100 fs/open.c:1084
 do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x440fc9
Code: e8 0c ad 02 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 bb 0a fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffc1cccc9c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000440fc9
RDX: 0000000000000002 RSI: 0000000020000140 RDI: ffffffffffffff9c
RBP: 00007ffc1cccc9e0 R08: 0000000000000002 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: ffffffffffffffff
R13: 0000000000000003 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 7789:
 save_stack+0x45/0xd0 mm/kasan/common.c:75
 set_track mm/kasan/common.c:87 [inline]
 __kasan_kmalloc mm/kasan/common.c:497 [inline]
 __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:470
 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:511
 __do_kmalloc mm/slab.c:3726 [inline]
 __kmalloc+0x15c/0x740 mm/slab.c:3735
 kmalloc include/linux/slab.h:553 [inline]
 kzalloc include/linux/slab.h:743 [inline]
 alloc_workqueue+0x13c/0xe70 kernel/workqueue.c:4236
 ucma_open+0x76/0x290 drivers/infiniband/core/ucma.c:1732
 misc_open+0x398/0x4c0 drivers/char/misc.c:141
 chrdev_open+0x247/0x6b0 fs/char_dev.c:417
 do_dentry_open+0x488/0x1160 fs/open.c:771
 vfs_open+0xa0/0xd0 fs/open.c:880
 do_last fs/namei.c:3416 [inline]
 path_openat+0x10e9/0x46e0 fs/namei.c:3533
 do_filp_open+0x1a1/0x280 fs/namei.c:3563
 do_sys_open+0x3fe/0x5d0 fs/open.c:1063
 __do_sys_openat fs/open.c:1090 [inline]
 __se_sys_openat fs/open.c:1084 [inline]
 __x64_sys_openat+0x9d/0x100 fs/open.c:1084
 do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 7789:
 save_stack+0x45/0xd0 mm/kasan/common.c:75
 set_track mm/kasan/common.c:87 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/common.c:459
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:467
 __cache_free mm/slab.c:3498 [inline]
 kfree+0xcf/0x230 mm/slab.c:3821
 alloc_workqueue+0xc3e/0xe70 kernel/workqueue.c:4295
 ucma_open+0x76/0x290 drivers/infiniband/core/ucma.c:1732
 misc_open+0x398/0x4c0 drivers/char/misc.c:141
 chrdev_open+0x247/0x6b0 fs/char_dev.c:417
 do_dentry_open+0x488/0x1160 fs/open.c:771
 vfs_open+0xa0/0xd0 fs/open.c:880
 do_last fs/namei.c:3416 [inline]
 path_openat+0x10e9/0x46e0 fs/namei.c:3533
 do_filp_open+0x1a1/0x280 fs/namei.c:3563
 do_sys_open+0x3fe/0x5d0 fs/open.c:1063
 __do_sys_openat fs/open.c:1090 [inline]
 __se_sys_openat fs/open.c:1084 [inline]
 __x64_sys_openat+0x9d/0x100 fs/open.c:1084
 do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff888090fc2580
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 280 bytes inside of
 512-byte region [ffff888090fc2580, ffff888090fc2780)
The buggy address belongs to the page:
page:ffffea000243f080 count:1 mapcount:0 mapping:ffff88812c3f0940 index:0xffff888090fc2300
flags: 0x1fffc0000000200(slab)
raw: 01fffc0000000200 ffffea0002417248 ffffea00024751c8 ffff88812c3f0940
raw: ffff888090fc2300 ffff888090fc2080 0000000100000004 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff888090fc2580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888090fc2600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888090fc2680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                            ^
 ffff888090fc2700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888090fc2780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (37):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/03/02 14:52 linux-next c63e9e91a254 1c0e457a .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2019/03/11 08:03 upstream 065b6c4c913d 12365b99 .config console log report ci-upstream-kasan-gce-smack-root
2019/03/10 23:21 upstream 065b6c4c913d 12365b99 .config console log report ci-upstream-kasan-gce-root
2019/03/10 18:20 upstream 6cdc577a18a6 12365b99 .config console log report ci-upstream-kasan-gce-smack-root
2019/03/10 13:40 upstream 6cdc577a18a6 12365b99 .config console log report ci-upstream-kasan-gce-selinux-root
2019/03/10 13:33 upstream 6cdc577a18a6 12365b99 .config console log report ci-upstream-kasan-gce-root
2019/03/10 07:18 upstream 6cdc577a18a6 12365b99 .config console log report ci-upstream-kasan-gce-root
2019/03/10 04:49 upstream 6cdc577a18a6 12365b99 .config console log report ci-upstream-kasan-gce-selinux-root
2019/03/10 01:20 upstream 38e7571c07be 12365b99 .config console log report ci-upstream-kasan-gce-root
2019/03/09 19:46 upstream 38e7571c07be 12365b99 .config console log report ci-upstream-kasan-gce-smack-root
2019/03/09 16:41 upstream 38e7571c07be 12365b99 .config console log report ci-upstream-kasan-gce-root
2019/03/09 09:45 upstream 3601fe43e816 12365b99 .config console log report ci-upstream-kasan-gce-root
2019/03/09 08:09 upstream 3601fe43e816 12365b99 .config console log report ci-upstream-kasan-gce-smack-root
2019/03/08 05:07 upstream 1fc1cd8399ab 4b69c3cb .config console log report ci-upstream-kasan-gce-selinux-root
2019/03/08 04:30 upstream 1fc1cd8399ab 4b69c3cb .config console log report ci-upstream-kasan-gce-selinux-root
2019/03/08 02:36 upstream 1fc1cd8399ab 4b69c3cb .config console log report ci-upstream-kasan-gce-root
2019/03/08 01:00 upstream 1fc1cd8399ab 4b69c3cb .config console log report ci-upstream-kasan-gce-selinux-root
2019/03/07 14:13 upstream f90d64483ebd 8c085c5e .config console log report ci-upstream-kasan-gce-smack-root
2019/03/07 03:02 upstream afe6fe7036c6 18215b8d .config console log report ci-upstream-kasan-gce-smack-root
2019/03/10 15:32 upstream 6cdc577a18a6 12365b99 .config console log report ci-upstream-kasan-gce-386
2019/03/07 08:22 upstream afe6fe7036c6 18215b8d .config console log report ci-upstream-kasan-gce-386
2019/03/16 01:11 linux-next cf08baa29613 bab43553 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/03/15 17:49 linux-next cf08baa29613 bab43553 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/03/14 08:40 linux-next cf08baa29613 d09a902e .config console log report ci-upstream-linux-next-kasan-gce-root
2019/03/10 15:53 linux-next cf08baa29613 12365b99 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/03/09 13:59 linux-next cf08baa29613 12365b99 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/03/09 00:22 linux-next cf08baa29613 12365b99 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/03/07 17:05 linux-next cf08baa29613 8c085c5e .config console log report ci-upstream-linux-next-kasan-gce-root
2019/03/06 23:50 linux-next cf08baa29613 18215b8d .config console log report ci-upstream-linux-next-kasan-gce-root
2019/03/06 02:00 linux-next baf5a9d1f9b9 16559f86 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/03/05 21:26 linux-next baf5a9d1f9b9 16559f86 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/03/05 02:15 linux-next 5d57915a1c8b 7c693b52 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/03/04 02:34 linux-next c63e9e91a254 1c0e457a .config console log report ci-upstream-linux-next-kasan-gce-root
2019/03/03 05:09 linux-next c63e9e91a254 1c0e457a .config console log report ci-upstream-linux-next-kasan-gce-root
2019/03/02 15:08 linux-next c63e9e91a254 1c0e457a .config console log report ci-upstream-linux-next-kasan-gce-root
2019/03/02 14:47 linux-next c63e9e91a254 1c0e457a .config console log report ci-upstream-linux-next-kasan-gce-root
2019/03/02 13:01 linux-next c63e9e91a254 1c0e457a .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.