• Shiraz Saleem's avatar
    i40iw: Prevent multiple netdev event notifier registrations · 47fb3c16
    Shiraz Saleem authored
    Netdev event notifier registration/de-registration is not
    synchronized with a lock and there is a possibility of a
    duplicate registration of notifier before the unregister
    completes.
    
    Register netdev event notifiers during module init and
    de-register them at module exit.
    
    This avoids the need to tie the registration to first netdev
    client interface open and de-registration to last client
    interface close and the synchronization to achieve it.
    
    This also fixes a crash due to duplicate registration.
    
    BUG: unable to handle kernel paging request at ffffffffa0d60388
    IP: [<ffffffff8160f75d>] notifier_call_chain+0x3d/0x70
    PGD 190d067 PUD 190e063 PMD 76c840067 PTE 0
    Oops: 0000 [#1] SMP
    Modules linked in: i40e(OF-) fuse btrfs zlib_deflate raid6_pq xor vfat msdos
    [..]
    e1000e vxlan ip_tunnel ptp pps_core i2c_core video [last unloaded: i40iw]
    CPU: 1 PID: 27101 Comm: modprobe Tainted: GF       W  O--------------   3.10.0-229.el7.x86_64 #1
    Hardware name: Gigabyte Technology Co., Ltd. To be filled by O.E.M./Q87M-D2H, BIOS F7 01/17/2014
    task: ffff88076e8a96c0 ti: ffff8806959c8000 task.ti: ffff8806959c8000
    RIP: 0010:[<ffffffff8160f75d>]  [<ffffffff8160f75d>] notifier_call_chain+0x3d/0x70
    RSP: 0018:ffff8806959cbb38  EFLAGS: 00010282
    RAX: ffffffffa0d60380 RBX: 00000000fffffffd RCX: 0000000000000000
    0708] RDX: 0000000000000000 RSI: ffff88081227a000 RDI: 0000000000000002
    RBP: ffff8806959cbb60 R08: 0000000000000246 R09: 000000000000700c
    R10: ffff88080e16ea40 R11: 00000000000ae8df R12: ffffffffa0d60380
    R13: 0000000000000002 R14: ffff88076e738800 R15: 0000000000000000
    FS:  00007f604ef4a740(0000) GS:ffff88083e240000(0000) knlGS:0000000000000000
    CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: ffffffffa0d60388 CR3: 0000000753cd2000 CR4: 00000000001407e0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
    Stack:
    ffffffff819e73a0 0000000000000000 0000000000000002 ffff88076e738800
    00000000ffffffff ffff8806959cbba0 ffffffff8109d61d 0000000000000000
    0000000000000000 ffff88076e738800 0000000000000000 ffff88076e738800
    Call Trace:
    [<ffffffff8109d61d>] __blocking_notifier_call_chain+0x4d/0x70
    [<ffffffff8109d656>] blocking_notifier_call_chain+0x16/0x20
    [<ffffffff8156b9e4>] __inet_del_ifa+0x154/0x2b0
    [<ffffffff8156d102>] inetdev_event+0x182/0x530
    [<ffffffff8160f76c>] notifier_call_chain+0x4c/0x70
    [<ffffffff8109d446>] raw_notifier_call_chain+0x16/0x20
    [<ffffffff814f71fd>] call_netdevice_notifiers+0x2d/0x60
    [<ffffffff814f8845>] rollback_registered_many+0x105/0x220
    [<ffffffff814f89a0>] rollback_registered+0x40/0x70
    [<ffffffff814f9c88>] unregister_netdevice_queue+0x48/0x80
    [<ffffffff814f9cdc>] unregister_netdev+0x1c/0x30
    [<ffffffffa0067139>] i40e_vsi_release+0x2a9/0x2b0 [i40e]
    [<ffffffffa00674e8>] i40e_remove+0x128/0x2b0 [i40e]
    [<ffffffff813092db>] pci_device_remove+0x3b/0xb0
    [<ffffffff813d26ef>] __device_release_driver+0x7f/0xf0
    [<ffffffff813d3068>] driver_detach+0xb8/0xc0
    [<ffffffff813d22db>] bus_remove_driver+0x9b/0x120
    [<ffffffff813d36dc>] driver_unregister+0x2c/0x50
    [<ffffffff81307d4c>] pci_unregister_driver+0x2c/0x90
    [<ffffffffa008f9d0>] i40e_exit_module+0x10/0x23 [i40e]
    [<ffffffff810dad0b>] SyS_delete_module+0x16b/0x2d0
    [<ffffffff81013b0c>] ? do_notify_resume+0x9c/0xb0
    [<ffffffff81613da9>] system_call_fastpath+0x16/0x1b
    Code: e5 41 57 4d 89 c7 41 56 49 89 d6 41 55 49 89 f5 41 54 53 89 cb
    75 14 eb 3d 0f 1f 44 00 00 83 eb 01 74 25 4d 85 e4 74 20 4c 89 e0 <4c>
    8b 60 08 4c 89 f2 4c 89 ee 48 89 c7 ff 10 4d 85 ff 74 04 41
    RIP  [<ffffffff8160f75d>] notifier_call_chain+0x3d/0x70
    Signed-off-by: default avatarShiraz Saleem <shiraz.saleem@intel.com>
    Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
    47fb3c16
i40iw_main.c 56.6 KB