Re: WARNING: proc registration bug in snmp6_register_dev

2020-05-06 Thread syzbot
syzbot has bisected this bug to:

commit e0a4b99773d3d8d3fb40087805f8fd858a23e582
Author: Taehee Yoo 
Date:   Fri Feb 28 18:02:10 2020 +

hsr: use upper/lower device infrastructure

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=1481118210
start commit:   ac935d22 Add linux-next specific files for 20200415
git tree:   linux-next
final crash:https://syzkaller.appspot.com/x/report.txt?x=1681118210
console output: https://syzkaller.appspot.com/x/log.txt?x=1281118210
kernel config:  https://syzkaller.appspot.com/x/.config?x=bc498783097e9019
dashboard link: https://syzkaller.appspot.com/bug?extid=1d51c8b74efa4c44adeb
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=148e615010
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=115c379c10

Reported-by: syzbot+1d51c8b74efa4c44a...@syzkaller.appspotmail.com
Fixes: e0a4b99773d3 ("hsr: use upper/lower device infrastructure")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection


Re: WARNING: proc registration bug in snmp6_register_dev

2020-05-05 Thread syzbot
syzbot has found a reproducer for the following crash on:

HEAD commit:ac935d22 Add linux-next specific files for 20200415
git tree:   linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=17006f4c10
kernel config:  https://syzkaller.appspot.com/x/.config?x=bc498783097e9019
dashboard link: https://syzkaller.appspot.com/bug?extid=1d51c8b74efa4c44adeb
compiler:   gcc (GCC) 9.0.0 20181231 (experimental)
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=148e615010
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=115c379c10

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+1d51c8b74efa4c44a...@syzkaller.appspotmail.com

[ cut here ]
proc_dir_entry 'dev_snmp6/hsr1' already registered
WARNING: CPU: 0 PID: 7289 at fs/proc/generic.c:362 proc_register+0x40b/0x580 
fs/proc/generic.c:362
Kernel panic - not syncing: panic_on_warn set ...
CPU: 0 PID: 7289 Comm: syz-executor779 Not tainted 
5.7.0-rc1-next-20200415-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 
01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x188/0x20d lib/dump_stack.c:118
 panic+0x2e3/0x75c kernel/panic.c:221
 __warn.cold+0x2f/0x35 kernel/panic.c:582
 report_bug+0x27b/0x2f0 lib/bug.c:195
 fixup_bug arch/x86/kernel/traps.c:175 [inline]
 fixup_bug arch/x86/kernel/traps.c:170 [inline]
 do_error_trap+0x12b/0x220 arch/x86/kernel/traps.c:267
 do_invalid_op+0x32/0x40 arch/x86/kernel/traps.c:286
 invalid_op+0x23/0x30 arch/x86/entry/entry_64.S:1027
RIP: 0010:proc_register+0x40b/0x580 fs/proc/generic.c:362
Code: ff df 48 89 f9 48 c1 e9 03 80 3c 01 00 0f 85 5c 01 00 00 48 8b 04 24 48 
c7 c7 a0 7a 39 88 48 8b b0 d8 00 00 00 e8 4d 2d 61 ff <0f> 0b 48 c7 c7 a0 ac ac 
89 e8 f7 5b f3 05 48 8b 4c 24 28 48 b8 00
RSP: 0018:c90005956cc8 EFLAGS: 00010282
RAX:  RBX: 8880a9138ac8 RCX: 
RDX:  RSI: 815ce211 RDI: f52000b2ad8b
RBP: 8880a1ab3a80 R08: 888087c40340 R09: ed1015cc66b1
R10: 8880ae633587 R11: ed1015cc66b0 R12: 
R13: dc00 R14: 8880a6561240 R15: 0004
 proc_create_single_data+0xdb/0x130 fs/proc/generic.c:631
 snmp6_register_dev+0xbe/0x140 net/ipv6/proc.c:254
 ipv6_add_dev net/ipv6/addrconf.c:408 [inline]
 ipv6_add_dev+0x54b/0x10b0 net/ipv6/addrconf.c:365
 addrconf_notify+0x960/0x2310 net/ipv6/addrconf.c:3503
 notifier_call_chain+0xc0/0x230 kernel/notifier.c:83
 call_netdevice_notifiers_info net/core/dev.c:1948 [inline]
 call_netdevice_notifiers_info+0xb5/0x130 net/core/dev.c:1933
 call_netdevice_notifiers_extack net/core/dev.c:1960 [inline]
 call_netdevice_notifiers net/core/dev.c:1974 [inline]
 register_netdevice+0xd70/0x10b0 net/core/dev.c:9423
 hsr_dev_finalize+0x516/0x746 net/hsr/hsr_device.c:486
 hsr_newlink+0x27c/0x520 net/hsr/hsr_netlink.c:83
 __rtnl_newlink+0xf18/0x1590 net/core/rtnetlink.c:
 rtnl_newlink+0x64/0xa0 net/core/rtnetlink.c:3391
 rtnetlink_rcv_msg+0x44e/0xad0 net/core/rtnetlink.c:5454
 netlink_rcv_skb+0x15a/0x410 net/netlink/af_netlink.c:2469
 netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
 netlink_unicast+0x537/0x740 net/netlink/af_netlink.c:1329
 netlink_sendmsg+0x882/0xe10 net/netlink/af_netlink.c:1918
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:672
 sys_sendmsg+0x6bf/0x7e0 net/socket.c:2362
 ___sys_sendmsg+0x100/0x170 net/socket.c:2416
 __sys_sendmsg+0xec/0x1b0 net/socket.c:2449
 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
 entry_SYSCALL_64_after_hwframe+0x49/0xb3
RIP: 0033:0x449409
Code: e8 cc 14 03 00 48 83 c4 18 c3 0f 1f 80 00 00 00 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 0f 83 
9b 0c fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:7fa3c088fdb8 EFLAGS: 0246 ORIG_RAX: 002e
RAX: ffda RBX: 006dfca8 RCX: 00449409
RDX:  RSI: 2040 RDI: 000e
RBP: 006dfca0 R08: 0014 R09: 
R10: 0001 R11: 0246 R12: 006dfcac
R13: 7ffc318e2f1f R14: 7fa3c08909c0 R15: 006dfcac
Kernel Offset: disabled
Rebooting in 86400 seconds..



Re: WARNING: proc registration bug in snmp6_register_dev

2020-05-05 Thread Taehee Yoo
On Thu, 16 Apr 2020 at 07:46, syzbot
 wrote:
>
> Hello,
>
> syzbot found the following crash on:
>
> HEAD commit:ab6f762f printk: queue wake_up_klogd irq_work only if per-..
> git tree:   upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=1395613fe0
> kernel config:  https://syzkaller.appspot.com/x/.config?x=3010ccb0f380f660
> dashboard link: https://syzkaller.appspot.com/bug?extid=1d51c8b74efa4c44adeb
> compiler:   clang version 10.0.0 (https://github.com/llvm/llvm-project/ 
> c2443155a0fb245c8f17f2c1c72b6ea391e86e81)
>
> Unfortunately, I don't have any reproducer for this crash yet.
>
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+1d51c8b74efa4c44a...@syzkaller.appspotmail.com
>
> [ cut here ]
> proc_dir_entry 'dev_snmp6/hsr1' already registered
> WARNING: CPU: 0 PID: 22141 at fs/proc/generic.c:363 proc_register+0x2bc/0x4e0 
> fs/proc/generic.c:362
> Kernel panic - not syncing: panic_on_warn set ...
> CPU: 0 PID: 22141 Comm: syz-executor.2 Not tainted 5.6.0-syzkaller #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS 
> Google 01/01/2011
> Call Trace:
>  __dump_stack lib/dump_stack.c:77 [inline]
>  dump_stack+0x1e9/0x30e lib/dump_stack.c:118
>  panic+0x264/0x7a0 kernel/panic.c:221
>  __warn+0x209/0x210 kernel/panic.c:582
>  report_bug+0x1ac/0x2d0 lib/bug.c:195
>  fixup_bug arch/x86/kernel/traps.c:175 [inline]
>  do_error_trap+0xca/0x1c0 arch/x86/kernel/traps.c:267
>  do_invalid_op+0x32/0x40 arch/x86/kernel/traps.c:286
>  invalid_op+0x23/0x30 arch/x86/entry/entry_64.S:1027
> RIP: 0010:proc_register+0x2bc/0x4e0 fs/proc/generic.c:362
> Code: 08 4c 8b 74 24 28 48 8b 6c 24 20 74 08 48 89 ef e8 99 29 d1 ff 48 8b 55 
> 00 48 c7 c7 24 4e e9 88 48 89 de 31 c0 e8 e4 7c 65 ff <0f> 0b 48 c7 c7 20 e6 
> 32 89 e8 66 41 2a 06 48 8b 44 24 30 42 8a 04
> RSP: :c900088feec0 EFLAGS: 00010246
> RAX: f20851673ab1bb00 RBX: 8880908a5264 RCX: 0004
> RDX: c9000df22000 RSI: 000150b4 RDI: 000150b5
> RBP: 88808981bc18 R08: 815cac69 R09: ed1015d06660
> R10: ed1015d06660 R11:  R12: dc00
> R13: 0004 R14: 88808981bbd4 R15: 88808981bb40
>  proc_create_single_data+0x18e/0x1e0 fs/proc/generic.c:631
>  snmp6_register_dev+0xa1/0x110 net/ipv6/proc.c:254
>  ipv6_add_dev+0x509/0x1430 net/ipv6/addrconf.c:408
>  addrconf_notify+0x5f8/0x3ad0 net/ipv6/addrconf.c:3503
>  notifier_call_chain kernel/notifier.c:83 [inline]
>  __raw_notifier_call_chain kernel/notifier.c:361 [inline]
>  raw_notifier_call_chain+0xd4/0x170 kernel/notifier.c:368
>  call_netdevice_notifiers_info net/core/dev.c:1948 [inline]
>  call_netdevice_notifiers_extack net/core/dev.c:1960 [inline]
>  call_netdevice_notifiers net/core/dev.c:1974 [inline]
>  register_netdevice+0x14a4/0x1a50 net/core/dev.c:9421
>  hsr_dev_finalize+0x425/0x6d0 net/hsr/hsr_device.c:486
>  hsr_newlink+0x3b5/0x460 net/hsr/hsr_netlink.c:77
>  __rtnl_newlink net/core/rtnetlink.c: [inline]
>  rtnl_newlink+0x143e/0x1c00 net/core/rtnetlink.c:3391
>  rtnetlink_rcv_msg+0x889/0xd40 net/core/rtnetlink.c:5454
>  netlink_rcv_skb+0x190/0x3a0 net/netlink/af_netlink.c:2469
>  netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
>  netlink_unicast+0x786/0x940 net/netlink/af_netlink.c:1329
>  netlink_sendmsg+0xa57/0xd70 net/netlink/af_netlink.c:1918
>  sock_sendmsg_nosec net/socket.c:652 [inline]
>  sock_sendmsg net/socket.c:672 [inline]
>  sys_sendmsg+0x4f9/0x7c0 net/socket.c:2362
>  ___sys_sendmsg net/socket.c:2416 [inline]
>  __sys_sendmsg+0x2a6/0x360 net/socket.c:2449
>  do_syscall_64+0xf3/0x1b0 arch/x86/entry/common.c:295
>  entry_SYSCALL_64_after_hwframe+0x49/0xb3
> RIP: 0033:0x45c889
> Code: ad b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 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 0f 
> 83 7b b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00
> RSP: 002b:7f007299ac78 EFLAGS: 0246 ORIG_RAX: 002e
> RAX: ffda RBX: 7f007299b6d4 RCX: 0045c889
> RDX:  RSI: 20c0 RDI: 0006
> RBP: 0076c180 R08:  R09: 
> R10:  R11: 0246 R12: 
> R13: 09fc R14: 004ccb7c R15: 0076c18c
> Kernel Offset: disabled
> Rebooting in 86400 seconds..
>

This is hsr module bug.
When a hsr interface is being removed,
"/proc/net/dev_snmp6/" is removed and it is created again
because of NETDEV_CHANGEMTU after NETDEV_UNREGISTER.
So, this resource can't be released in the RTNL mutex critical section.
This remained resources will be released by netdev_run_todo() but it is
not protected by RTNL mutex. So that creating a new interface
routine(rtnl_newlink()) can be executed concurrently.
This routine would try to create the same proc entry
("/proc/net/dev_snmp6/")
At