linux/drivers/net/ethernet
Daniel Borkmann b5b2ffc057 ixgbe: fix use after free adapter->state test in ixgbe_remove/ixgbe_probe
While working on a different issue, I noticed an annoying use
after free bug on my machine when unloading the ixgbe driver:

[ 8642.318797] ixgbe 0000:02:00.1: removed PHC on p2p2
[ 8642.742716] ixgbe 0000:02:00.1: complete
[ 8642.743784] BUG: unable to handle kernel paging request at ffff8807d3740a90
[ 8642.744828] IP: [<ffffffffa01c77dc>] ixgbe_remove+0xfc/0x1b0 [ixgbe]
[ 8642.745886] PGD 20c6067 PUD 81c1f6067 PMD 81c15a067 PTE 80000007d3740060
[ 8642.746956] Oops: 0002 [#1] SMP DEBUG_PAGEALLOC
[ 8642.748039] Modules linked in: [...]
[ 8642.752929] CPU: 1 PID: 1225 Comm: rmmod Not tainted 3.18.0-rc2+ #49
[ 8642.754203] Hardware name: Supermicro X10SLM-F/X10SLM-F, BIOS 1.1b 11/01/2013
[ 8642.755505] task: ffff8807e34d3fe0 ti: ffff8807b7204000 task.ti: ffff8807b7204000
[ 8642.756831] RIP: 0010:[<ffffffffa01c77dc>]  [<ffffffffa01c77dc>] ixgbe_remove+0xfc/0x1b0 [ixgbe]
[...]
[ 8642.774335] Stack:
[ 8642.775805]  ffff8807ee824098 ffff8807ee824098 ffffffffa01f3000 ffff8807ee824000
[ 8642.777326]  ffff8807b7207e18 ffffffff8137720f ffff8807ee824098 ffff8807ee824098
[ 8642.778848]  ffffffffa01f3068 ffff8807ee8240f8 ffff8807b7207e38 ffffffff8144180f
[ 8642.780365] Call Trace:
[ 8642.781869]  [<ffffffff8137720f>] pci_device_remove+0x3f/0xc0
[ 8642.783395]  [<ffffffff8144180f>] __device_release_driver+0x7f/0xf0
[ 8642.784876]  [<ffffffff814421f8>] driver_detach+0xb8/0xc0
[ 8642.786352]  [<ffffffff814414a9>] bus_remove_driver+0x59/0xe0
[ 8642.787783]  [<ffffffff814429d0>] driver_unregister+0x30/0x70
[ 8642.789202]  [<ffffffff81375c65>] pci_unregister_driver+0x25/0xa0
[ 8642.790657]  [<ffffffffa01eb38e>] ixgbe_exit_module+0x1c/0xc8e [ixgbe]
[ 8642.792064]  [<ffffffff810f93a2>] SyS_delete_module+0x132/0x1c0
[ 8642.793450]  [<ffffffff81012c61>] ? do_notify_resume+0x61/0xa0
[ 8642.794837]  [<ffffffff816d2029>] system_call_fastpath+0x12/0x17

The issue is that test_and_set_bit() done on adapter->state is being
performed *after* the netdevice has been freed via free_netdev().

When netdev is being allocated on initialization time, it allocates
a private area, here struct ixgbe_adapter, that resides after the
net_device structure. In ixgbe_probe(), the device init routine,
we set up the adapter after alloc_etherdev_mq() on the private area
and add a reference for the pci_dev as well via pci_set_drvdata().

Both in the error path of ixgbe_probe(), but also on module unload
when ixgbe_remove() is being called, commit 41c62843eb ("ixgbe:
Fix rcu warnings induced by LER") accesses adapter after free_netdev().
The patch stores the result in a bool and thus fixes above oops on my
side.

Fixes: 41c62843eb ("ixgbe: Fix rcu warnings induced by LER")
Cc: stable <stable@vger.kernel.org>
Cc: Mark Rustad <mark.d.rustad@intel.com>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-11-23 14:26:12 -05:00
..
3com Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2014-10-08 16:22:22 -04:00
8390 PCI changes for the v3.17 merge window (part 2): 2014-08-14 18:10:33 -06:00
adaptec PCI: Remove DEFINE_PCI_DEVICE_TABLE macro use 2014-08-12 12:15:14 -06:00
adi net: ethernet: Remove superfluous ether_setup after alloc_etherdev 2014-10-03 15:31:40 -07:00
aeroflex greth: moved TX ring cleaning to NAPI rx poll func 2014-09-05 21:57:09 -07:00
agere et131x: Add PCIe gigabit ethernet driver et131x to drivers/net 2014-10-03 12:22:19 -07:00
allwinner net: ethernet: Remove superfluous ether_setup after alloc_etherdev 2014-10-03 15:31:40 -07:00
alteon PCI: Remove DEFINE_PCI_DEVICE_TABLE macro use 2014-08-12 12:15:14 -06:00
altera Altera TSE: Add support for no PHY 2014-10-05 21:39:40 -04:00
amd amd-xgbe: Fix napi Rx budget accounting 2014-10-22 17:50:31 -04:00
apm drivers: net: xgene: fix: Use separate resources 2014-11-04 17:08:42 -05:00
apple
arc Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2014-09-23 12:09:27 -04:00
atheros PCI: Remove DEFINE_PCI_DEVICE_TABLE macro use 2014-08-12 12:15:14 -06:00
broadcom net: bcmgenet: apply MII configuration in bcmgenet_open() 2014-11-11 18:23:23 -05:00
brocade bna: fix skb->truesize underestimation 2014-10-17 23:56:33 -04:00
cadence net: ethernet: Remove superfluous ether_setup after alloc_etherdev 2014-10-03 15:31:40 -07:00
calxeda net: ethernet: Remove superfluous ether_setup after alloc_etherdev 2014-10-03 15:31:40 -07:00
chelsio cxgb4 : Fix DCB priority groups being returned in wrong order 2014-11-21 00:05:55 -05:00
cirrus cirrus: cs89x0: Use managed interfaces 2014-08-02 16:40:52 -07:00
cisco enic: update desc properly in rx_copybreak 2014-11-06 16:42:04 -05:00
davicom net: ethernet: Remove superfluous ether_setup after alloc_etherdev 2014-10-03 15:31:40 -07:00
dec tulip: dmfe: Fix global namespace pollution of phy accessors. 2014-08-27 18:25:40 -07:00
dlink PCI: Remove DEFINE_PCI_DEVICE_TABLE macro use 2014-08-12 12:15:14 -06:00
emulex be2net: Implement ndo_gso_check() 2014-11-14 17:12:48 -05:00
faraday
freescale net: fec: fix regression on i.MX28 introduced by rx_copybreak support 2014-11-07 12:08:58 -05:00
fujitsu drivers/net: ethernet: Remove typedef for struct and enum 2014-08-07 16:02:58 -07:00
hisilicon
hp hp100: Convert the normal skb free path to dev_consume_skb_any() 2014-09-08 15:39:58 -07:00
i825xx
ibm ehea: Fix TSO and hw checksums with non-accelerated vlan packets. 2014-08-25 17:27:09 -07:00
icplus PCI: Remove DEFINE_PCI_DEVICE_TABLE macro use 2014-08-12 12:15:14 -06:00
intel ixgbe: fix use after free adapter->state test in ixgbe_remove/ixgbe_probe 2014-11-23 14:26:12 -05:00
marvell net: mv643xx_eth: reclaim TX skbs only when released by the HW 2014-11-06 14:54:39 -05:00
mellanox net/mlx4_en: Add VXLAN ndo calls to the PF net device ops too 2014-11-19 15:11:09 -05:00
micrel net: ks8842: use dmaengine_terminate_all() API 2014-10-15 21:31:00 +05:30
microchip
moxa net: ethernet: Remove superfluous ether_setup after alloc_etherdev 2014-10-03 15:31:40 -07:00
myricom PCI changes for the v3.17 merge window (part 2): 2014-08-14 18:10:33 -06:00
natsemi PCI: Remove DEFINE_PCI_DEVICE_TABLE macro use 2014-08-12 12:15:14 -06:00
neterion net: ethernet: neterion: vxge: vxge-main.c: Cleaning up missing null-terminate in conjunction with strncpy 2014-09-15 14:17:00 -04:00
nuvoton net: ethernet: Remove superfluous ether_setup after alloc_etherdev 2014-10-03 15:31:40 -07:00
nvidia ethernet: nvidia: Remove extra parens 2014-09-02 13:47:25 -07:00
nxp net: ethernet: Remove superfluous ether_setup after alloc_etherdev 2014-10-03 15:31:40 -07:00
octeon drivers: net: ethernet: octeon_mgmt: fix a compiler warning 2014-09-08 14:23:46 -07:00
oki-semi pch_gbe: 'select' NET_PTP_CLASSIFY. 2014-09-22 13:25:51 -04:00
packetengines drivers/net: Convert remaining uses of pr_warning to pr_warn 2014-09-09 20:37:08 -07:00
pasemi PCI: Remove DEFINE_PCI_DEVICE_TABLE macro use 2014-08-12 12:15:14 -06:00
qlogic qlcnic: Implement ndo_gso_check() 2014-11-14 17:12:48 -05:00
qualcomm net: qualcomm: Fix dependency 2014-11-11 18:12:32 -05:00
rdc PCI: Remove DEFINE_PCI_DEVICE_TABLE macro use 2014-08-12 12:15:14 -06:00
realtek r8169:add support for RTL8168EP 2014-10-08 15:58:45 -04:00
renesas net: sh_eth: fix driver dependencies 2014-09-02 13:23:25 -07:00
samsung
seeq
sfc sfc: don't BUG_ON efx->max_channels == 0 in probe 2014-11-03 15:57:50 -05:00
sgi PCI: Remove DEFINE_PCI_DEVICE_TABLE macro use 2014-08-12 12:15:14 -06:00
silan PCI: Remove DEFINE_PCI_DEVICE_TABLE macro use 2014-08-12 12:15:14 -06:00
sis PCI: Remove DEFINE_PCI_DEVICE_TABLE macro use 2014-08-12 12:15:14 -06:00
smsc smsc911x: power-up phydev before doing a software reset. 2014-11-13 15:09:28 -05:00
stmicro stmmac: fix atomicity in pm routines 2014-11-05 16:22:57 -05:00
sun sunhme: Add DMA mapping error checks. 2014-11-01 00:23:46 -04:00
tehuti PCI: Remove DEFINE_PCI_DEVICE_TABLE macro use 2014-08-12 12:15:14 -06:00
ti drivers: net: cpsw: Fix TX_IN_SEL offset 2014-11-16 14:20:00 -05:00
tile Merge branch 'for-3.18-consistent-ops' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu 2014-10-15 07:48:18 +02:00
toshiba net: spider_net: avoid using signed char for bitops 2014-10-05 21:15:16 -04:00
tundra
via Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2014-10-07 21:16:26 -04:00
wiznet net: ethernet: Remove superfluous ether_setup after alloc_etherdev 2014-10-03 15:31:40 -07:00
xilinx drivers: net: ethernet: xilinx: xilinx_emaclite: revert the original commit "1db3ddff1602edf2390b7667dcbaa0f71512e3ea" 2014-11-05 16:00:51 -05:00
xircom ethernet: amd: Remove typedef local_info_t 2014-08-11 12:19:53 -07:00
xscale
dnet.c net: dnet: Use managed interfaces 2014-08-02 16:40:52 -07:00
dnet.h
ec_bhf.c net: ec_bhf: remove excessive debug messages 2014-08-24 18:36:57 -07:00
ethoc.c net: ethernet: Remove superfluous ether_setup after alloc_etherdev 2014-10-03 15:31:40 -07:00
fealnx.c PCI: Remove DEFINE_PCI_DEVICE_TABLE macro use 2014-08-12 12:15:14 -06:00
jme.c PCI: Remove DEFINE_PCI_DEVICE_TABLE macro use 2014-08-12 12:15:14 -06:00
jme.h
Kconfig et131x: Add PCIe gigabit ethernet driver et131x to drivers/net 2014-10-03 12:22:19 -07:00
korina.c
lantiq_etop.c net: ethernet: Remove superfluous ether_setup after alloc_etherdev 2014-10-03 15:31:40 -07:00
Makefile et131x: Add PCIe gigabit ethernet driver et131x to drivers/net 2014-10-03 12:22:19 -07:00
netx-eth.c net: ethernet: Remove superfluous ether_setup after alloc_etherdev 2014-10-03 15:31:40 -07:00
s6gmac.c