mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: tariqt@nvidia.com
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, netdev@vger.kernel.org, pabeni@redhat.com,
	agoldberger@nvidia.com, cratiu@nvidia.com, gal@nvidia.com,
	leon@kernel.org, linux-kernel@vger.kernel.org,
	linux-rdma@vger.kernel.org, mbloch@nvidia.com, moshe@nvidia.com,
	ohartoov@nvidia.com, saeedm@nvidia.com, shayd@nvidia.com
Subject: Re: [PATCH net-next 01/13] net/mlx5e: Assign a random MAC to any netdev with a zero MAC address
Date: Thu, 24 Sep 2026 17:45:51 +0000	[thread overview]
Message-ID: <179027195115.2160803.12005137371690023734@kernel.org> (raw)
In-Reply-To: <20260923103830.1183-2-tariqt@nvidia.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] The commit message for "net/mlx5e: Assign a random MAC to any
  netdev with a zero MAC address" describes a bug ('A vport group…

Pre-existing issues:
- [Medium] In mlx5e_set_netdev_dev_addr()
  (drivers/net/ethernet/mellanox/mlx5/core/en_main.c), the local `u8…

--

net/mlx5e: Assign a random MAC to any netdev with a zero MAC address

This commit removes the vport_group_manager exception from
mlx5e_set_netdev_dev_addr(). As a result, any mlx5e netdev whose queried
MAC is all zeros gets a random MAC instead of keeping the zero address.

> mlx5e_set_netdev_dev_addr() falls back to a random MAC only when the
> queried address is all-zeros AND the device is not a vport group
> manager.  A vport group manager that comes up with a zero MAC is
> therefore left with an invalid all-zero address.
>
> The vport_group_manager exception is unnecessary: a zero MAC is always
> invalid, regardless of device type. Drop the condition and assign a
> random MAC whenever the queried address is zero, so every netdev comes
> up with a valid address.

[Severity: Low]
The message treats the old behaviour as a bug. However, it has no Fixes:
tag and doesn't say which configuration triggers it.

The check being removed was added on purpose in commit 108805fc196e
("net/mlx5e: Assign random MAC address if needed"). That commit only
covers SR-IOV VFs loaded without an admin-assigned MAC. It used
vport_group_manager (PF/ECPF, which is expected to have a burned-in MAC)
as a stand-in for "not a VF". The new message calls the exception
"unnecessary" but doesn't explain why it was there.

Another commit in the series, "net/mlx5: E-switch, correct stale VF/PF
wording in esw-allowed comments", suggests the real motivation is new FW
that lets a VF act as a nested e-switch manager. If so, this is a new
case rather than a regression.

Could the message do one of these?

  - If a zero-MAC group manager can happen with existing FW, add:

      Fixes: 108805fc196e ("net/mlx5e: Assign random MAC address if needed")

  - Otherwise, say that this is preparation for VF e-switch managers.

The message also leaves out the visible effect on affected devices.
addr_assign_type changes from NET_ADDR_PERM to NET_ADDR_RANDOM, and the
MAC changes on every driver load. Other users of mlx5_query_mac_address()
still see the firmware's zero address, for example the getpermhwaddr path
in en_dcbnl.c and the default GID in rdma.c.

> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> index fc110a7d16e8d..b0765f07cc3a7 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> @@ -5430,8 +5430,7 @@ static void mlx5e_set_netdev_dev_addr(struct net_device *netdev)
>  	u8 addr[ETH_ALEN];
>  
>  	mlx5_query_mac_address(priv->mdev, addr);
> -	if (is_zero_ether_addr(addr) &&
> -	    !MLX5_CAP_GEN(priv->mdev, vport_group_manager)) {
> +	if (is_zero_ether_addr(addr)) {

[Severity: Medium]
This is a pre-existing issue and was not introduced by this patch.
Since the patch rewrites this condition, though: what does addr hold if
mlx5_query_mac_address() fails?

addr has no initializer, and the return value of the query is ignored.
The path is:

  _mlx5e_probe()->mlx5e_build_nic_netdev()->mlx5e_set_netdev_dev_addr()
    ->mlx5_query_mac_address()->mlx5_query_nic_vport_mac_address()

mlx5_query_nic_vport_mac_address() in vport.c writes the caller's buffer
only when the command succeeds:

	err = mlx5_cmd_exec_inout(mdev, query_nic_vport_context, in, out);
	if (!err)
		ether_addr_copy(addr, &out_addr[2]);

	return err;

The query can fail with a bad FW status. It can also fail with -ENOLINK
during FW internal error, because mlx5_internal_err_ret_value() includes
MLX5_CMD_OP_QUERY_NIC_VPORT_CONTEXT in the opcodes it handles that way.

In that case is_zero_ether_addr() reads whatever was left on the stack.
Unless those bytes are all zero, the random fallback is skipped and
eth_hw_addr_set(netdev, addr) installs them as the MAC.

Can this give the netdev an invalid address, for example one with the
multicast bit set? Can it also expose 6 bytes of kernel stack through
RTM_GETLINK, the sysfs address file or SIOCGIFHWADDR?

With CONFIG_INIT_STACK_ALL_ZERO the buffer starts zeroed, so after this
patch the failure case gets a random MAC. With INIT_STACK_NONE, the
leftover bytes are installed instead.

The unchecked return value and the uninitialized buffer go back to
537e4d2e6fe3c5 and earlier code. No later patch in the series appears to
touch this function.

To reach the goal that "every netdev comes up with a valid address",
would it help to zero-initialize addr, check the return value, and use
something like this?

	if (err || !is_valid_ether_addr(addr))
		eth_hw_addr_random(netdev);

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260923103830.1183-1-tariqt%40nvidia.com

  reply	other threads:[~2026-09-24 17:45 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-23 10:38 [PATCH net-next 00/13] net/mlx5: Preparations for nested E-switch Tariq Toukan
2026-09-23 10:38 ` [PATCH net-next 01/13] net/mlx5e: Assign a random MAC to any netdev with a zero MAC address Tariq Toukan
2026-09-24 17:45   ` netdev-bot+sashiko [this message]
2026-09-23 10:38 ` [PATCH net-next 02/13] net/mlx5: E-switch, do not leave an unpaired devcom registered Tariq Toukan
2026-09-24 17:45   ` netdev-bot+sashiko
2026-09-23 10:38 ` [PATCH net-next 03/13] net/mlx5: LAG, allocate v2p_map dynamically Tariq Toukan
2026-09-24 17:45   ` netdev-bot+sashiko
2026-09-23 10:38 ` [PATCH net-next 04/13] net/mlx5: LAG, allocate port-indexed scratch buffers dynamically Tariq Toukan
2026-09-24 17:45   ` netdev-bot+sashiko
2026-09-23 10:38 ` [PATCH net-next 05/13] net/mlx5: LAG, drop per-port scratch array in drop-rule setup Tariq Toukan
2026-09-23 10:38 ` [PATCH net-next 06/13] net/mlx5: LAG, size debugfs buffers by port count Tariq Toukan
2026-09-24 17:45   ` netdev-bot+sashiko
2026-09-23 10:38 ` [PATCH net-next 07/13] net/mlx5e: TC, anchor peer-flow reverse index on the duplicated flow Tariq Toukan
2026-09-24 17:45   ` netdev-bot+sashiko
2026-09-23 10:38 ` [PATCH net-next 08/13] net/mlx5e: TC, track peer flows in a vhca_id xarray Tariq Toukan
2026-09-24 17:46   ` netdev-bot+sashiko
2026-09-23 10:38 ` [PATCH net-next 09/13] net/mlx5: E-switch, derive manager vport from device capability Tariq Toukan
2026-09-24 17:46   ` netdev-bot+sashiko
2026-09-23 10:38 ` [PATCH net-next 10/13] net/mlx5: LAG, don't print port mapping to debugfs in MPESW mode Tariq Toukan
2026-09-23 10:38 ` [PATCH net-next 11/13] net/mlx5: LAG, drop stale esw_shared_ingress_acl gate from shared FDB Tariq Toukan
2026-09-23 10:38 ` [PATCH net-next 12/13] net/mlx5: E-switch, correct stale VF/PF wording in esw-allowed comments Tariq Toukan
2026-09-23 10:38 ` [PATCH net-next 13/13] net/mlx5: E-switch, disable host functions for a non PF e-switch manager Tariq Toukan

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=179027195115.2160803.12005137371690023734@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=agoldberger@nvidia.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=cratiu@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gal@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=moshe@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=ohartoov@nvidia.com \
    --cc=pabeni@redhat.com \
    --cc=saeedm@nvidia.com \
    --cc=shayd@nvidia.com \
    --cc=tariqt@nvidia.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®