Kernel bug: divide error in iova_bitmap_alloc
Subsystem: iommu
Status: fixed

Crash report:
Oops: divide error: 0000 [#1] SMP KASAN NOPTI
CPU: 2 UID: 0 PID: 6098 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:iova_bitmap_offset_to_index drivers/iommu/iommufd/iova_bitmap.c:135 [inline]
RIP: 0010:iova_bitmap_alloc+0xe8/0x350 drivers/iommu/iommufd/iova_bitmap.c:259
Code: e8 3d ad 7e fc 48 83 fd 3f 0f 87 c0 8c e9 fb e8 be b1 7e fc 89 e9 b8 08 00 00 00 31 d2 48 d3 e0 48 8d 7b 40 48 89 c1 4c 89 e0 <48> f7 f1 48 ba 00 00 00 00 00 fc ff df 48 89 f9 48 c1 e9 03 48 83
RSP: 0018:ffffc900034ffba8 EFLAGS: 00010246
RAX: ffffffffffffffff RBX: ffff888032636100 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffffffff853dc2d2 RDI: ffff888032636140
RBP: 000000000000003f R08: 0000000000000007 R09: 000000000000003f
R10: 000000000000003f R11: 0000000000000000 R12: ffffffffffffffff
R13: 0000000000000000 R14: 0000000000000000 R15: ffffffff8c065aa0
FS:  000055558b0da500(0000) GS:ffff8880d6bdf000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000001b2f463fff CR3: 000000004ee7c000 CR4: 0000000000352ef0
Call Trace:
 <TASK>
 iommu_read_and_clear_dirty drivers/iommu/iommufd/io_pagetable.c:543 [inline]
 iopt_read_and_clear_dirty_data+0x271/0x4c0 drivers/iommu/iommufd/io_pagetable.c:603
 iommufd_hwpt_get_dirty_bitmap+0x1c3/0x340 drivers/iommu/iommufd/hw_pagetable.c:485
 iommufd_fops_ioctl+0x34d/0x540 drivers/iommu/iommufd/main.c:533
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:597 [inline]
 __se_sys_ioctl fs/ioctl.c:583 [inline]
 __x64_sys_ioctl+0x18b/0x210 fs/ioctl.c:583
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xcd/0xfa0 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f705598eec9
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:00007ffeac4d43a8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f7055be5fa0 RCX: 00007f705598eec9
RDX: 0000200000000300 RSI: 0000000000003b8c RDI: 0000000000000003
RBP: 00007f7055a11f91 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f7055be5fa0 R14: 00007f7055be5fa0 R15: 0000000000000003
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:iova_bitmap_offset_to_index drivers/iommu/iommufd/iova_bitmap.c:135 [inline]
RIP: 0010:iova_bitmap_alloc+0xe8/0x350 drivers/iommu/iommufd/iova_bitmap.c:259
Code: e8 3d ad 7e fc 48 83 fd 3f 0f 87 c0 8c e9 fb e8 be b1 7e fc 89 e9 b8 08 00 00 00 31 d2 48 d3 e0 48 8d 7b 40 48 89 c1 4c 89 e0 <48> f7 f1 48 ba 00 00 00 00 00 fc ff df 48 89 f9 48 c1 e9 03 48 83
RSP: 0018:ffffc900034ffba8 EFLAGS: 00010246
RAX: ffffffffffffffff RBX: ffff888032636100 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffffffff853dc2d2 RDI: ffff888032636140
RBP: 000000000000003f R08: 0000000000000007 R09: 000000000000003f
R10: 000000000000003f R11: 0000000000000000 R12: ffffffffffffffff
R13: 0000000000000000 R14: 0000000000000000 R15: ffffffff8c065aa0
FS:  000055558b0da500(0000) GS:ffff8880d6cdf000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055558b0da808 CR3: 000000004ee7c000 CR4: 0000000000352ef0
----------------
Code disassembly (best guess):
   0:	e8 3d ad 7e fc       	call   0xfc7ead42
   5:	48 83 fd 3f          	cmp    $0x3f,%rbp
   9:	0f 87 c0 8c e9 fb    	ja     0xfbe98ccf
   f:	e8 be b1 7e fc       	call   0xfc7eb1d2
  14:	89 e9                	mov    %ebp,%ecx
  16:	b8 08 00 00 00       	mov    $0x8,%eax
  1b:	31 d2                	xor    %edx,%edx
  1d:	48 d3 e0             	shl    %cl,%rax
  20:	48 8d 7b 40          	lea    0x40(%rbx),%rdi
  24:	48 89 c1             	mov    %rax,%rcx
  27:	4c 89 e0             	mov    %r12,%rax
* 2a:	48 f7 f1             	div    %rcx <-- trapping instruction
  2d:	48 ba 00 00 00 00 00 	movabs $0xdffffc0000000000,%rdx
  34:	fc ff df
  37:	48 89 f9             	mov    %rdi,%rcx
  3a:	48 c1 e9 03          	shr    $0x3,%rcx
  3e:	48                   	rex.W
  3f:	83                   	.byte 0x83