bisecting fixing commit since 14260788bbb9c94b0e36abc17294266b69dd46e4 building syzkaller on 4f7e1d0f5e1c44e2298738f690dde25c486cc65a testing commit 14260788bbb9c94b0e36abc17294266b69dd46e4 with gcc (GCC) 8.1.0 kernel signature: 34a5ba0d74498cfc7fe6131f2f2c97aac4392e7a2bbacc5ae3056011124cb7b9 all runs: crashed: WARNING: bad unlock balance in ucma_destroy_id testing current HEAD 88d6de67e390b6093f2c11189ad022988a9e2961 testing commit 88d6de67e390b6093f2c11189ad022988a9e2961 with gcc (GCC) 8.1.0 kernel signature: df2d396fbb8773900fb03c3dc6e0aa7658e629027d46dd2e21959f58cf07b054 all runs: crashed: WARNING: bad unlock balance in ucma_destroy_id revisions tested: 2, total time: 26m20.021634742s (build: 18m12.864133599s, test: 7m31.487407114s) the crash still happens on HEAD commit msg: Linux 4.19.99 crash: WARNING: bad unlock balance in ucma_destroy_id ===================================== WARNING: bad unlock balance detected! 4.19.99-syzkaller #0 Not tainted ------------------------------------- syz-executor.2/20316 is trying to release lock (&file->mut) at: [] ucma_destroy_id+0x240/0x400 drivers/infiniband/core/ucma.c:628 but there are no more locks to release! other info that might help us debug this: 1 lock held by syz-executor.2/20316: #0: 00000000d0eb5230 (&file->mut){+.+.}, at: ucma_destroy_id+0x1e0/0x400 drivers/infiniband/core/ucma.c:626 stack backtrace: CPU: 0 PID: 20316 Comm: syz-executor.2 Not tainted 4.19.99-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:3464 __lock_release kernel/locking/lockdep.c:3674 [inline] lock_release+0x685/0x850 kernel/locking/lockdep.c:3922 __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:628 ucma_write+0x203/0x2d0 drivers/infiniband/core/ucma.c:1689 __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:0x45a679 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:00007f29c6844c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 000000000045a679 RDX: 0000000000000018 RSI: 0000000020000140 RDI: 0000000000000003 RBP: 000000000075bfc8 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00007f29c68456d4 R13: 00000000004d2b20 R14: 00000000004e3ba8 R15: 00000000ffffffff ================================================================== BUG: KASAN: use-after-free in ucma_destroy_id+0x3ce/0x400 drivers/infiniband/core/ucma.c:630 Read of size 8 at addr ffff88809b9a5328 by task syz-executor.2/20316 CPU: 0 PID: 20316 Comm: syz-executor.2 Not tainted 4.19.99-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 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433 ucma_destroy_id+0x3ce/0x400 drivers/infiniband/core/ucma.c:630 ucma_write+0x203/0x2d0 drivers/infiniband/core/ucma.c:1689 __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:0x45a679 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:00007f29c6844c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 000000000045a679 RDX: 0000000000000018 RSI: 0000000020000140 RDI: 0000000000000003 RBP: 000000000075bfc8 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00007f29c68456d4 R13: 00000000004d2b20 R14: 00000000004e3ba8 R15: 00000000ffffffff Allocated by task 20316: 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] kzalloc include/linux/slab.h:709 [inline] ucma_alloc_ctx+0x4c/0x490 drivers/infiniband/core/ucma.c:209 ucma_create_id+0xeb/0x560 drivers/infiniband/core/ucma.c:500 ucma_write+0x203/0x2d0 drivers/infiniband/core/ucma.c:1689 __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 Freed by task 20302: 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_free_ctx+0x750/0xcd0 drivers/infiniband/core/ucma.c:599 ucma_close+0x109/0x2e0 drivers/infiniband/core/ucma.c:1775 __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 ffff88809b9a52c0 which belongs to the cache kmalloc-256 of size 256 The buggy address is located 104 bytes inside of 256-byte region [ffff88809b9a52c0, ffff88809b9a53c0) The buggy address belongs to the page: page:ffffea00026e6940 count:1 mapcount:0 mapping:ffff88812c31c7c0 index:0x0 flags: 0xfffe0000000100(slab) raw: 00fffe0000000100 ffffea0002693708 ffffea0001f7ae08 ffff88812c31c7c0 raw: 0000000000000000 ffff88809b9a5040 000000010000000c 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88809b9a5200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88809b9a5280: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb >ffff88809b9a5300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88809b9a5380: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ffff88809b9a5400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================