syzbot


inconsistent lock state in p9_req_put

Status: upstream: reported on 2022/08/15 22:24
Reported-by: syzbot+2f20b523930c32c160cc@syzkaller.appspotmail.com
Fix commit: net/9p: use a dedicated spinlock for trans_fd
Patched on: [], missing on: [ci-qemu-upstream ci-qemu-upstream-386 ci-qemu2-arm32 ci-qemu2-arm64 ci-qemu2-arm64-compat ci-qemu2-arm64-mte ci-qemu2-riscv64 ci-upstream-bpf-kasan-gce ci-upstream-bpf-next-kasan-gce ci-upstream-gce-arm64 ci-upstream-gce-leak ci-upstream-kasan-gce ci-upstream-kasan-gce-386 ci-upstream-kasan-gce-root ci-upstream-kasan-gce-selinux-root ci-upstream-kasan-gce-smack-root ci-upstream-kmsan-gce ci-upstream-kmsan-gce-386 ci-upstream-linux-next-kasan-gce-root ci-upstream-net-kasan-gce ci-upstream-net-this-kasan-gce ci2-upstream-fs ci2-upstream-kcsan-gce ci2-upstream-usb]
First crash: 53d, last: 1d05h

Sample crash report:
================================
WARNING: inconsistent lock state
6.0.0-rc7-syzkaller-00239-gb357fd1c2afc #0 Not tainted
--------------------------------
inconsistent {HARDIRQ-ON-W} -> {IN-HARDIRQ-W} usage.
modprobe/10380 [HC1[1]:SC1[1]:HE0:SE0] takes:
ffff888025a1e818 (&clnt->lock){?.+.}-{2:2}, at: p9_tag_remove net/9p/client.c:367 [inline]
ffff888025a1e818 (&clnt->lock){?.+.}-{2:2}, at: p9_req_put net/9p/client.c:375 [inline]
ffff888025a1e818 (&clnt->lock){?.+.}-{2:2}, at: p9_req_put+0xc6/0x250 net/9p/client.c:372
{HARDIRQ-ON-W} state was registered at:
  lock_acquire kernel/locking/lockdep.c:5666 [inline]
  lock_acquire+0x1ab/0x570 kernel/locking/lockdep.c:5631
  __raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
  _raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:154
  spin_lock include/linux/spinlock.h:349 [inline]
  p9_fd_request+0x85/0x330 net/9p/trans_fd.c:672
  p9_client_rpc+0x2f0/0xce0 net/9p/client.c:660
  p9_client_version net/9p/client.c:880 [inline]
  p9_client_create+0xaec/0x1070 net/9p/client.c:985
  v9fs_session_init+0x1e2/0x1810 fs/9p/v9fs.c:408
  v9fs_mount+0xba/0xc90 fs/9p/vfs_super.c:126
  legacy_get_tree+0x105/0x220 fs/fs_context.c:610
  vfs_get_tree+0x89/0x2f0 fs/super.c:1530
  do_new_mount fs/namespace.c:3040 [inline]
  path_mount+0x1326/0x1e20 fs/namespace.c:3370
  do_mount fs/namespace.c:3383 [inline]
  __do_sys_mount fs/namespace.c:3591 [inline]
  __se_sys_mount fs/namespace.c:3568 [inline]
  __x64_sys_mount+0x27f/0x300 fs/namespace.c:3568
  do_syscall_x64 arch/x86/entry/common.c:50 [inline]
  do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
  entry_SYSCALL_64_after_hwframe+0x63/0xcd
irq event stamp: 3327
hardirqs last  enabled at (3326): [<ffffffff89c00190>] __do_softirq+0x190/0x9c6 kernel/softirq.c:555
hardirqs last disabled at (3327): [<ffffffff897fc711>] common_interrupt+0x11/0xc0 arch/x86/kernel/irq.c:240
softirqs last  enabled at (354): [<ffffffff812d46e8>] fpu_reset_fpregs arch/x86/kernel/fpu/core.c:699 [inline]
softirqs last  enabled at (354): [<ffffffff812d46e8>] fpu_flush_thread+0x298/0x3d0 arch/x86/kernel/fpu/core.c:745
softirqs last disabled at (3325): [<ffffffff814840f3>] invoke_softirq kernel/softirq.c:445 [inline]
softirqs last disabled at (3325): [<ffffffff814840f3>] __irq_exit_rcu+0x123/0x180 kernel/softirq.c:650

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(&clnt->lock);
  <Interrupt>
    lock(&clnt->lock);

 *** DEADLOCK ***

2 locks held by modprobe/10380:
 #0: ffff88801a890868 (&mm->mmap_lock#2){++++}-{3:3}, at: mmap_write_lock_killable include/linux/mmap_lock.h:87 [inline]
 #0: ffff88801a890868 (&mm->mmap_lock#2){++++}-{3:3}, at: vm_mmap_pgoff+0x155/0x270 mm/util.c:550
 #1: ffff888022b64020 (&chan->lock#2){-.-.}-{2:2}, at: req_done+0xcf/0x2e0 net/9p/trans_virtio.c:139

stack backtrace:
CPU: 0 PID: 10380 Comm: modprobe Not tainted 6.0.0-rc7-syzkaller-00239-gb357fd1c2afc #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014
Call Trace:
 <IRQ>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_usage_bug kernel/locking/lockdep.c:3961 [inline]
 valid_state kernel/locking/lockdep.c:3973 [inline]
 mark_lock_irq kernel/locking/lockdep.c:4176 [inline]
 mark_lock.part.0.cold+0x18/0xd8 kernel/locking/lockdep.c:4632
 mark_lock kernel/locking/lockdep.c:4596 [inline]
 mark_usage kernel/locking/lockdep.c:4524 [inline]
 __lock_acquire+0x14a2/0x56d0 kernel/locking/lockdep.c:5007
 lock_acquire kernel/locking/lockdep.c:5666 [inline]
 lock_acquire+0x1ab/0x570 kernel/locking/lockdep.c:5631
 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
 _raw_spin_lock_irqsave+0x39/0x50 kernel/locking/spinlock.c:162
 p9_tag_remove net/9p/client.c:367 [inline]
 p9_req_put net/9p/client.c:375 [inline]
 p9_req_put+0xc6/0x250 net/9p/client.c:372
 req_done+0x1de/0x2e0 net/9p/trans_virtio.c:148
 vring_interrupt drivers/virtio/virtio_ring.c:2462 [inline]
 vring_interrupt+0x29d/0x3d0 drivers/virtio/virtio_ring.c:2437
 __handle_irq_event_percpu+0x227/0x870 kernel/irq/handle.c:158
 handle_irq_event_percpu kernel/irq/handle.c:193 [inline]
 handle_irq_event+0xa7/0x1e0 kernel/irq/handle.c:210
 handle_edge_irq+0x25f/0xd00 kernel/irq/chip.c:819
 generic_handle_irq_desc include/linux/irqdesc.h:158 [inline]
 handle_irq arch/x86/kernel/irq.c:231 [inline]
 __common_interrupt+0x9d/0x210 arch/x86/kernel/irq.c:250
 common_interrupt+0x4d/0xc0 arch/x86/kernel/irq.c:240
 asm_common_interrupt+0x22/0x40 arch/x86/include/asm/idtentry.h:640
RIP: 0010:__do_softirq+0x196/0x9c6 kernel/softirq.c:557
Code: 00 48 01 f0 48 89 44 24 18 48 c7 c7 40 43 eb 89 e8 3f 17 c0 ff 65 66 c7 05 35 94 43 76 00 00 e8 f0 ac c1 f7 fb b8 ff ff ff ff <48> c7 c3 c0 a0 c0 8b 41 0f bc c5 41 89 c7 41 83 c7 01 0f 85 ad 00
RSP: 0018:ffffc90000007f70 EFLAGS: 00000202
RAX: 00000000ffffffff RBX: ffff8880124aa200 RCX: 1ffffffff211eb2e
RDX: 0000000000000000 RSI: 0000000000000100 RDI: 0000000000000000
RBP: ffff8880125221c0 R08: 0000000000000001 R09: ffffffff908e1977
R10: 0000000000000001 R11: 0000000000000001 R12: 0000000000000000
R13: 0000000000000280 R14: 0000000000000000 R15: 0000000000000000
 invoke_softirq kernel/softirq.c:445 [inline]
 __irq_exit_rcu+0x123/0x180 kernel/softirq.c:650
 irq_exit_rcu+0x5/0x20 kernel/softirq.c:662
 sysvec_apic_timer_interrupt+0x93/0xc0 arch/x86/kernel/apic/apic.c:1106
 </IRQ>
 <TASK>
 asm_sysvec_apic_timer_interrupt+0x16/0x20 arch/x86/include/asm/idtentry.h:649
RIP: 0010:lock_release+0x3f1/0x780 kernel/locking/lockdep.c:5674
Code: 7e 83 f8 01 0f 85 cb 01 00 00 9c 58 f6 c4 02 0f 85 b6 01 00 00 48 f7 04 24 00 02 00 00 74 01 fb 48 b8 00 00 00 00 00 fc ff df <48> 01 c5 48 c7 45 00 00 00 00 00 c7 45 08 00 00 00 00 48 8b 84 24
RSP: 0018:ffffc900035b78b0 EFLAGS: 00000206
RAX: dffffc0000000000 RBX: 3feb250a82636bc7 RCX: ffffc900035b7900
RDX: 1ffff1100249558d RSI: 0000000000000000 RDI: 0000000000000000
RBP: 1ffff920006b6f18 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000000 R12: 0000000000000001
R13: 0000000000000002 R14: ffff8880124aac70 R15: ffff8880124aa200
 up_read+0x12/0x20 kernel/locking/rwsem.c:1594
 anon_vma_unlock_read include/linux/rmap.h:141 [inline]
 validate_mm+0x142/0x800 mm/mmap.c:366
 __vma_adjust+0x1097/0x24a0 mm/mmap.c:980
 vma_adjust include/linux/mm.h:2584 [inline]
 __split_vma+0x467/0x550 mm/mmap.c:2714
 __do_munmap+0xd03/0x10b0 mm/mmap.c:2808
 do_munmap mm/mmap.c:2847 [inline]
 munmap_vma_range mm/mmap.c:562 [inline]
 mmap_region+0x1d8/0x1460 mm/mmap.c:1707
 do_mmap+0x863/0xfa0 mm/mmap.c:1540
 vm_mmap_pgoff+0x1ab/0x270 mm/util.c:552
 ksys_mmap_pgoff+0x41b/0x5a0 mm/mmap.c:1586
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f5987e2e1f2
Code: 04 00 00 5b 5d 41 5c c3 41 f7 c1 ff 0f 00 00 75 27 55 48 89 fd 53 89 cb 48 85 ff 74 33 41 89 da 48 89 ef b8 09 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 56 5b 5d c3 0f 1f 00 c7 05 9e 1f 01 00 16 00
RSP: 002b:00007ffd64bab768 EFLAGS: 00000206 ORIG_RAX: 0000000000000009
RAX: ffffffffffffffda RBX: 0000000000000812 RCX: 00007f5987e2e1f2
RDX: 0000000000000005 RSI: 0000000000014000 RDI: 00007f5987b50000
RBP: 00007f5987b50000 R08: 0000000000000000 R09: 0000000000007000
R10: 0000000000000812 R11: 0000000000000206 R12: 00007ffd64bab780
R13: 00007ffd64bab7b0 R14: 0000000000000005 R15: 00007f5987e0cf00
 </TASK>
----------------
Code disassembly (best guess):
   0:	00 48 01             	add    %cl,0x1(%rax)
   3:	f0 48 89 44 24 18    	lock mov %rax,0x18(%rsp)
   9:	48 c7 c7 40 43 eb 89 	mov    $0xffffffff89eb4340,%rdi
  10:	e8 3f 17 c0 ff       	callq  0xffc01754
  15:	65 66 c7 05 35 94 43 	movw   $0x0,%gs:0x76439435(%rip)        # 0x76439454
  1c:	76 00 00
  1f:	e8 f0 ac c1 f7       	callq  0xf7c1ad14
  24:	fb                   	sti
  25:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
* 2a:	48 c7 c3 c0 a0 c0 8b 	mov    $0xffffffff8bc0a0c0,%rbx <-- trapping instruction
  31:	41 0f bc c5          	bsf    %r13d,%eax
  35:	41 89 c7             	mov    %eax,%r15d
  38:	41 83 c7 01          	add    $0x1,%r15d
  3c:	0f                   	.byte 0xf
  3d:	85                   	.byte 0x85
  3e:	ad                   	lods   %ds:(%rsi),%eax

Crashes (179):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-qemu-upstream 2022/10/01 20:16 upstream b357fd1c2afc feb56351 .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream 2022/09/28 14:57 upstream 49c13ed0316d e2556bc3 .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream 2022/09/26 00:14 upstream f76349cf4145 0042f2b4 .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream 2022/09/25 10:47 upstream 105a36f3694e 0042f2b4 .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream 2022/09/24 20:42 upstream 1a61b828566f 0042f2b4 .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream 2022/09/23 04:42 upstream bf682942cd26 0042f2b4 .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream 2022/09/20 21:47 upstream 60891ec99e14 c4b8ccfd .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream 2022/09/20 07:52 upstream 521a547ced64 7c41a9ba .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream 2022/09/19 10:46 upstream 521a547ced64 dd9a85ff .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream 2022/09/19 00:10 upstream 38eddeedbbea dd9a85ff .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream 2022/09/18 22:31 upstream 38eddeedbbea dd9a85ff .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream 2022/09/18 18:11 upstream 38eddeedbbea dd9a85ff .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream 2022/09/17 09:02 upstream a335366bad13 dd9a85ff .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream 2022/09/17 04:30 upstream a335366bad13 dd9a85ff .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream 2022/09/16 18:41 upstream 6879c2d3b960 dd9a85ff .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream 2022/09/13 21:51 upstream d1221cea11fc b884348d .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream 2022/09/12 06:51 upstream 4ed9c1e971b1 356d8217 .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream 2022/09/10 11:28 upstream ce888220d5c7 356d8217 .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream 2022/09/08 12:56 upstream 0066f1b0e275 f3027468 .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream 2022/09/06 10:18 upstream 53e99dcff61e 65aea2b9 .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream 2022/09/04 20:13 upstream 7726d4c3e60b 28811d0a .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream 2022/08/14 01:22 upstream f6eb0fed6a39 8dfcaa3d .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream 2022/08/11 22:17 upstream 7ebfc85e2cd7 21724cb2 .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream-386 2022/10/02 18:54 upstream a962b54e162c feb56351 .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream-386 2022/10/01 17:45 upstream b357fd1c2afc feb56351 .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream-386 2022/09/30 15:38 upstream 987a926c1d8a 5e8ac358 .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream-386 2022/09/28 23:37 upstream c3e0e1e23c70 a41a2080 .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream-386 2022/09/28 06:52 upstream 46452d3786a8 75c78242 .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream-386 2022/09/26 21:44 upstream f76349cf4145 10323ddf .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream-386 2022/09/25 22:48 upstream 5e049663f678 0042f2b4 .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream-386 2022/09/25 16:37 upstream 5e049663f678 0042f2b4 .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream-386 2022/09/25 03:05 upstream 1a61b828566f 0042f2b4 .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream-386 2022/09/21 21:26 upstream 06f7db949993 380f82fb .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream-386 2022/09/21 18:39 upstream 06f7db949993 380f82fb .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream-386 2022/09/21 16:26 upstream 60891ec99e14 380f82fb .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream-386 2022/09/21 14:24 upstream 60891ec99e14 380f82fb .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream-386 2022/09/16 16:11 upstream 6879c2d3b960 dd9a85ff .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream-386 2022/09/15 08:22 upstream 3245cb65fd91 dd9a85ff .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream-386 2022/09/14 13:37 upstream 3245cb65fd91 b884348d .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream-386 2022/09/13 08:23 upstream e839a756012b a08652b0 .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream-386 2022/09/12 18:48 upstream 80e78fcce86d f371ed7e .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream-386 2022/09/12 15:12 upstream 80e78fcce86d 356d8217 .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream-386 2022/09/11 23:11 upstream 4ed9c1e971b1 356d8217 .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream-386 2022/09/09 03:45 upstream 506357871c18 f3027468 .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream-386 2022/09/08 11:16 upstream 0066f1b0e275 f3027468 .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream-386 2022/09/07 16:04 upstream 0066f1b0e275 c5b7bc57 .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream-386 2022/09/07 10:54 upstream 0066f1b0e275 5fc30c37 .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream-386 2022/09/05 22:10 upstream 7e18e42e4b28 9dcd38fc .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream-386 2022/09/05 10:01 upstream 7e18e42e4b28 922294ab .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream-386 2022/09/05 08:46 upstream 7e18e42e4b28 28811d0a .config log report info inconsistent lock state in p9_req_put
ci-qemu-upstream-386 2022/09/05 06:26 upstream 7e18e42e4b28 28811d0a .config log report info inconsistent lock state in p9_req_put
* Struck through repros no longer work on HEAD.