OpenCloudOS-Kernel/drivers/net/ethernet
Ignat Korchagin 99ba0ea616 sfc: adjust efx->xdp_tx_queue_count with the real number of initialized queues
efx->xdp_tx_queue_count is initially initialized to num_possible_cpus() and is
later used to allocate and traverse efx->xdp_tx_queues lookup array. However,
we may end up not initializing all the array slots with real queues during
probing. This results, for example, in a NULL pointer dereference, when running
"# ethtool -S <iface>", similar to below

[2570283.664955][T4126959] BUG: kernel NULL pointer dereference, address: 00000000000000f8
[2570283.681283][T4126959] #PF: supervisor read access in kernel mode
[2570283.695678][T4126959] #PF: error_code(0x0000) - not-present page
[2570283.710013][T4126959] PGD 0 P4D 0
[2570283.721649][T4126959] Oops: 0000 [#1] SMP PTI
[2570283.734108][T4126959] CPU: 23 PID: 4126959 Comm: ethtool Tainted: G           O      5.10.20-cloudflare-2021.3.1 #1
[2570283.752641][T4126959] Hardware name: <redacted>
[2570283.781408][T4126959] RIP: 0010:efx_ethtool_get_stats+0x2ca/0x330 [sfc]
[2570283.796073][T4126959] Code: 00 85 c0 74 39 48 8b 95 a8 0f 00 00 48 85 d2 74 2d 31 c0 eb 07 48 8b 95 a8 0f 00 00 48 63 c8 49 83 c4 08 83 c0 01 48 8b 14 ca <48> 8b 92 f8 00 00 00 49 89 54 24 f8 39 85 a0 0f 00 00 77 d7 48 8b
[2570283.831259][T4126959] RSP: 0018:ffffb79a77657ce8 EFLAGS: 00010202
[2570283.845121][T4126959] RAX: 0000000000000019 RBX: ffffb799cd0c9280 RCX: 0000000000000018
[2570283.860872][T4126959] RDX: 0000000000000000 RSI: ffff96dd970ce000 RDI: 0000000000000005
[2570283.876525][T4126959] RBP: ffff96dd86f0a000 R08: ffff96dd970ce480 R09: 000000000000005f
[2570283.892014][T4126959] R10: ffffb799cd0c9fff R11: ffffb799cd0c9000 R12: ffffb799cd0c94f8
[2570283.907406][T4126959] R13: ffffffffc11b1090 R14: ffff96dd970ce000 R15: ffffffffc11cd66c
[2570283.922705][T4126959] FS:  00007fa7723f8740(0000) GS:ffff96f51fac0000(0000) knlGS:0000000000000000
[2570283.938848][T4126959] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[2570283.952524][T4126959] CR2: 00000000000000f8 CR3: 0000001a73e6e006 CR4: 00000000007706e0
[2570283.967529][T4126959] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[2570283.982400][T4126959] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[2570283.997308][T4126959] PKRU: 55555554
[2570284.007649][T4126959] Call Trace:
[2570284.017598][T4126959]  dev_ethtool+0x1832/0x2830

Fix this by adjusting efx->xdp_tx_queue_count after probing to reflect the true
value of initialized slots in efx->xdp_tx_queues.

Signed-off-by: Ignat Korchagin <ignat@cloudflare.com>
Fixes: e26ca4b535 ("sfc: reduce the number of requested xdp ev queues")
Cc: <stable@vger.kernel.org> # 5.12.x
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-04-27 15:38:29 -07:00
..
3com net: 3c509: Fix fall-through warnings for Clang 2021-03-10 12:45:15 -08:00
8390
actions net: ethernet: actions: Add Actions Semi Owl Ethernet MAC driver 2021-03-22 12:56:21 -07:00
adaptec
aeroflex of: net: pass the dst buffer to of_get_mac_address() 2021-04-13 14:35:02 -07:00
agere
alacritech
allwinner of: net: pass the dst buffer to of_get_mac_address() 2021-04-13 14:35:02 -07:00
alteon
altera of: net: pass the dst buffer to of_get_mac_address() 2021-04-13 14:35:02 -07:00
amazon net: ena: remove extra words from comments 2021-03-31 14:34:08 -07:00
amd pcnet32: Remove redundant variable prev_link and curr_link 2021-04-26 12:46:10 -07:00
apm
apple
aquantia net: ethernet: aquantia: Handle error cleanup of start on open 2021-02-11 14:38:06 -08:00
arc of: net: pass the dst buffer to of_get_mac_address() 2021-04-13 14:35:02 -07:00
atheros net: ag71xx: make use of generic NET_SELFTESTS library 2021-04-20 16:08:02 -07:00
broadcom Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-04-26 12:00:00 -07:00
brocade bna: Update driver to use ethtool_sprintf 2021-03-17 11:42:31 -07:00
cadence Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-04-17 11:08:07 -07:00
calxeda
cavium Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-04-17 11:08:07 -07:00
chelsio ch_ktls: Remove redundant variable result 2021-04-25 18:07:11 -07:00
cirrus
cisco enic: use module_pci_driver to simplify the code 2021-04-07 15:15:01 -07:00
cortina
davicom net: davicom: Remove redundant assignment to ret 2021-04-26 12:48:30 -07:00
dec tulip: de2104x: use module_pci_driver to simplify the code 2021-04-07 15:15:01 -07:00
dlink net: sundance: use module_pci_driver to simplify the code 2021-04-07 15:15:01 -07:00
emulex
ezchip of: net: pass the dst buffer to of_get_mac_address() 2021-04-13 14:35:02 -07:00
faraday Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-03-25 15:31:22 -07:00
freescale enetc: fix locking for one-step timestamping packet transfer 2021-04-23 13:52:30 -07:00
fujitsu
google net: gve: remove duplicated allowed 2021-03-25 17:07:58 -07:00
hisilicon net: hns3: change the value of the SEPARATOR_VALUE macro in hclgevf_main.c 2021-04-19 15:38:05 -07:00
huawei hinic: avoid gcc -Wrestrict warning 2021-03-24 18:00:32 -07:00
i825xx
ibm Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-04-17 11:08:07 -07:00
intel iavf: redefine the magic number for FDIR GTP-U header fields 2021-04-23 09:34:19 -07:00
marvell Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-04-26 12:00:00 -07:00
mediatek net: ethernet: mtk_eth_soc: use iopoll.h macro for DMA init 2021-04-23 13:31:58 -07:00
mellanox net/mlx5: SF, Extend SF table for additional SF id range 2021-04-24 00:59:07 -07:00
micrel of: net: pass the dst buffer to of_get_mac_address() 2021-04-13 14:35:02 -07:00
microchip of: net: pass the dst buffer to of_get_mac_address() 2021-04-13 14:35:02 -07:00
microsoft net: mana: Use int to check the return value of mana_gd_poll_cq() 2021-04-23 13:16:29 -07:00
moxa net: moxa: remove redundant dev_err call in moxart_mac_probe() 2021-03-28 18:06:50 -07:00
mscc net: mscc: ocelot: support PTP Sync one-step timestamping 2021-04-27 14:10:15 -07:00
myricom ethernet: myri10ge: Fix a use after free in myri10ge_sw_tso 2021-03-29 13:41:17 -07:00
natsemi
neterion vxge: avoid -Wemtpy-body warnings 2021-04-22 13:27:36 -07:00
netronome Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-04-26 12:00:00 -07:00
ni
nvidia
nxp of: net: pass the dst buffer to of_get_mac_address() 2021-04-13 14:35:02 -07:00
oki-semi ptp_pch: Move 'pch_*()' prototypes to shared header 2021-03-12 17:09:34 -08:00
packetengines
pasemi
pensando ionic: return -EFAULT if copy_to_user() fails 2021-04-13 15:08:18 -07:00
qlogic qede: Use 'skb_add_rx_frag()' instead of hand coding it 2021-04-05 11:59:33 -07:00
qualcomm net:emac/emac-mac: Fix a use after free in emac_mac_tx_buf_send 2021-04-26 13:07:30 -07:00
rdc
realtek r8169: keep pause settings on interface down/up cycle 2021-04-17 14:02:48 -07:00
renesas Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-04-26 12:00:00 -07:00
rocker net: bridge: switchdev: include local flag in FDB notifications 2021-04-16 15:15:45 -07:00
samsung of: net: pass the dst buffer to of_get_mac_address() 2021-04-13 14:35:02 -07:00
seeq
sfc sfc: adjust efx->xdp_tx_queue_count with the real number of initialized queues 2021-04-27 15:38:29 -07:00
sgi
silan
sis
smsc net: smsc911x: skip acpi_device_id table when !CONFIG_ACPI 2021-04-05 15:05:02 -07:00
socionext of: net: pass the dst buffer to of_get_mac_address() 2021-04-13 14:35:02 -07:00
stmicro Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-04-26 12:00:00 -07:00
sun Fix a typo 2021-03-18 19:46:19 -07:00
synopsys net: dwc-xlgmac: Fix spelling mistake in function name 2021-02-06 11:37:01 -08:00
tehuti net: tehuti: fix error return code in bdx_probe() 2021-03-05 12:59:32 -08:00
ti Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-04-26 12:00:00 -07:00
toshiba net: toshiba: fix the trailing format of some block comments 2021-03-31 14:34:09 -07:00
tundra
via net: ethernet: Fix typo of 'network' in comment 2021-03-30 18:14:11 -07:00
wiznet of: net: pass the dst buffer to of_get_mac_address() 2021-04-13 14:35:02 -07:00
xilinx net: xilinx: drivers need/depend on HAS_IOMEM 2021-04-19 15:36:00 -07:00
xircom xircom: remove redundant error check on variable err 2021-04-07 14:48:32 -07:00
xscale Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-04-26 12:00:00 -07:00
Kconfig net: korina: Make driver COMPILE_TESTable 2021-04-19 15:58:14 -07:00
Makefile net: mana: Add a driver for Microsoft Azure Network Adapter (MANA) 2021-04-19 15:24:25 -07:00
dnet.c
dnet.h
ec_bhf.c
ethoc.c of: net: pass the dst buffer to of_get_mac_address() 2021-04-13 14:35:02 -07:00
fealnx.c net: fealnx: use module_pci_driver to simplify the code 2021-04-07 15:15:02 -07:00
jme.c
jme.h
korina.c korina: Fix build. 2021-04-20 16:40:08 -07:00
lantiq_etop.c
lantiq_xrx200.c of: net: pass the dst buffer to of_get_mac_address() 2021-04-13 14:35:02 -07:00