mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: florian.fainelli@broadcom.com
Cc: netdev@vger.kernel.org, nb@tipi-net.de, opendmb@gmail.com,
	bcm-kernel-feedback-list@broadcom.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, zakkemble@gmail.com, horms@kernel.org,
	ryotkkr98@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v2 4/5] net: bcmgenet: validate Ethernet address in bcmgenet_set_mac_addr
Date: Fri, 25 Sep 2026 23:09:40 +0000	[thread overview]
Message-ID: <179037778070.2160803.14102576528369806489@kernel.org> (raw)
In-Reply-To: <20260921220021.281418-5-florian.fainelli@broadcom.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] bcmgenet_set_mac_addr()
  (drivers/net/ethernet/broadcom/genet/bcmgenet.c:3628-3644) now hand-…

--

net: bcmgenet: validate Ethernet address in bcmgenet_set_mac_addr

This adds an is_valid_ether_addr() check to bcmgenet_set_mac_addr() so
that an invalid MAC address (all zeroes, or a multicast address) is
rejected with -EADDRNOTAVAIL instead of being programmed while the
interface is down.

> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> index bfb74dca55d6f..e9d9d3d7b6369 100644
> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> @@ -3634,6 +3634,9 @@ static int bcmgenet_set_mac_addr(struct net_device *dev, void *p)
>  	if (netif_running(dev))
>  		return -EBUSY;
>  
> +	if (!is_valid_ether_addr(addr->sa_data))
> +		return -EADDRNOTAVAIL;
> +
>  	eth_hw_addr_set(dev, addr->sa_data);
>  
>  	return 0;

[Severity: Low]
This isn't a bug, but with this hunk bcmgenet_set_mac_addr() now open-codes
exactly what the core helpers already do.

net/ethernet/eth.c:

	int eth_prepare_mac_addr_change(struct net_device *dev, void *p)
	{
		struct sockaddr *addr = p;

		if (!(dev->priv_flags & IFF_LIVE_ADDR_CHANGE) && netif_running(dev))
			return -EBUSY;
		if (!is_valid_ether_addr(addr->sa_data))
			return -EADDRNOTAVAIL;
		return 0;
	}

	void eth_commit_mac_addr_change(struct net_device *dev, void *p)
	{
		struct sockaddr *addr = p;

		eth_hw_addr_set(dev, addr->sa_data);
	}

The resulting body of bcmgenet_set_mac_addr() is then equivalent to
eth_mac_addr(). Would calling eth_prepare_mac_addr_change() followed by
eth_commit_mac_addr_change() (keeping the driver-specific comment about the
UniMAC RX/TX enable bits) be preferable to duplicating the validation here?

One small difference: the driver copy tests netif_running() unconditionally
and so does not honour the IFF_LIVE_ADDR_CHANGE exemption that the core
helper checks. bcmgenet does not set that private flag today, so there is no
behavioural change now, but the duplicated checks will not track future
changes to the core validation rules.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260921220021.281418-1-florian.fainelli%40broadcom.com

  reply	other threads:[~2026-09-25 23:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-21 22:00 [PATCH net v2 0/5] net: bcmgenet: Collection of bug fixes Florian Fainelli
2026-09-21 22:00 ` [PATCH net v2 1/5] net: bcmgenet: fix 64-bit RTNL stats reading in ethtool on 32-bit systems Florian Fainelli
2026-09-21 22:00 ` [PATCH net v2 2/5] net: bcmgenet: initialize u64 stats seq counter for all queues Florian Fainelli
2026-09-21 22:00 ` [PATCH net v2 3/5] net: bcmgenet: do not skip WoL power up on GENET V1 Florian Fainelli
2026-09-25 23:09   ` netdev-bot+sashiko
2026-09-21 22:00 ` [PATCH net v2 4/5] net: bcmgenet: validate Ethernet address in bcmgenet_set_mac_addr Florian Fainelli
2026-09-25 23:09   ` netdev-bot+sashiko [this message]
2026-09-21 22:00 ` [PATCH net v2 5/5] net: bcmgenet: mask DMA_TIMEOUT_MASK when reading DMA_RING0_TIMEOUT Florian Fainelli
2026-09-24  2:20 ` [PATCH net v2 0/5] net: bcmgenet: Collection of bug fixes patchwork-bot+netdevbpf

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=179037778070.2160803.14102576528369806489@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=horms@kernel.org \
    --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 \
    --cc=ryotkkr98@gmail.com \
    --cc=zakkemble@gmail.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®