mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: satishkh@cisco.com
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
	willemb@google.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, sebaddel@cisco.com,
	aradhana@cisco.com, rfaucett@cisco.com
Subject: Re: [PATCH net-next v4 5/6] enic: manage V2 VF station and administrative MAC
Date: Tue, 01 Dec 2026 14:04:54 +0000	[thread overview]
Message-ID: <179613389400.3146.4727108812986852753@kernel.org> (raw)
In-Reply-To: <20261130-b4-enic-sriov-v2-vf-receive-control-v4-5-5858d5a9ecb1@cisco.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] This patch changes the address-assignment type that userspace
  sees for a V2 VF with a provisioned (nonzero) MAC, and the commit…
- [Low] Several new on-stack MAC buffers are plain `u8[ETH_ALEN]` arrays
  with no `__aligned(2)`.
- [Low] This patch adds two driver paths that rewrite netdev->dev_addr in
  place on a registered netdev while holding only RTNL.

--

enic: manage V2 VF station and administrative MAC

This patch moves the V2 VF station address onto the mailbox MAC
operation and treats the PF administrative MAC as authoritative. PF
notifications are handled in a delayed worker, and policy is refreshed
with CMD_GET_MAC_ADDR after registration. The station address is
installed on open and removed on ordinary stop, and perm_addr is
initialized from the address chosen at probe.

> diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
> index 9c4b94a949809..a2186f65c74a8 100644
> --- a/drivers/net/ethernet/cisco/enic/enic_main.c
> +++ b/drivers/net/ethernet/cisco/enic/enic_main.c

[ ... ]

> @@ -1064,6 +1067,501 @@ static int enic_set_mac_addr(struct net_device *netdev, char *addr)

[ ... ]

> +static void enic_vf_admin_mac_work(struct work_struct *work)
> +{
> +	struct enic *enic = container_of(to_delayed_work(work), struct enic,
> +					 vf_admin_mac_work);
> +	u8 policy[ETH_ALEN];
> +	u8 selected[ETH_ALEN];

[Severity: Low]
Should policy[] and selected[] be marked __aligned(2)?

They are passed to ether_addr_copy(), ether_addr_equal() and
eth_hw_addr_set(). include/linux/etherdevice.h documents
ether_addr_copy() with:

 * Please note: dst & src must both be aligned to u16.

Without CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS, both ether_addr_copy()
and ether_addr_equal() access the address through u16 pointer casts. A
plain u8[ETH_ALEN] stack array is only guaranteed byte alignment. ENIC
depends only on PCI, so it can be built for strict-alignment
architectures, where this can trap or need slow fixups.

The same applies to previous_policy[], random_addr[], selected[] and
policy[] in enic_vf_admin_mac_refresh().

This patch already adds __aligned(2) to requested[] in
enic_vf_station_addr_open() and to enic->vf_station_addr. These other
arrays still lack the annotation at the end of the series.

> +	unsigned long delay = 0;
> +	u32 generation = 0;

[ ... ]

> +	changed = !ether_addr_equal(enic->netdev->dev_addr, selected);
> +	enic_vf_station_sync_reset(enic);
> +	eth_hw_addr_set(enic->netdev, selected);

[Severity: Low]
Can a concurrent reader see a torn MAC address here?

This worker runs asynchronously after ENIC_MBOX_PF_SET_ADMIN_MAC_NOTIF.
It rewrites dev_addr in place on a registered netdev while holding only
RTNL:

enic_mbox_vf_handle_admin_mac()
  enic_vf_admin_mac_notify()
    enic_vf_admin_mac_work()
      eth_hw_addr_set()
        __dev_addr_set()   /* memcpy into dev->dev_addr */

The core readers don't take RTNL. netif_get_mac_address()
(SIOCGIFHWADDR) and address_show() (/sys/class/net/*/address) take only
down_read(&dev_addr_sem) and rcu_read_lock(). The core writers
dev_set_mac_address_user() and do_setlink() take
down_write(&dev_addr_sem) for exactly this reason.

Those two lock sets don't overlap. A reader that runs during a PF-driven
change could therefore return a mix of old and new address bytes.

enic_vf_admin_mac_refresh() does the same thing when called from
__enic_open() and enic_admin_chan_reopen(). dev_addr_sem is declared
only in the private net/core/dev.h, so the driver can't simply take it.

[ ... ]

> +static int enic_vf_admin_mac_refresh(struct enic *enic)
> +{

[ ... ]

> +		changed = !ether_addr_equal(enic->netdev->dev_addr, selected);
> +		eth_hw_addr_set(enic->netdev, selected);
> +		if (!zero_policy || changed)
> +			enic->netdev->addr_assign_type = zero_policy ?
> +				NET_ADDR_RANDOM : NET_ADDR_SET;

[Severity: Low]
Is this change to addr_assign_type intended for a provisioned VF MAC?

enic_probe() now calls enic_vf_admin_mac_refresh() before
register_netdev(). For any nonzero CMD_GET_MAC_ADDR value, this sets
NET_ADDR_SET. Probe then copies dev_addr into perm_addr by hand:

enic_probe() {
    ...
	/* Record the initial address while preserving how it was assigned. */
	ether_addr_copy(netdev->perm_addr, netdev->dev_addr);
    ...
}

Before this patch, enic_get_vnic_config() read the same firmware MAC and
installed it with eth_hw_addr_set(). addr_assign_type stayed at
NET_ADDR_PERM, and register_netdevice() filled perm_addr.

/sys/class/net/<if>/addr_assign_type now changes from 0 to 3 for an
address that nothing set through dev_set_mac_address(). The UAPI
describes NET_ADDR_SET as "address is set using dev_set_mac_address()".

Userspace that trusts only NET_ADDR_PERM addresses behaves differently.
For example, systemd's net_id builtin stops producing ID_NET_NAME_MAC.

With a zero policy, perm_addr is a newly generated random address on
every probe. ETHTOOL_GPERMADDR then reports a different permanent
address each time the driver loads.

The commit message does disclose the random case:

    Initialize perm_addr from the selected probe address while retaining its
    assignment type, including NET_ADDR_RANDOM for a generated address.

It doesn't mention that a provisioned address changes from PERM to SET.
Could the commit message describe that change, or should the
provisioned case keep NET_ADDR_PERM?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130-b4-enic-sriov-v2-vf-receive-control-v4-0-5858d5a9ecb1%40cisco.com

  reply	other threads:[~2026-12-01 14:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 13:58 [PATCH net-next v4 0/6] enic: add V2 VF receive control over MBOX Satish Kharat
2026-11-30 13:58 ` [PATCH net-next v4 1/6] net: add netif_rx_mode_schedule_update() Satish Kharat
2026-11-30 13:58 ` [PATCH net-next v4 2/6] enic: serialize V2 VF mailbox requests Satish Kharat
2026-12-01 14:04   ` netdev-bot+sashiko
2026-11-30 13:58 ` [PATCH net-next v4 3/6] enic: recover V2 VF mailbox after request failure Satish Kharat
2026-12-01 14:04   ` netdev-bot+sashiko
2026-11-30 13:58 ` [PATCH net-next v4 4/6] enic: validate V2 VF configuration replies Satish Kharat
2026-12-01 14:04   ` netdev-bot+sashiko
2026-11-30 13:58 ` [PATCH net-next v4 5/6] enic: manage V2 VF station and administrative MAC Satish Kharat
2026-12-01 14:04   ` netdev-bot+sashiko [this message]
2026-11-30 13:58 ` [PATCH net-next v4 6/6] enic: configure V2 VF receive mode over mailbox Satish Kharat
2026-12-01 14:04   ` netdev-bot+sashiko

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=179613389400.3146.4727108812986852753@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=aradhana@cisco.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rfaucett@cisco.com \
    --cc=satishkh@cisco.com \
    --cc=sebaddel@cisco.com \
    --cc=willemb@google.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®