android_kernel_motorola_sm6375/drivers/net
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Peiyang Wang 7ae4e56de7 net: hns3: fix kernel crash when uninstalling driver
[ Upstream commit df3dff8ab6d79edc942464999d06fbaedf8cdd18 ]

When the driver is uninstalled and the VF is disabled concurrently, a
kernel crash occurs. The reason is that the two actions call function
pci_disable_sriov(). The num_VFs is checked to determine whether to
release the corresponding resources. During the second calling, num_VFs
is not 0 and the resource release function is called. However, the
corresponding resource has been released during the first invoking.
Therefore, the problem occurs:

[15277.839633][T50670] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000020
...
[15278.131557][T50670] Call trace:
[15278.134686][T50670]  klist_put+0x28/0x12c
[15278.138682][T50670]  klist_del+0x14/0x20
[15278.142592][T50670]  device_del+0xbc/0x3c0
[15278.146676][T50670]  pci_remove_bus_device+0x84/0x120
[15278.151714][T50670]  pci_stop_and_remove_bus_device+0x6c/0x80
[15278.157447][T50670]  pci_iov_remove_virtfn+0xb4/0x12c
[15278.162485][T50670]  sriov_disable+0x50/0x11c
[15278.166829][T50670]  pci_disable_sriov+0x24/0x30
[15278.171433][T50670]  hnae3_unregister_ae_algo_prepare+0x60/0x90 [hnae3]
[15278.178039][T50670]  hclge_exit+0x28/0xd0 [hclge]
[15278.182730][T50670]  __se_sys_delete_module.isra.0+0x164/0x230
[15278.188550][T50670]  __arm64_sys_delete_module+0x1c/0x30
[15278.193848][T50670]  invoke_syscall+0x50/0x11c
[15278.198278][T50670]  el0_svc_common.constprop.0+0x158/0x164
[15278.203837][T50670]  do_el0_svc+0x34/0xcc
[15278.207834][T50670]  el0_svc+0x20/0x30

For details, see the following figure.

     rmmod hclge              disable VFs
----------------------------------------------------
hclge_exit()            sriov_numvfs_store()
  ...                     device_lock()
  pci_disable_sriov()     hns3_pci_sriov_configure()
                            pci_disable_sriov()
                              sriov_disable()
    sriov_disable()             if !num_VFs :
      if !num_VFs :               return;
        return;                 sriov_del_vfs()
      sriov_del_vfs()             ...
        ...                       klist_put()
        klist_put()               ...
        ...                     num_VFs = 0;
      num_VFs = 0;        device_unlock();

In this patch, when driver is removing, we get the device_lock()
to protect num_VFs, just like sriov_numvfs_store().

Fixes: 0dd8a25f355b ("net: hns3: disable sriov before unload hclge layer")
Signed-off-by: Peiyang Wang <[email protected]>
Signed-off-by: Jijie Shao <[email protected]>
Reviewed-by: Simon Horman <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Paolo Abeni <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
2024-11-17 14:58:50 +01:00
..
appletalk
arcnet arcnet: restoring support for multiple Sohard Arcnet cards 2023-12-13 18:18:12 +01:00
bonding net: bonding: correctly annotate RCU in bond_should_notify_peers() 2024-08-19 05:33:41 +02:00
caif drivers: net: Fix Kconfig indentation, continued 2024-11-08 16:20:35 +01:00
can can: c_can: fix {rx,tx}_errors statistics 2024-11-17 14:58:50 +01:00
dsa net: dsa: vsc73xx: fix possible subblocks range of CAPT block 2024-09-12 11:03:53 +02:00
ethernet net: hns3: fix kernel crash when uninstalling driver 2024-11-17 14:58:50 +01:00
fddi
fjes fjes: fix memleaks in fjes_hw_setup 2024-02-23 08:24:51 +01:00
hamradio
hippi
hyperv hv_netvsc: Fix VF namespace also in synthetic NIC NETDEV_REGISTER event 2024-11-08 16:20:51 +01:00
ieee802154 net: ieee802154: mcr20a: Use IRQF_NO_AUTOEN flag in request_irq() 2024-11-08 16:20:36 +01:00
ipvlan ipvlan: Dont Use skb->sk in ipvlan_process_v{4,6}_outbound 2024-06-16 13:28:48 +02:00
netdevsim
phy net: phy: vitesse: repair vsc73xx autonegotiation 2024-11-08 16:20:24 +01:00
plip
ppp ppp: fix ppp_async_encode() illegal access 2024-11-08 16:20:46 +01:00
slip slip: make slhc_remember() more robust against malicious packets 2024-11-08 16:20:46 +01:00
team team: Fix use-after-free when an option instance allocation fails 2023-12-20 15:41:25 +01:00
usb net: usb: usbnet: fix name regression 2024-11-08 16:20:51 +01:00
vmxnet3
wan net: remove unneeded break 2024-02-23 08:25:04 +01:00
wimax
wireless wifi: iwlegacy: Clear stale interrupts before resuming device 2024-11-08 16:20:53 +01:00
xen-netback xen-netback: properly sync TX responses 2024-02-23 08:25:11 +01:00
dummy.c
eql.c
geneve.c geneve: fix header validation in geneve[6]_xmit_skb 2024-05-02 16:18:28 +02:00
gtp.c gtp: allow -1 to be specified as file description from userspace 2024-11-08 16:20:52 +01:00
ifb.c
Kconfig drivers: net: Fix Kconfig indentation, continued 2024-11-08 16:20:35 +01:00
LICENSE.SRC
loopback.c
macsec.c macsec: don't increment counters for an unrelated SA 2024-11-08 16:20:49 +01:00
macvlan.c macvlan: Don't propagate promisc change to lower dev in passthru 2023-11-28 16:50:17 +00:00
macvtap.c
Makefile
mdio.c
mii.c
net_failover.c
netconsole.c net: netconsole: Disable target before netpoll cleanup 2024-08-19 05:33:35 +02:00
nlmon.c
ntb_netdev.c
rionet.c
sb1000.c
Space.c
sungem_phy.c
tap.c tap: add missing verification for short frame 2024-07-27 10:38:33 +02:00
thunderbolt.c
tun.c tun: add missing verification for short frame 2024-07-27 10:38:33 +02:00
veth.c
virtio_net.c virtio_net: Fix napi_skb_cache_put warning 2024-09-12 11:03:50 +02:00
vrf.c
vsockmon.c
vxlan.c vxlan: Fix regression when dropping packets due to invalid src addresses 2024-07-05 09:08:11 +02:00
xen-netfront.c