BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Dipayaan Roy" <dipayanroy@linux.microsoft.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net-next,v9 2/2] net: mana: force full-page RX buffers via ethtool private flag
Date: Fri, 08 May 2026 21:35:44 +0000	[thread overview]
Message-ID: <20260508213545.60980C2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260508142921.497921-3-dipayanroy@linux.microsoft.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Forcing `apc->port_is_up = true` in the `mana_attach` error path causes a guaranteed NULL pointer dereference in the reset worker.
--

commit d36beb9b51f56b9797284c9fa1dd515410680980
Author: Dipayaan Roy <dipayanroy@linux.microsoft.com>
Subject: net: mana: force full-page RX buffers via ethtool private flag

This patch adds an ethtool private flag full-page-rx that allows the
user to force one RX buffer per page, bypassing the page_pool fragment path
on ARM64 platforms with 4K PAGE_SIZE.

> diff --git a/drivers/net/ethernet/microsoft/mana/mana_ethtool.c b/drivers/net/ethernet/microsoft/mana/mana_ethtool.c
> index 7e79681634db3..f22bbb3259489 100644
> --- a/drivers/net/ethernet/microsoft/mana/mana_ethtool.c
> +++ b/drivers/net/ethernet/microsoft/mana/mana_ethtool.c
[ ... ]
> @@ -590,6 +609,88 @@ static int mana_get_link_ksettings(struct net_device *ndev,
[ ... ]
> +static int mana_set_priv_flags(struct net_device *ndev, u32 priv_flags)
> +{
[ ... ]
> +		err = mana_attach(ndev);
> +		if (err) {
> +			netdev_err(ndev, "mana_attach failed: %d\n", err);
> +			apc->priv_flags = old_priv_flags;
> +
> +			/* Restore 'port_is_up' so the reset work handler
> +			 * can properly detach/attach. Without this,
> +			 * the handler sees port_is_up=false and skips
> +			 * queue allocation, leaving the port dead.
> +			 */
> +			apc->port_is_up = true;
> +			schedule_port_reset = true;
> +		}

Can this cause a NULL pointer dereference in the reset worker?

If mana_attach() fails, its error path cleans up the partially allocated state.
Specifically, if mana_alloc_queues() fails, it calls mana_cleanup_port_context(),
which frees the tx_qp array and sets apc->tx_qp = NULL.

When apc->port_is_up is forced to true and the reset work is scheduled here:

mana_set_priv_flags()
  err = mana_attach(ndev);
  if (err) {
      ...
      apc->port_is_up = true;
      schedule_port_reset = true;
  }

The reset worker will eventually call mana_detach(). Because apc->port_is_up
is true, mana_detach() will attempt to deallocate the queues:

mana_detach()
  apc->port_st_save = apc->port_is_up;
  ...
  if (apc->port_st_save) {
      err = mana_dealloc_queues(ndev);

If mana_dealloc_queues() unconditionally iterates over apc->num_queues and
accesses apc->tx_qp[i], does this lead to an immediate kernel panic since
apc->tx_qp was already set to NULL during the earlier cleanup?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260508142921.497921-1-dipayanroy@linux.microsoft.com?part=2

      reply	other threads:[~2026-05-08 21:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-08 14:27 [PATCH net-next,v9 0/2] net: mana: add ethtool private flag for full-page RX buffers Dipayaan Roy
2026-05-08 14:27 ` [PATCH net-next,v9 1/2] net: mana: refactor mana_get_strings() and mana_get_sset_count() to use switch Dipayaan Roy
2026-05-08 14:27 ` [PATCH net-next,v9 2/2] net: mana: force full-page RX buffers via ethtool private flag Dipayaan Roy
2026-05-08 21:35   ` sashiko-bot [this message]

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=20260508213545.60980C2BCB0@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=dipayanroy@linux.microsoft.com \
    --cc=sashiko@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox