syzbot


WARNING: bad unlock balance in bpf

Status: fixed on 2023/09/28 17:51
Subsystems: bpf
[Documentation on labels]
Reported-by: syzbot+8982e75c2878b9ffeac5@syzkaller.appspotmail.com
Fix commit: 4266f41feaee bpf: Fix bad unlock balance on freeze_mutex
First crash: 508d, last: 507d
Cause bisection: introduced by (bisect log) :
commit c4c84f6fb2c4dc4c0f5fd927b3c3d3fd28b7030e
Author: Andrii Nakryiko <andrii@kernel.org>
Date: Wed May 24 22:54:19 2023 +0000

  bpf: drop unnecessary bpf_capable() check in BPF_MAP_FREEZE command

Crash: WARNING: bad unlock balance in bpf (log)
Repro: C syz .config
  
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [bpf?] WARNING: bad unlock balance in bpf 1 (2) 2023/05/26 12:52
Last patch testing requests (1)
Created Duration User Patch Repo Result
2023/05/26 10:22 24m daniel@iogearbox.net bpf-next OK log

Sample crash report:
=====================================
WARNING: bad unlock balance detected!
6.4.0-rc1-syzkaller-00360-g321a64b32815 #0 Not tainted
-------------------------------------
syz-executor243/5005 is trying to release lock (&map->freeze_mutex) at:
[<ffffffff8193e2c4>] map_freeze kernel/bpf/syscall.c:1951 [inline]
[<ffffffff8193e2c4>] __sys_bpf+0x3234/0x5520 kernel/bpf/syscall.c:5078
but there are no more locks to release!

other info that might help us debug this:
no locks held by syz-executor243/5005.

stack backtrace:
CPU: 1 PID: 5005 Comm: syz-executor243 Not tainted 6.4.0-rc1-syzkaller-00360-g321a64b32815 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/16/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd9/0x150 lib/dump_stack.c:106
 __lock_release kernel/locking/lockdep.c:5368 [inline]
 lock_release+0x4f1/0x670 kernel/locking/lockdep.c:5711
 __mutex_unlock_slowpath+0x99/0x5e0 kernel/locking/mutex.c:907
 map_freeze kernel/bpf/syscall.c:1951 [inline]
 __sys_bpf+0x3234/0x5520 kernel/bpf/syscall.c:5078
 __do_sys_bpf kernel/bpf/syscall.c:5185 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:5183 [inline]
 __x64_sys_bpf+0x79/0xc0 kernel/bpf/syscall.c:5183
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fbcdfaafc59
Code: 28 c3 e8 2a 14 00 00 66 2e 0f 1f 84 00 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 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffee6b4a9c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fbcdfaafc59
RDX: 0000000000000004 RSI: 0000000020000440 RDI: 0000000000000016
RBP: 00007fbcdfa73e00 R08: 00000000000

Crashes (12):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/05/26 11:27 bpf-next 321a64b32815 b40ef614 .config strace log report syz C ci-upstream-bpf-next-kasan-gce WARNING: bad unlock balance in bpf
2023/05/25 23:40 bpf-next c4c84f6fb2c4 0513b3e6 .config strace log report syz C ci-upstream-bpf-next-kasan-gce WARNING: bad unlock balance in bpf
2023/05/26 12:10 bpf-next 321a64b32815 b40ef614 .config console log report info ci-upstream-bpf-next-kasan-gce WARNING: bad unlock balance in bpf
2023/05/26 10:58 bpf-next 321a64b32815 b40ef614 .config console log report info ci-upstream-bpf-next-kasan-gce WARNING: bad unlock balance in bpf
2023/05/26 08:14 bpf-next 321a64b32815 b40ef614 .config console log report info ci-upstream-bpf-next-kasan-gce WARNING: bad unlock balance in bpf
2023/05/26 06:39 bpf-next 321a64b32815 b40ef614 .config console log report info ci-upstream-bpf-next-kasan-gce WARNING: bad unlock balance in bpf
2023/05/26 05:39 bpf-next 321a64b32815 b40ef614 .config console log report info ci-upstream-bpf-next-kasan-gce WARNING: bad unlock balance in bpf
2023/05/26 01:39 bpf-next c4c84f6fb2c4 0513b3e6 .config console log report info ci-upstream-bpf-next-kasan-gce WARNING: bad unlock balance in bpf
2023/05/26 01:19 bpf-next c4c84f6fb2c4 0513b3e6 .config console log report info ci-upstream-bpf-next-kasan-gce WARNING: bad unlock balance in bpf
2023/05/25 22:40 bpf-next c4c84f6fb2c4 0513b3e6 .config console log report info ci-upstream-bpf-next-kasan-gce WARNING: bad unlock balance in bpf
2023/05/25 21:23 bpf-next c4c84f6fb2c4 0513b3e6 .config console log report info ci-upstream-bpf-next-kasan-gce WARNING: bad unlock balance in bpf
2023/05/25 18:39 bpf-next c4c84f6fb2c4 0513b3e6 .config console log report info ci-upstream-bpf-next-kasan-gce WARNING: bad unlock balance in bpf
* Struck through repros no longer work on HEAD.