mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: nb@tipi-net.de
Cc: netdev@vger.kernel.org, opendmb@gmail.com,
	florian.fainelli@broadcom.com, justin.chen@broadcom.com,
	bcm-kernel-feedback-list@broadcom.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] net: bcmgenet: restore the hardware filters on open
Date: Mon, 14 Sep 2026 19:02:58 +0000	[thread overview]
Message-ID: <178941257876.22033.16482190060523760551@kernel.org> (raw)
In-Reply-To: <20260913190052.939955-1-nb@tipi-net.de>

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

Critical: 0 · High: 0 · Medium: 1 · Low: 0

- [Medium] The commit message of "net: bcmgenet: restore the hardware
  filters on open" describes only the loss of user-configured rxnfc…

--

net: bcmgenet: restore the hardware filters on open

The patch splits bcmgenet_hfb_init() into a list-initialisation part that
now runs once from bcmgenet_probe(), and a new bcmgenet_hfb_restore() that
clears the hardware filter block and re-programs the configured rxnfc
rules.  bcmgenet_open() and bcmgenet_resume() both call the restore helper.

> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> index a2305e6428d1f..b916080f4ff17 100644
> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c

[ ... ]

> @@ -4075,6 +4084,7 @@ static int bcmgenet_probe(struct platform_device *pdev)
>  
>  	/* Mii wait queue */
>  	init_waitqueue_head(&priv->wq);
> +	bcmgenet_hfb_init(priv);
>  	INIT_WORK(&priv->bcmgenet_irq_work, bcmgenet_irq_task);

[Severity: Medium]
Does this hunk also fix a NULL pointer dereference that the changelog does
not mention?

Before this change, priv->rxnfc_list was only initialised from
bcmgenet_open(), and alloc_etherdev_mqs() hands back zeroed private data,
so between register_netdev() and the first ifup the list head is
{NULL, NULL}.

The ethtool rxnfc getters have no netif_running() gate; bcmgenet_begin()
only enables the clock:

drivers/net/ethernet/broadcom/genet/bcmgenet.c:bcmgenet_begin() {
	struct bcmgenet_priv *priv = netdev_priv(dev);

	/* Turn on the clock */
	return clk_prepare_enable(priv->clk);
}

so ETHTOOL_GRXCLSRLCNT reaches bcmgenet_get_rxnfc() ->
bcmgenet_get_num_flows():

drivers/net/ethernet/broadcom/genet/bcmgenet.c:bcmgenet_get_num_flows() {
	struct list_head *pos;
	int res = 0;

	list_for_each(pos, &priv->rxnfc_list)
		res++;
	...
}

with pos = head->next == NULL, the list_is_head() test does not match the
head, and pos->next is then dereferenced.

ETHTOOL_GRXCLSRLCNT, ETHTOOL_GRXCLSRULE and ETHTOOL_GRXCLSRLALL are
exempted from the ns_capable(CAP_NET_ADMIN) check in dev_ethtool():

net/ethtool/ioctl.c:dev_ethtool() {
	case ETHTOOL_GRXCLSRLCNT:
	case ETHTOOL_GRXCLSRULE:
	case ETHTOOL_GRXCLSRLALL:
		break;
	default:
		if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
			return -EPERM;
	...
}

so an unprivileged local user running "ethtool -n eth0" on a bcmgenet
interface that was never brought up could hit this.

The changelog only describes the lost rules:

	Every rule the user configured is silently lost

	Initialise the lists once at probe and restore the rules on open, as
	bcmgenet_resume() already does.

Could the changelog also mention this crash, since it affects how the
patch is triaged for stable?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260913190052.939955-1-nb%40tipi-net.de

  reply	other threads:[~2026-09-14 19:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-13 19:00 Nicolai Buchwitz
2026-09-14 19:02 ` netdev-bot+sashiko [this message]
2026-09-14 19:28 ` Justin Chen
2026-09-14 19:30 ` Florian Fainelli
2026-09-15  2:30 ` patchwork-bot+netdevbpf
2026-09-15  8:24 Xiang Mei
2026-09-15  8:26 ` Xiang Mei

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=178941257876.22033.16482190060523760551@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=justin.chen@broadcom.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nb@tipi-net.de \
    --cc=netdev@vger.kernel.org \
    --cc=opendmb@gmail.com \
    --cc=pabeni@redhat.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

all inboxes | Powered by JetHome®