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: 296ab4a81384 net/9p: use a dedicated spinlock for trans_fd
Patched on: [ci-qemu-upstream ci-qemu-upstream-386 ci-qemu2-arm32 ci-qemu2-arm64 ci-qemu2-arm64-compat ci-qemu2-arm64-mte 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], missing on: [ci-qemu2-riscv64]
First crash: 178d, last: 123d

Sample crash report:
================================
WARNING: inconsistent lock state
6.0.0-syzkaller-00188-gf3dfe925f954 #0 Not tainted
--------------------------------
inconsistent {HARDIRQ-ON-W} -> {IN-HARDIRQ-W} usage.
kworker/u16:1/12 [HC1[1]:SC0[0]:HE0:SE1] takes:
ffff88800f293418 (&clnt->lock){?.+.}-{2:2}, at: p9_tag_remove net/9p/client.c:367 [inline]
ffff88800f293418 (&clnt->lock){?.+.}-{2:2}, at: p9_req_put net/9p/client.c:375 [inline]
ffff88800f293418 (&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: 60024596
hardirqs last  enabled at (60024595): [<ffffffff81484250>] __local_bh_enable_ip+0xa0/0x120 kernel/softirq.c:401
hardirqs last disabled at (60024596): [<ffffffff897fd631>] common_interrupt+0x11/0xc0 arch/x86/kernel/irq.c:240
softirqs last  enabled at (60024594): [<ffffffff89198595>] spin_unlock_bh include/linux/spinlock.h:394 [inline]
softirqs last  enabled at (60024594): [<ffffffff89198595>] batadv_nc_purge_paths+0x2a5/0x3a0 net/batman-adv/network-coding.c:471
softirqs last disabled at (60024592): [<ffffffff891983cf>] spin_lock_bh include/linux/spinlock.h:354 [inline]
softirqs last disabled at (60024592): [<ffffffff891983cf>] batadv_nc_purge_paths+0xdf/0x3a0 net/batman-adv/network-coding.c:442

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

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

 *** DEADLOCK ***

3 locks held by kworker/u16:1/12:
 #0: ffff888048733938 ((wq_completion)bat_events){+.+.}-{0:0}, at: arch_atomic64_set arch/x86/include/asm/atomic64_64.h:34 [inline]
 #0: ffff888048733938 ((wq_completion)bat_events){+.+.}-{0:0}, at: arch_atomic_long_set include/linux/atomic/atomic-long.h:41 [inline]
 #0: ffff888048733938 ((wq_completion)bat_events){+.+.}-{0:0}, at: atomic_long_set include/linux/atomic/atomic-instrumented.h:1280 [inline]
 #0: ffff888048733938 ((wq_completion)bat_events){+.+.}-{0:0}, at: set_work_data kernel/workqueue.c:636 [inline]
 #0: ffff888048733938 ((wq_completion)bat_events){+.+.}-{0:0}, at: set_work_pool_and_clear_pending kernel/workqueue.c:663 [inline]
 #0: ffff888048733938 ((wq_completion)bat_events){+.+.}-{0:0}, at: process_one_work+0x87a/0x1610 kernel/workqueue.c:2260
 #1: ffffc900005ffda8 ((work_completion)(&(&bat_priv->nc.work)->work)){+.+.}-{0:0}, at: process_one_work+0x8ae/0x1610 kernel/workqueue.c:2264
 #2: ffff888045228020 (&chan->lock#2){-...}-{2:2}, at: req_done+0xcf/0x2e0 net/9p/trans_virtio.c:139

stack backtrace:
CPU: 0 PID: 12 Comm: kworker/u16:1 Not tainted 6.0.0-syzkaller-00188-gf3dfe925f954 #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014
Workqueue: bat_events batadv_nc_worker
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+0xa4/0xc0 arch/x86/kernel/irq.c:240
 </IRQ>
 <TASK>
 asm_common_interrupt+0x22/0x40 arch/x86/include/asm/idtentry.h:640
RIP: 0010:__local_bh_enable_ip+0xa8/0x120 kernel/softirq.c:403
Code: 1d 0d 2d ba 7e 65 8b 05 06 2d ba 7e a9 00 ff ff 00 74 45 bf 01 00 00 00 e8 65 9f 09 00 e8 80 78 39 00 fb 65 8b 05 e8 2c ba 7e <85> c0 74 58 5b 5d c3 65 8b 05 d6 33 ba 7e 85 c0 75 a2 0f 0b eb 9e
RSP: 0018:ffffc900005ffc00 EFLAGS: 00000202
RAX: 0000000080000000 RBX: 00000000fffffe00 RCX: 1ffffffff2127d26
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: ffffffff89198595 R08: 0000000000000001 R09: ffffffff908e1a37
R10: 0000000000000001 R11: 0000000000000000 R12: ffff88806e9fd7a8
R13: ffff88806e9fcc80 R14: dffffc0000000000 R15: ffffffff891987f0
 spin_unlock_bh include/linux/spinlock.h:394 [inline]
 batadv_nc_purge_paths+0x2a5/0x3a0 net/batman-adv/network-coding.c:471
 batadv_nc_worker+0x8f9/0xfa0 net/batman-adv/network-coding.c:720
 process_one_work+0x991/0x1610 kernel/workqueue.c:2289
 worker_thread+0x665/0x1080 kernel/workqueue.c:2436
 kthread+0x2e4/0x3a0 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306
 </TASK>
----------------
Code disassembly (best guess):
   0:	1d 0d 2d ba 7e       	sbb    $0x7eba2d0d,%eax
   5:	65 8b 05 06 2d ba 7e 	mov    %gs:0x7eba2d06(%rip),%eax        # 0x7eba2d12
   c:	a9 00 ff ff 00       	test   $0xffff00,%eax
  11:	74 45                	je     0x58
  13:	bf 01 00 00 00       	mov    $0x1,%edi
  18:	e8 65 9f 09 00       	callq  0x99f82
  1d:	e8 80 78 39 00       	callq  0x3978a2
  22:	fb                   	sti
  23:	65 8b 05 e8 2c ba 7e 	mov    %gs:0x7eba2ce8(%rip),%eax        # 0x7eba2d12
* 2a:	85 c0                	test   %eax,%eax <-- trapping instruction
  2c:	74 58                	je     0x86
  2e:	5b                   	pop    %rbx
  2f:	5d                   	pop    %rbp
  30:	c3                   	retq
  31:	65 8b 05 d6 33 ba 7e 	mov    %gs:0x7eba33d6(%rip),%eax        # 0x7eba340e
  38:	85 c0                	test   %eax,%eax
  3a:	75 a2                	jne    0xffffffde
  3c:	0f 0b                	ud2
  3e:	eb 9e                	jmp    0xffffffde

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