public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev, Peiyang Wang <wangpeiyang1@huawei.com>,
	Jijie Shao <shaojijie@huawei.com>,
	Simon Horman <horms@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.1 28/98] net: hns3: fix kernel crash when uninstalling driver
Date: Tue, 12 Nov 2024 11:20:43 +0100	[thread overview]
Message-ID: <20241112101845.344732945@linuxfoundation.org> (raw)
In-Reply-To: <20241112101844.263449965@linuxfoundation.org>

6.1-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Peiyang Wang <wangpeiyang1@huawei.com>

[ 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 <wangpeiyang1@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20241101091507.3644584-1-shaojijie@huawei.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/hisilicon/hns3/hnae3.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.c b/drivers/net/ethernet/hisilicon/hns3/hnae3.c
index 67b0bf310daaa..9a63fbc694083 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.c
@@ -25,8 +25,11 @@ void hnae3_unregister_ae_algo_prepare(struct hnae3_ae_algo *ae_algo)
 		pci_id = pci_match_id(ae_algo->pdev_id_table, ae_dev->pdev);
 		if (!pci_id)
 			continue;
-		if (IS_ENABLED(CONFIG_PCI_IOV))
+		if (IS_ENABLED(CONFIG_PCI_IOV)) {
+			device_lock(&ae_dev->pdev->dev);
 			pci_disable_sriov(ae_dev->pdev);
+			device_unlock(&ae_dev->pdev->dev);
+		}
 	}
 }
 EXPORT_SYMBOL(hnae3_unregister_ae_algo_prepare);
-- 
2.43.0




  parent reply	other threads:[~2024-11-12 10:28 UTC|newest]

Thread overview: 109+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-12 10:20 [PATCH 6.1 00/98] 6.1.117-rc1 review Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 01/98] arm64: dts: rockchip: Fix rt5651 compatible value on rk3399-eaidk-610 Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 02/98] arm64: dts: rockchip: Fix rt5651 compatible value on rk3399-sapphire-excavator Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 03/98] arm64: dts: rockchip: Remove hdmis 2nd interrupt on rk3328 Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 04/98] arm64: dts: rockchip: Fix wakeup prop names on PineNote BT node Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 05/98] arm64: dts: rockchip: Fix bluetooth properties on Rock960 boards Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 06/98] arm64: dts: rockchip: Remove #cooling-cells from fan on Theobroma lion Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 07/98] arm64: dts: rockchip: Fix LED triggers on rk3308-roc-cc Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 08/98] arm64: dts: imx8qm: Fix VPU core alias name Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 09/98] arm64: dts: imx8qxp: Add VPU subsystem file Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 10/98] arm64: dts: imx8-ss-vpu: Fix imx8qm VPU IRQs Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 11/98] arm64: dts: imx8mp: correct sdhc ipg clk Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 12/98] ARM: dts: rockchip: fix rk3036 acodec node Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 13/98] ARM: dts: rockchip: drop grf reference from rk3036 hdmi Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 14/98] ARM: dts: rockchip: Fix the spi controller on rk3036 Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 15/98] ARM: dts: rockchip: Fix the realtek audio codec on rk3036-kylin Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 16/98] HID: core: zero-initialize the report buffer Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 17/98] platform/x86/amd/pmc: Detect when STB is not available Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 18/98] sunrpc: handle -ENOTCONN in xs_tcp_setup_socket() Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 19/98] NFSv3: only use NFS timeout for MOUNT when protocols are compatible Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 20/98] NFSv3: handle out-of-order write replies Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 21/98] nfs: avoid i_lock contention in nfs_clear_invalid_mapping Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 22/98] security/keys: fix slab-out-of-bounds in key_task_permission Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 23/98] net: enetc: set MAC address to the VF net_device Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 24/98] sctp: properly validate chunk size in sctp_sf_ootb() Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 25/98] can: c_can: fix {rx,tx}_errors statistics Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 26/98] ice: change q_index variable type to s16 to store -1 value Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 27/98] i40e: fix race condition by adding filters intermediate sync state Greg Kroah-Hartman
2024-11-12 10:20 ` Greg Kroah-Hartman [this message]
2024-11-12 10:20 ` [PATCH 6.1 29/98] net: phy: ti: add PHY_RST_AFTER_CLK_EN flag Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 30/98] net: stmmac: Fix unbalanced IRQ wake disable warning on single irq case Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 31/98] virtio_net: Add hash_key_length check Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 32/98] net: arc: fix the device for dma_map_single/dma_unmap_single Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 33/98] net: arc: rockchip: fix emac mdio node support Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 34/98] Revert "ALSA: hda/conexant: Mute speakers at suspend / shutdown" Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 35/98] media: stb0899_algo: initialize cfr before using it Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 36/98] media: dvbdev: prevent the risk of out of memory access Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 37/98] media: dvb_frontend: dont play tricks with underflow values Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 38/98] media: adv7604: prevent underflow condition when reporting colorspace Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 39/98] scsi: sd_zbc: Use kvzalloc() to allocate REPORT ZONES buffer Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 40/98] ALSA: firewire-lib: fix return value on fail in amdtp_tscm_init() Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 41/98] tools/lib/thermal: Fix sampling handler context ptr Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 42/98] thermal/of: support thermal zones w/o trips subnode Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 43/98] ASoC: stm32: spdifrx: fix dma channel release in stm32_spdifrx_remove Greg Kroah-Hartman
2024-11-12 10:20 ` [PATCH 6.1 44/98] media: ar0521: dont overflow when checking PLL values Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 45/98] media: s5p-jpeg: prevent buffer overflows Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 46/98] media: cx24116: prevent overflows on SNR calculus Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 47/98] media: pulse8-cec: fix data timestamp at pulse8_setup() Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 48/98] media: v4l2-tpg: prevent the risk of a division by zero Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 49/98] media: v4l2-ctrls-api: fix error handling for v4l2_g_ctrl() Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 50/98] can: mcp251xfd: mcp251xfd_get_tef_len(): fix length calculation Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 51/98] can: mcp251xfd: mcp251xfd_ring_alloc(): fix coalescing configuration when switching CAN modes Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 52/98] ksmbd: fix slab-use-after-free in ksmbd_smb2_session_create Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 53/98] ksmbd: Fix the missing xa_store error check Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 54/98] ksmbd: fix slab-use-after-free in smb3_preauth_hash_rsp Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 55/98] pwm: imx-tpm: Use correct MODULO value for EPWM mode Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 56/98] drm/amdgpu: Adjust debugfs eviction and IB access permissions Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 57/98] drm/amdgpu: add missing size check in amdgpu_debugfs_gprwave_read() Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 58/98] drm/amdgpu: prevent NULL pointer dereference if ATIF is not supported Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 59/98] thermal/drivers/qcom/lmh: Remove false lockdep backtrace Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 60/98] dm cache: correct the number of origin blocks to match the target length Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 61/98] dm cache: fix flushing uninitialized delayed_work on cache_ctr error Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 62/98] dm cache: fix out-of-bounds access to the dirty bitset when resizing Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 63/98] dm cache: optimize dirty bit checking with find_next_bit " Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 64/98] dm cache: fix potential out-of-bounds access on the first resume Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 65/98] dm-unstriped: cast an operand to sector_t to prevent potential uint32_t overflow Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 66/98] ALSA: usb-audio: Add quirk for HP 320 FHD Webcam Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 67/98] ALSA: hda/realtek: Fix headset mic on TUXEDO Gemini 17 Gen3 Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 68/98] posix-cpu-timers: Clear TICK_DEP_BIT_POSIX_TIMER on clone Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 69/98] nfs: Fix KMSAN warning in decode_getfattr_attrs() Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 70/98] net: wwan: t7xx: Fix off-by-one error in t7xx_dpmaif_rx_buf_alloc() Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 71/98] net: vertexcom: mse102x: Fix possible double free of TX skb Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 72/98] mptcp: use sock_kfree_s instead of kfree Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 73/98] arm64: Kconfig: Make SME depend on BROKEN for now Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 74/98] btrfs: reinitialize delayed ref list after deleting it from the list Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 75/98] riscv/purgatory: align riscv_kernel_entry Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 76/98] bnxt_re: avoid shift undefined behavior in bnxt_qplib_alloc_init_hwq Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 77/98] Revert "wifi: mac80211: fix RCU list iterations" Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 78/98] net: do not delay dst_entries_add() in dst_release() Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 79/98] kselftest/arm64: Initialise current at build time in signal tests Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 80/98] media: uvcvideo: Skip parsing frames of type UVC_VS_UNDEFINED in uvc_parse_format Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 81/98] filemap: Fix bounds checking in filemap_read() Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 82/98] fs/proc: fix compile warning about variable vmcore_mmap_ops Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 83/98] signal: restore the override_rlimit logic Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 84/98] usb: musb: sunxi: Fix accessing an released usb phy Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 85/98] usb: dwc3: fix fault at system suspend if device was already runtime suspended Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 86/98] usb: typec: fix potential out of bounds in ucsi_ccg_update_set_new_cam_cmd() Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 87/98] USB: serial: io_edgeport: fix use after free in debug printk Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 88/98] USB: serial: qcserial: add support for Sierra Wireless EM86xx Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 89/98] USB: serial: option: add Fibocom FG132 0x0112 composition Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 90/98] USB: serial: option: add Quectel RG650V Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 91/98] irqchip/gic-v3: Force propagation of the active state with a read-back Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 92/98] ocfs2: remove entry once instead of null-ptr-dereference in ocfs2_xa_remove() Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 93/98] ucounts: fix counter leak in inc_rlimit_get_ucounts() Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 94/98] ASoC: amd: yc: fix internal mic on Xiaomi Book Pro 14 2022 Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 95/98] net: sched: use RCU read-side critical section in taprio_dump() Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 96/98] hv_sock: Initializing vsk->trans to NULL to prevent a dangling pointer Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 97/98] vsock/virtio: Initialization of the dangling pointer occurring in vsk->trans Greg Kroah-Hartman
2024-11-12 10:21 ` [PATCH 6.1 98/98] media: amphion: Fix VPU core alias name Greg Kroah-Hartman
2024-11-12 20:56 ` [PATCH 6.1 00/98] 6.1.117-rc1 review Pavel Machek
2024-11-12 23:17 ` Shuah Khan
2024-11-13  0:22 ` Florian Fainelli
2024-11-13  0:38 ` Ron Economos
2024-11-13 11:23 ` Naresh Kamboju
2024-11-13 13:29 ` Mark Brown
2024-11-13 18:35 ` Peter Schneider
2024-11-13 19:58 ` Jon Hunter
2024-11-14 10:50 ` [PATCH 6.1] " Hardik Garg
2024-11-28 18:05 ` [PATCH 6.1 00/98] " Pavel Machek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241112101845.344732945@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=horms@kernel.org \
    --cc=pabeni@redhat.com \
    --cc=patches@lists.linux.dev \
    --cc=sashal@kernel.org \
    --cc=shaojijie@huawei.com \
    --cc=stable@vger.kernel.org \
    --cc=wangpeiyang1@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox