syzbot


WARNING: bad unlock balance in ucma_destroy_id

Status: upstream: reported C repro on 2019/06/27 11:05
Reported-by: syzbot+bab3ddce7ee3bc34ccd4@syzkaller.appspotmail.com
First crash: 1192d, last: 22d

Fix bisection: failed (bisect log)
similar bugs (2):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream WARNING: bad unlock balance in ucma_destroy_id syz done 44 941d 1495d 17/24 fixed on 2020/05/10 10:42
linux-4.14 WARNING: bad unlock balance in ucma_destroy_id C inconclusive 9 22d 1188d 0/1 upstream: reported C repro on 2019/07/01 17:24

Sample crash report:
wlan1: Created IBSS using preconfigured BSSID 50:50:50:50:50:50
IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
wlan1: Creating new IBSS network, BSSID 50:50:50:50:50:50
IPv6: ADDRCONF(NETDEV_CHANGE): wlan1: link becomes ready
=====================================
WARNING: bad unlock balance detected!
4.19.211-syzkaller #0 Not tainted
-------------------------------------
syz-executor174/8344 is trying to release lock (&file->mut) at:
[<ffffffff85f61bf1>] ucma_destroy_id+0x221/0x4a0 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-executor174/8344:
 #0: 0000000063535aa8 (&file->mut){+.+.}, at: ucma_destroy_id+0x1c2/0x4a0 drivers/infiniband/core/ucma.c:629

stack backtrace:
CPU: 1 PID: 8344 Comm: syz-executor174 Not tainted 4.19.211-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/26/2022
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x1fc/0x2ef lib/dump_stack.c:118
 print_unlock_imbalance_bug kernel/locking/lockdep.c:149 [inline]
 __lock_release kernel/locking/lockdep.c:3679 [inline]
 lock_release.cold+0xe/0x4a kernel/locking/lockdep.c:3927
 __mutex_unlock_slowpath+0x89/0x610 kernel/locking/mutex.c:1203
 ucma_destroy_id+0x221/0x4a0 drivers/infiniband/core/ucma.c:631
 ucma_write+0x288/0x350 drivers/infiniband/core/ucma.c:1738
 __vfs_write+0xf7/0x770 fs/read_write.c:485
 vfs_write+0x1f3/0x540 fs/read_write.c:549
 ksys_write+0x12b/0x2a0 fs/read_write.c:599
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7f2dc0aec3d9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 91 18 00 00 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 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f2dc026f208 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f2dc0b6f4b8 RCX: 00007f2dc0aec3d9
RDX: 0000000000000018 RSI: 0000000020000180 RDI: 0000000000000003
RBP: 00007f2dc0b6f4b0 R08: 00007f2dc026f700 R09: 0000000000000000
R10: 00007f2dc026f700 R11: 0000000000000246 R12: 00007f2dc0b6f4bc
R13: 00007ffc5999ab5f R14: 00007f2dc026f300 R15: 0000000000022000
==================================================================
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+0x96/0x610 kernel/locking/mutex.c:1212
Read of size 8 at addr ffff8880b49faac0 by task syz-executor174/8344

CPU: 1 PID: 8344 Comm: syz-executor174 Not tainted 4.19.211-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/26/2022
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x1fc/0x2ef lib/dump_stack.c:118
 print_address_description.cold+0x54/0x219 mm/kasan/report.c:256
 kasan_report_error.cold+0x8a/0x1b9 mm/kasan/report.c:354
 kasan_report+0x8f/0xa0 mm/kasan/report.c:412
 atomic64_read include/asm-generic/atomic-instrumented.h:27 [inline]
 atomic_long_read include/asm-generic/atomic-long.h:47 [inline]
 __mutex_unlock_slowpath+0x96/0x610 kernel/locking/mutex.c:1212
 ucma_destroy_id+0x221/0x4a0 drivers/infiniband/core/ucma.c:631
 ucma_write+0x288/0x350 drivers/infiniband/core/ucma.c:1738
 __vfs_write+0xf7/0x770 fs/read_write.c:485
 vfs_write+0x1f3/0x540 fs/read_write.c:549
 ksys_write+0x12b/0x2a0 fs/read_write.c:599
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7f2dc0aec3d9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 91 18 00 00 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 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f2dc026f208 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f2dc0b6f4b8 RCX: 00007f2dc0aec3d9
RDX: 0000000000000018 RSI: 0000000020000180 RDI: 0000000000000003
RBP: 00007f2dc0b6f4b0 R08: 00007f2dc026f700 R09: 0000000000000000
R10: 00007f2dc026f700 R11: 0000000000000246 R12: 00007f2dc0b6f4bc
R13: 00007ffc5999ab5f R14: 00007f2dc026f300 R15: 0000000000022000

Allocated by task 8341:
 kmem_cache_alloc_trace+0x12f/0x380 mm/slab.c:3625
 kmalloc include/linux/slab.h:515 [inline]
 ucma_open+0x4a/0x280 drivers/infiniband/core/ucma.c:1770
 misc_open+0x372/0x4a0 drivers/char/misc.c:141
 chrdev_open+0x266/0x770 fs/char_dev.c:423
 do_dentry_open+0x4aa/0x1160 fs/open.c:796
 do_last fs/namei.c:3421 [inline]
 path_openat+0x793/0x2df0 fs/namei.c:3537
 do_filp_open+0x18c/0x3f0 fs/namei.c:3567
 do_sys_open+0x3b3/0x520 fs/open.c:1085
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 8082:
 __cache_free mm/slab.c:3503 [inline]
 kfree+0xcc/0x210 mm/slab.c:3822
 ucma_close+0x2cf/0x360 drivers/infiniband/core/ucma.c:1829
 __fput+0x2ce/0x890 fs/file_table.c:278
 task_work_run+0x148/0x1c0 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:193 [inline]
 exit_to_usermode_loop+0x251/0x2a0 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+0x538/0x620 arch/x86/entry/common.c:296
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8880b49faac0
 which belongs to the cache kmalloc-256 of size 256
The buggy address is located 0 bytes inside of
 256-byte region [ffff8880b49faac0, ffff8880b49fabc0)
The buggy address belongs to the page:
page:ffffea0002d27e80 count:1 mapcount:0 mapping:ffff88813bff07c0 index:0x0
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffffea0002bfbd48 ffffea0002d37888 ffff88813bff07c0
raw: 0000000000000000 ffff8880b49fa0c0 000000010000000c 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880b49fa980: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff8880b49faa00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fc
>ffff8880b49faa80: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
                                           ^
 ffff8880b49fab00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880b49fab80: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================

Crashes (6):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci2-linux-4-19 2022/09/09 05:09 linux-4.19.y 3f8a27f9e27b f3027468 .config log report syz C WARNING: bad unlock balance in ucma_destroy_id
ci2-linux-4-19 2021/01/28 14:32 linux-4.19.y c4ff839de17f eefc07f2 .config log report syz WARNING: bad unlock balance in ucma_destroy_id
ci2-linux-4-19 2020/02/18 11:08 linux-4.19.y 9b15f7fae677 1ce142dc .config log report syz
ci2-linux-4-19 2019/11/29 23:00 linux-4.19.y 14260788bbb9 4f7e1d0f .config log report syz
ci2-linux-4-19 2019/06/27 10:48 linux-4.19.y aec3002d07fd 7509bf36 .config log report syz
ci2-linux-4-19 2019/06/27 10:04 linux-4.19.y aec3002d07fd 7509bf36 .config log report
* Struck through repros no longer work on HEAD.