bisecting fixing commit since 9b15f7fae677336e04b9e026ff91854e43165455 building syzkaller on 1ce142dcc7e25341405592c66bcb7cb0d60d2b3a testing commit 9b15f7fae677336e04b9e026ff91854e43165455 with gcc (GCC) 8.1.0 kernel signature: bb7a753fc044447eaf485f47c0cf09eb723fc64ee85c021e1e15b7a025dbb8b8 all runs: crashed: WARNING: bad unlock balance in ucma_destroy_id testing current HEAD 3fc898571b974f9a05e4e5c1fe17b18548207091 testing commit 3fc898571b974f9a05e4e5c1fe17b18548207091 with gcc (GCC) 8.1.0 kernel signature: 762dcf243aba4452b02f377dfbe6c2f066d5be16c1afcbc5e6f22fa3dbab121e all runs: crashed: WARNING: bad unlock balance in ucma_destroy_id revisions tested: 2, total time: 28m29.599840345s (build: 18m11.794674435s, test: 9m50.892056783s) the crash still happens on HEAD commit msg: Linux 4.19.128 crash: WARNING: bad unlock balance in ucma_destroy_id ===================================== WARNING: bad unlock balance detected! 4.19.128-syzkaller #0 Not tainted ------------------------------------- syz-executor.4/15310 is trying to release lock (&file->mut) at: [] ucma_destroy_id+0x240/0x400 drivers/infiniband/core/ucma.c:631 but there are no more locks to release! other info that might help us debug this: 1 lock held by syz-executor.4/15310: #0: 0000000042350558 (&file->mut){+.+.}, at: ucma_destroy_id+0x1e0/0x400 drivers/infiniband/core/ucma.c:629 stack backtrace: CPU: 0 PID: 15310 Comm: syz-executor.4 Not tainted 4.19.128-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+0x123/0x177 lib/dump_stack.c:118 print_unlock_imbalance_bug.cold.50+0x114/0x123 kernel/locking/lockdep.c:3468 __lock_release kernel/locking/lockdep.c:3678 [inline] lock_release+0x685/0x850 kernel/locking/lockdep.c:3926 __mutex_unlock_slowpath+0x8e/0x6a0 kernel/locking/mutex.c:1197 mutex_unlock+0xd/0x10 kernel/locking/mutex.c:713 ucma_destroy_id+0x240/0x400 drivers/infiniband/core/ucma.c:631 ucma_write+0x203/0x2d0 drivers/infiniband/core/ucma.c:1734 __vfs_write+0xe3/0x890 fs/read_write.c:485 vfs_write+0x150/0x4d0 fs/read_write.c:549 ksys_write+0x103/0x260 fs/read_write.c:599 __do_sys_write fs/read_write.c:611 [inline] __se_sys_write fs/read_write.c:608 [inline] __x64_sys_write+0x6e/0xb0 fs/read_write.c:608 do_syscall_64+0xd0/0x4e0 arch/x86/entry/common.c:293 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x45c6b9 Code: ad b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 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 7b b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 RSP: 002b:00007ff7a08a3c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007ff7a08a46d4 RCX: 000000000045c6b9 RDX: 0000000000000018 RSI: 0000000020001380 RDI: 0000000000000003 RBP: 000000000076bfc0 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff R13: 0000000000000c8a R14: 00000000004d78f0 R15: 000000000076bfcc ================================================================== BUG: KASAN: use-after-free in atomic64_read include/asm-generic/atomic-instrumented.h:27 [inline] BUG: KASAN: use-after-free in atomic_long_read include/asm-generic/atomic-long.h:47 [inline] BUG: KASAN: use-after-free in __mutex_unlock_slowpath+0x9b/0x6a0 kernel/locking/mutex.c:1206 Read of size 8 at addr ffff8880a78137c0 by task syz-executor.4/15310 CPU: 1 PID: 15310 Comm: syz-executor.4 Not tainted 4.19.128-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+0x123/0x177 lib/dump_stack.c:118 print_address_description.cold.8+0x9/0x1ff mm/kasan/report.c:256 kasan_report_error mm/kasan/report.c:354 [inline] kasan_report.cold.9+0x242/0x309 mm/kasan/report.c:412 check_memory_region_inline mm/kasan/kasan.c:260 [inline] check_memory_region+0x13e/0x1b0 mm/kasan/kasan.c:267 kasan_check_read+0x11/0x20 mm/kasan/kasan.c:272 atomic64_read include/asm-generic/atomic-instrumented.h:27 [inline] atomic_long_read include/asm-generic/atomic-long.h:47 [inline] __mutex_unlock_slowpath+0x9b/0x6a0 kernel/locking/mutex.c:1206 mutex_unlock+0xd/0x10 kernel/locking/mutex.c:713 ucma_destroy_id+0x240/0x400 drivers/infiniband/core/ucma.c:631 ucma_write+0x203/0x2d0 drivers/infiniband/core/ucma.c:1734 __vfs_write+0xe3/0x890 fs/read_write.c:485 vfs_write+0x150/0x4d0 fs/read_write.c:549 ksys_write+0x103/0x260 fs/read_write.c:599 __do_sys_write fs/read_write.c:611 [inline] __se_sys_write fs/read_write.c:608 [inline] __x64_sys_write+0x6e/0xb0 fs/read_write.c:608 do_syscall_64+0xd0/0x4e0 arch/x86/entry/common.c:293 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x45c6b9 Code: ad b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 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 7b b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 RSP: 002b:00007ff7a08a3c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007ff7a08a46d4 RCX: 000000000045c6b9 RDX: 0000000000000018 RSI: 0000000020001380 RDI: 0000000000000003 RBP: 000000000076bfc0 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff R13: 0000000000000c8a R14: 00000000004d78f0 R15: 000000000076bfcc Allocated by task 15310: save_stack+0x43/0xd0 mm/kasan/kasan.c:448 set_track mm/kasan/kasan.c:460 [inline] kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:553 kmem_cache_alloc_trace+0x152/0x740 mm/slab.c:3625 kmalloc include/linux/slab.h:515 [inline] ucma_open+0x4d/0x260 drivers/infiniband/core/ucma.c:1766 misc_open+0x31b/0x4d0 drivers/char/misc.c:141 chrdev_open+0x1ed/0x5c0 fs/char_dev.c:423 do_dentry_open+0x3f1/0x1010 fs/open.c:796 vfs_open+0x9a/0xc0 fs/open.c:902 do_last fs/namei.c:3421 [inline] path_openat+0x6fa/0x3c60 fs/namei.c:3537 do_filp_open+0x177/0x250 fs/namei.c:3567 do_sys_open+0x1dd/0x350 fs/open.c:1085 __do_sys_openat fs/open.c:1112 [inline] __se_sys_openat fs/open.c:1106 [inline] __x64_sys_openat+0x98/0xf0 fs/open.c:1106 do_syscall_64+0xd0/0x4e0 arch/x86/entry/common.c:293 entry_SYSCALL_64_after_hwframe+0x49/0xbe Freed by task 15273: save_stack+0x43/0xd0 mm/kasan/kasan.c:448 set_track mm/kasan/kasan.c:460 [inline] __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528 __cache_free mm/slab.c:3503 [inline] kfree+0xcf/0x220 mm/slab.c:3822 ucma_close+0x24d/0x2f0 drivers/infiniband/core/ucma.c:1825 __fput+0x249/0x7f0 fs/file_table.c:278 ____fput+0x9/0x10 fs/file_table.c:309 task_work_run+0x108/0x180 kernel/task_work.c:113 tracehook_notify_resume include/linux/tracehook.h:193 [inline] exit_to_usermode_loop+0x1a9/0x200 arch/x86/entry/common.c:167 prepare_exit_to_usermode arch/x86/entry/common.c:198 [inline] syscall_return_slowpath arch/x86/entry/common.c:271 [inline] do_syscall_64+0x413/0x4e0 arch/x86/entry/common.c:296 entry_SYSCALL_64_after_hwframe+0x49/0xbe The buggy address belongs to the object at ffff8880a78137c0 which belongs to the cache kmalloc-256 of size 256 The buggy address is located 0 bytes inside of 256-byte region [ffff8880a78137c0, ffff8880a78138c0) The buggy address belongs to the page: page:ffffea00029e04c0 count:1 mapcount:0 mapping:ffff88812c29c7c0 index:0x0 flags: 0xfffe0000000100(slab) raw: 00fffe0000000100 ffffea00022835c8 ffffea00026cb248 ffff88812c29c7c0 raw: 0000000000000000 ffff8880a7813040 000000010000000c 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8880a7813680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8880a7813700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff8880a7813780: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb ^ ffff8880a7813800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8880a7813880: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ==================================================================