Kernel bug: kernel BUG in ocfs2_remove_btree_range (2)
Subsystem: ocfs2
Status: fixed

Crash report:
(syz.0.17,5491,0):ocfs2_truncate_log_needs_flush:5830 ERROR: bug expression: le16_to_cpu(tl->tl_used) > le16_to_cpu(tl->tl_count)
(syz.0.17,5491,0):ocfs2_truncate_log_needs_flush:5830 ERROR: slot 0, invalid truncate log parameters: used = 129, count = 39
------------[ cut here ]------------
kernel BUG at fs/ocfs2/alloc.c:5830!
Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI
CPU: 0 UID: 0 PID: 5491 Comm: syz.0.17 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
RIP: 0010:ocfs2_truncate_log_needs_flush fs/ocfs2/alloc.c:5827 [inline]
RIP: 0010:ocfs2_remove_btree_range+0x152f/0x1540 fs/ocfs2/alloc.c:5752
Code: b7 45 00 4c 89 e7 48 c7 c6 16 10 7e 8d ba c6 16 00 00 48 c7 c1 80 d4 aa 8b 41 89 d8 45 89 f9 50 e8 46 20 1e 00 48 83 c4 08 90 <0f> 0b 66 66 66 66 66 66 2e 0f 1f 84 00 00 00 00 00 90 90 90 90 90
RSP: 0018:ffffc90002b6ecc0 EFLAGS: 00010296
RAX: 1c4f3c72a1dda200 RBX: 0000000000000000 RCX: 1c4f3c72a1dda200
RDX: 0000000000000000 RSI: 0000000080000000 RDI: 0000000000000000
RBP: ffffc90002b6ef98 R08: ffff88801fe24293 R09: 1ffff11003fc4852
R10: dffffc0000000000 R11: ffffed1003fc4853 R12: ffffc90002b6ed80
R13: ffff88804c09fac0 R14: 1ffff11009813f58 R15: 0000000000000081
FS:  000055556b844500(0000) GS:ffff88808d72f000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000557f72160e20 CR3: 0000000059e03000 CR4: 0000000000352ef0
Call Trace:
 <TASK>
 ocfs2_commit_truncate+0xb64/0x21d0 fs/ocfs2/alloc.c:7372
 ocfs2_truncate_file+0xca2/0x1420 fs/ocfs2/file.c:509
 ocfs2_setattr+0x1520/0x1b40 fs/ocfs2/file.c:1212
 notify_change+0xc1a/0xf40 fs/attr.c:546
 do_truncate+0x1a4/0x220 fs/open.c:68
 handle_truncate fs/namei.c:3596 [inline]
 do_open fs/namei.c:3979 [inline]
 path_openat+0x306c/0x3830 fs/namei.c:4134
 do_filp_open+0x1fa/0x410 fs/namei.c:4161
 do_sys_openat2+0x121/0x1c0 fs/open.c:1437
 do_sys_open fs/open.c:1452 [inline]
 __do_sys_openat fs/open.c:1468 [inline]
 __se_sys_openat fs/open.c:1463 [inline]
 __x64_sys_openat+0x138/0x170 fs/open.c:1463
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xfa/0xfa0 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fe596b8f749
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 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 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffe6dee1248 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 00007fe596de5fa0 RCX: 00007fe596b8f749
RDX: 000000000000275a RSI: 0000200000000040 RDI: ffffffffffffff9c
RBP: 00007fe596c13f91 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fe596de5fa0 R14: 00007fe596de5fa0 R15: 0000000000000004
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:ocfs2_truncate_log_needs_flush fs/ocfs2/alloc.c:5827 [inline]
RIP: 0010:ocfs2_remove_btree_range+0x152f/0x1540 fs/ocfs2/alloc.c:5752
Code: b7 45 00 4c 89 e7 48 c7 c6 16 10 7e 8d ba c6 16 00 00 48 c7 c1 80 d4 aa 8b 41 89 d8 45 89 f9 50 e8 46 20 1e 00 48 83 c4 08 90 <0f> 0b 66 66 66 66 66 66 2e 0f 1f 84 00 00 00 00 00 90 90 90 90 90
RSP: 0018:ffffc90002b6ecc0 EFLAGS: 00010296
RAX: 1c4f3c72a1dda200 RBX: 0000000000000000 RCX: 1c4f3c72a1dda200
RDX: 0000000000000000 RSI: 0000000080000000 RDI: 0000000000000000
RBP: ffffc90002b6ef98 R08: ffff88801fe24293 R09: 1ffff11003fc4852
R10: dffffc0000000000 R11: ffffed1003fc4853 R12: ffffc90002b6ed80
R13: ffff88804c09fac0 R14: 1ffff11009813f58 R15: 0000000000000081
FS:  000055556b844500(0000) GS:ffff88808d72f000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000557f7216a138 CR3: 0000000059e03000 CR4: 0000000000352ef0