All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Daniel Machon" <daniel.machon@microchip.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net-next v5 08/13] net: lan966x: add shutdown callback to stop FDMA on reboot
Date: Sat, 30 May 2026 00:44:37 +0000	[thread overview]
Message-ID: <20260530004437.CCB671F00898@smtp.kernel.org> (raw)
In-Reply-To: <20260520-lan966x-pci-fdma-v5-8-ca56197ae05b@microchip.com>

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:

New issues:
- [High] Calling napi_disable() unconditionally during shutdown causes a NULL pointer dereference if the device tree contains no valid ports.
- [High] The lan966x_shutdown() callback disables hardware channels before stopping the network stack and NAPI, allowing concurrent traffic to re-activate the DMA channels.

Pre-existing issues:
- [Critical] The driver's `remove` method tears down the FDMA structures before unregistering the network devices, leading to a Use-After-Free upon concurrent transmission.
- [High] NAPI is deleted without being disabled in the probe error path if fdma_init fails.
--

commit 4567cfb4a8261113fe86f623b6d21c6d3a34dd6b
Author: Daniel Machon <daniel.machon@microchip.com>

net: lan966x: add shutdown callback to stop FDMA on reboot

This commit adds a shutdown callback to stop the FDMA engine when the host
reboots. It masks FDMA interrupts and disables the RX and TX channels.
This prevents the shared PCIe INTx from asserting before the driver
re-probes on the card.

> diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
> --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
> +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c

[ ... ]

> static void lan966x_remove(struct platform_device *pdev)
> {
> 	struct lan966x *lan966x = platform_get_drvdata(pdev);
> 
> 	lan966x_taprio_deinit(lan966x);
> 	lan966x_vcap_deinit(lan966x);
> 	lan966x->ops->fdma_deinit(lan966x);
> 	lan966x_cleanup_ports(lan966x);

[Severity: Critical]
This is a pre-existing issue, but does the remove method tear down FDMA
structures before unregistering the network devices?

Because lan966x_cleanup_ports() has not yet unregistered the netdevs, they
remain active. Could a concurrent frame transmission call lan966x_fdma_xmit(),
access the freed DMA coherent memory, and result in a use-after-free?

> 
> 	cancel_delayed_work_sync(&lan966x->stats_work);
> 	destroy_workqueue(lan966x->stats_queue);

[ ... ]

> @@ -1313,9 +1313,27 @@ static void lan966x_remove(struct platform_device *pdev)
>  	debugfs_remove_recursive(lan966x->debugfs_root);
>  }
>  
> +static void lan966x_shutdown(struct platform_device *pdev)
> +{
> +	struct lan966x *lan966x = platform_get_drvdata(pdev);
> +
> +	if (!lan966x->fdma)
> +		return;
> +
> +	lan966x_fdma_rx_disable(&lan966x->rx);
> +	lan966x_fdma_tx_disable(&lan966x->tx);

[Severity: High]
Should the network stack and NAPI be disabled before turning off the
hardware channels?

If the networking stack invokes ndo_start_xmit concurrently, could the driver
observe the channel is deactivated and write to FDMA_CH_ACTIVATE to turn the
DMA engine back on? This might defeat the purpose of the shutdown callback
and risk DMA memory corruption.

> +
> +	napi_synchronize(&lan966x->napi);
> +	napi_disable(&lan966x->napi);

[Severity: High]
What happens here if the device tree contains no valid ports?

If the ports list is empty, lan966x_fdma_netdev_init() is never called, leaving
lan966x->napi zero-initialized (meaning napi->dev is NULL). Does calling
napi_disable() here unconditionally attempt to acquire netdev_lock(n->dev) and
cause a NULL pointer dereference?

> +
> +	lan_wr(0, lan966x, FDMA_INTR_ENA);
> +	lan_wr(0, lan966x, FDMA_INTR_DB_ENA);
> +}

[Severity: High]
This is a pre-existing issue, but I noticed a potential problem in
lan966x_probe() during error handling.

If lan966x->ops->fdma_init() fails after the global NAPI instance is
initialized and enabled by lan966x_port_init(), the error path jumps to
cleanup_ptp and bypasses cleanup_fdma.

This leads to lan966x_cleanup_ports() removing the NAPI instance via
netif_napi_del() without first calling napi_disable(). Does deleting an
enabled NAPI instance trigger a WARN_ON and potentially lead to a
use-after-free if a poll happens concurrently?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260520-lan966x-pci-fdma-v5-0-ca56197ae05b@microchip.com?part=8

  parent reply	other threads:[~2026-05-30  0:44 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-20  8:12 [PATCH net-next v5 00/13] net: lan966x: add support for PCIe FDMA Daniel Machon
2026-05-20  8:12 ` [PATCH net-next v5 01/13] MAINTAINERS: add FDMA library to Sparx5 SoC entry Daniel Machon
2026-05-20  8:12 ` [PATCH net-next v5 02/13] net: microchip: fdma: rename contiguous dataptr helpers Daniel Machon
2026-05-20  8:12 ` [PATCH net-next v5 03/13] net: microchip: fdma: add PCIe ATU support Daniel Machon
2026-05-30  0:44   ` sashiko-bot
2026-05-20  8:12 ` [PATCH net-next v5 04/13] net: lan966x: add FDMA LLP register write helper Daniel Machon
2026-05-30  0:44   ` sashiko-bot
2026-05-20  8:12 ` [PATCH net-next v5 05/13] net: lan966x: export FDMA helpers for reuse Daniel Machon
2026-05-30  0:44   ` sashiko-bot
2026-05-20  8:12 ` [PATCH net-next v5 06/13] net: lan966x: add FDMA ops dispatch for PCIe support Daniel Machon
2026-05-30  0:44   ` sashiko-bot
2026-05-20  8:12 ` [PATCH net-next v5 07/13] net: lan966x: clear FDMA interrupt stickies after switch reset Daniel Machon
2026-05-20  8:12 ` [PATCH net-next v5 08/13] net: lan966x: add shutdown callback to stop FDMA on reboot Daniel Machon
2026-05-23  1:45   ` Jakub Kicinski
2026-05-30  0:44   ` sashiko-bot [this message]
2026-05-20  8:12 ` [PATCH net-next v5 09/13] net: lan966x: add PCIe FDMA support Daniel Machon
2026-05-23  1:56   ` Jakub Kicinski
2026-05-30  0:44   ` sashiko-bot
2026-05-20  8:12 ` [PATCH net-next v5 10/13] net: lan966x: add PCIe FDMA MTU change support Daniel Machon
2026-05-30  0:44   ` sashiko-bot
2026-05-20  8:12 ` [PATCH net-next v5 11/13] net: lan966x: add PCIe FDMA XDP support Daniel Machon
2026-05-23  2:01   ` Jakub Kicinski
2026-05-20  8:12 ` [PATCH net-next v5 12/13] misc: lan966x-pci: dts: extend cpu reg to cover PCIE DBI space Daniel Machon
2026-05-23  2:01   ` Jakub Kicinski
2026-05-20  8:12 ` [PATCH net-next v5 13/13] misc: lan966x-pci: dts: add fdma interrupt to overlay Daniel Machon
2026-05-21 14:12 ` [PATCH net-next v5 00/13] net: lan966x: add support for PCIe FDMA Daniel Machon

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=20260530004437.CCB671F00898@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel.machon@microchip.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.