Re: inconsistent lock state in xfrm_user_rcv_msg

2020-09-23 Thread Herbert Xu
#syz dup: inconsistent lock state in xfrm_policy_lookup_inexact_addr
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


inconsistent lock state in xfrm_user_rcv_msg

2020-09-16 Thread syzbot
Hello,

syzbot found the following issue on:

HEAD commit:6b02addb Add linux-next specific files for 20200915
git tree:   linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=175c55b590
kernel config:  https://syzkaller.appspot.com/x/.config?x=7086d0e9e44d4a14
dashboard link: https://syzkaller.appspot.com/bug?extid=00c3b7dbdf97d1d36a9e
compiler:   gcc (GCC) 10.1.0-syz 20200507

Unfortunately, I don't have any reproducer for this issue yet.

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+00c3b7dbdf97d1d36...@syzkaller.appspotmail.com


WARNING: inconsistent lock state
5.9.0-rc5-next-20200915-syzkaller #0 Not tainted

inconsistent {IN-SOFTIRQ-R} -> {SOFTIRQ-ON-W} usage.
syz-executor.0/15304 [HC0[0]:SC0[0]:HE1:SE1] takes:
88805da556d0 (>seqcount#11){+.+-}-{0:0}, at: 
xfrm_user_rcv_msg+0x414/0x700 net/xfrm/xfrm_user.c:2684
{IN-SOFTIRQ-R} state was registered at:
  lock_acquire+0x1f2/0xaa0 kernel/locking/lockdep.c:5398
  seqcount_lockdep_reader_access+0x139/0x1a0 include/linux/seqlock.h:103
  xfrm_policy_lookup_inexact_addr+0x57/0x200 net/xfrm/xfrm_policy.c:1909
  xfrm_policy_find_inexact_candidates+0xac/0x1d0 net/xfrm/xfrm_policy.c:1953
  xfrm_policy_lookup_bytype+0x4b8/0xa40 net/xfrm/xfrm_policy.c:2108
  xfrm_policy_lookup net/xfrm/xfrm_policy.c:2144 [inline]
  xfrm_bundle_lookup net/xfrm/xfrm_policy.c:2944 [inline]
  xfrm_lookup_with_ifid+0xaa1/0x2100 net/xfrm/xfrm_policy.c:3085
  icmp6_dst_alloc+0x489/0x6c0 net/ipv6/route.c:3187
  ndisc_send_skb+0x1207/0x1720 net/ipv6/ndisc.c:486
  ndisc_send_rs+0x12e/0x700 net/ipv6/ndisc.c:700
  addrconf_rs_timer+0x2ec/0x7c0 net/ipv6/addrconf.c:3873
  call_timer_fn+0x1a5/0x6b0 kernel/time/timer.c:1413
  expire_timers kernel/time/timer.c:1458 [inline]
  __run_timers.part.0+0x67c/0xa50 kernel/time/timer.c:1755
  __run_timers kernel/time/timer.c:1736 [inline]
  run_timer_softirq+0xae/0x1a0 kernel/time/timer.c:1768
  __do_softirq+0x202/0xa42 kernel/softirq.c:298
  asm_call_on_stack+0xf/0x20 arch/x86/entry/entry_64.S:786
  __run_on_irqstack arch/x86/include/asm/irq_stack.h:22 [inline]
  run_on_irqstack_cond arch/x86/include/asm/irq_stack.h:48 [inline]
  do_softirq_own_stack+0x9d/0xd0 arch/x86/kernel/irq_64.c:77
  invoke_softirq kernel/softirq.c:393 [inline]
  __irq_exit_rcu kernel/softirq.c:423 [inline]
  irq_exit_rcu+0x235/0x280 kernel/softirq.c:435
  sysvec_apic_timer_interrupt+0x51/0xf0 arch/x86/kernel/apic/apic.c:1091
  asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:631
  arch_local_irq_restore+0x2e/0x50 arch/x86/include/asm/paravirt.h:653
  lock_is_held_type+0xbb/0xf0 kernel/locking/lockdep.c:5439
  lock_is_held include/linux/lockdep.h:271 [inline]
  schedule_debug kernel/sched/core.c:4296 [inline]
  __schedule+0x133a/0x21b0 kernel/sched/core.c:4421
  preempt_schedule_common+0x45/0xc0 kernel/sched/core.c:4685
  preempt_schedule_thunk+0x16/0x18 arch/x86/entry/thunk_64.S:40
  __raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:161 [inline]
  _raw_spin_unlock_irqrestore+0x78/0x90 kernel/locking/spinlock.c:191
  spin_unlock_irqrestore include/linux/spinlock.h:409 [inline]
  pty_write+0x15a/0x1f0 drivers/tty/pty.c:123
  tty_put_char+0x122/0x150 drivers/tty/tty_io.c:3030
  __process_echoes+0x577/0x9f0 drivers/tty/n_tty.c:728
  commit_echoes+0x148/0x210 drivers/tty/n_tty.c:794
  n_tty_receive_char_fast drivers/tty/n_tty.c:1449 [inline]
  n_tty_receive_buf_fast drivers/tty/n_tty.c:1609 [inline]
  __receive_buf drivers/tty/n_tty.c:1644 [inline]
  n_tty_receive_buf_common+0x203f/0x2bc0 drivers/tty/n_tty.c:1742
  tty_ldisc_receive_buf+0xa9/0x190 drivers/tty/tty_buffer.c:461
  tty_port_default_receive_buf+0x6e/0xa0 drivers/tty/tty_port.c:38
  receive_buf drivers/tty/tty_buffer.c:481 [inline]
  flush_to_ldisc+0x20d/0x380 drivers/tty/tty_buffer.c:533
  process_one_work+0x933/0x15a0 kernel/workqueue.c:2269
  worker_thread+0x64c/0x1120 kernel/workqueue.c:2415
  kthread+0x3af/0x4a0 kernel/kthread.c:292
  ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:296
irq event stamp: 103
hardirqs last  enabled at (103): [] 
__local_bh_enable_ip+0x10f/0x1f0 kernel/softirq.c:200
hardirqs last disabled at (101): [] 
__local_bh_enable_ip+0x154/0x1f0 kernel/softirq.c:177
softirqs last  enabled at (102): [] rcu_read_unlock_bh 
include/linux/rcupdate.h:726 [inline]
softirqs last  enabled at (102): [] 
__dev_queue_xmit+0x1a7e/0x2d10 net/core/dev.c:4164
softirqs last disabled at (98): [] 
__dev_queue_xmit+0x1d7/0x2d10 net/core/dev.c:4072

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

   CPU0
   
  lock(>seqcount#11);
  
lock(>seqcount#11);

 *** DEADLOCK ***

2 locks held by syz-executor.0/15304:
 #0: 88805da55a68 (>xfrm.xfrm_cfg_mutex){+.+.}-{3:3}, at: 
xfrm_netlink_rcv+0x5c/0x90 net/xfrm/xfrm_user.c:2691
 #1: 88805da55718