From: sashiko-bot@kernel.org
To: "Nagadheeraj Rottela" <nagadheeraj.rottela@amd.com>
Cc: conor+dt@kernel.org, robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH 14/20] net: dsa: xilinx: program MAC frame filter and per-port nibbles
Date: Sat, 08 Aug 2026 10:46:53 +0000 [thread overview]
Message-ID: <20260808104654.86A451F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260807104431.157230-15-nagadheeraj.rottela@amd.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] Use-After-Free and API violation when broadcasting NETDEV_CHANGEADDR on unregistered user ports.
- [High] Silent mutation of MAC address during NETDEV_REGISTER causes state divergence across subsystems.
- [High] Bypassing DSA MAC management leaks resources and drops packets after a conduit MAC change.
- [Medium] Missing collision check during initial probe allows duplicate MAC nibbles to break switch routing.
--
--- Patch [14]: [PATCH 14/20] net: dsa: xilinx: program MAC frame filter and per-port nibbles ---
commit a960829c1e4fd1b836fd23be3fc9bec389a6b123
Author: Nagadheeraj Rottela <nagadheeraj.rottela@amd.com>
net: dsa: xilinx: program MAC frame filter and per-port nibbles
This commit programs the switch fabric MAC frame filter using a 44-bit
prefix from the conduit interface and configures a unique 4-bit nibble for
each port. It adds a netdev notifier to track conduit and user port MAC
changes to keep the hardware synchronized.
> diff --git a/drivers/net/dsa/xilinx/xilinx_tsn.c b/drivers/net/dsa/xilinx/xilinx_tsn.c
> index 86aba2e8b6e94..9826f006b0789 100644
> --- a/drivers/net/dsa/xilinx/xilinx_tsn.c
> +++ b/drivers/net/dsa/xilinx/xilinx_tsn.c
[ ... ]
> @@ -287,6 +357,112 @@ static int xlnx_tsn_mdio_register_all(struct xlnx_tsn *sw)
> return ret;
> }
>
> +/* Build a per-port MAC from the shared prefix. */
> +static void xlnx_tsn_synth_port_mac(struct xlnx_tsn *sw, int port,
> + u8 *out)
[ ... ]
> +static int xlnx_tsn_handle_user_register(struct xlnx_tsn *sw,
> + struct net_device *dev, int port)
> +{
> + u8 want[ETH_ALEN];
> + u8 nibble;
> +
> + if (!xlnx_tsn_prefix_matches(sw, dev->dev_addr)) {
> + xlnx_tsn_synth_port_mac(sw, port, want);
> + dev_warn(sw->dev,
> + "port %d: MAC %pM does not match conduit prefix; overriding to %pM\n",
> + port, dev->dev_addr, want);
> + dev_addr_mod(dev, 0, want, ETH_ALEN);
[Severity: High]
Does modifying the MAC address directly in the registration notification
chain leave earlier subsystems out of sync?
When xlnx_tsn_handle_user_register() calls dev_addr_mod() during
NETDEV_REGISTER, subsystems like IPv6 that have already run earlier in the
notification chain will observe the old MAC inherited from the conduit,
and no subsequent NETDEV_CHANGEADDR is emitted to correct their state.
> + nibble = want[5] & TSN_SW_MAC_NIBBLE_WILDCARD;
> + } else if (ether_addr_equal(dev->dev_addr, sw->conduit->dev_addr)) {
> + /* Either DSA inherited the conduit MAC, or DT gave port@N
> + * the same address explicitly. Either way, assign a unique
> + * per-port nibble.
> + */
> + xlnx_tsn_synth_port_mac(sw, port, want);
> + dev_addr_mod(dev, 0, want, ETH_ALEN);
> + nibble = want[5] & TSN_SW_MAC_NIBBLE_WILDCARD;
> + } else {
> + nibble = dev->dev_addr[5] & TSN_SW_MAC_NIBBLE_WILDCARD;
> + }
> +
> + return xlnx_tsn_set_port_mac_nibble(sw, port, nibble);
[Severity: Medium]
Is it possible for the switch hardware to be configured with duplicate port
identifiers here?
Unlike the runtime callback, this initial registration path unconditionally
extracts and programs the nibble without verifying if it collides with the
CPU port or another user port. This could corrupt switch routing if the
device tree configures identical MAC addresses during probe.
> +}
> +
> +static void xlnx_tsn_handle_conduit_changeaddr(struct xlnx_tsn *sw)
> +{
> + struct dsa_port *dp;
> +
> + xlnx_tsn_derive_prefix(sw);
> + xlnx_tsn_program_frame_filter(sw);
> + xlnx_tsn_set_port_mac_nibble(sw, XLNX_TSN_CPU_PORT,
> + sw->conduit->dev_addr[5]);
> +
> + dsa_switch_for_each_user_port(dp, &sw->ds) {
> + u8 want[ETH_ALEN];
> +
> + if (!dp->user)
> + continue;
> +
> + xlnx_tsn_synth_port_mac(sw, dp->index, want);
> + dev_addr_mod(dp->user, 0, want, ETH_ALEN);
[Severity: High]
Does bypassing the DSA core ndo_set_mac_address hook leak resources and
cause packets to be dropped?
By using dev_addr_mod() here, the DSA core dsa_user_set_mac_address() is
never invoked. This means dsa_user_host_uc_install() and
dsa_user_host_uc_uninstall() are not called to synchronize the hardware
unicast filters with the new MAC address, leaving the old user MAC address
leaked in the conduit's filter list.
> + call_netdevice_notifiers(NETDEV_CHANGEADDR, dp->user);
[Severity: High]
Can this lead to a use-after-free or API violation?
If the conduit MAC address is changed concurrently with a failure in
dsa_user_create(), dp->user might be cleared without holding rtnl_lock,
allowing this code to dereference freed memory.
Also, this unconditionally broadcasts NETDEV_CHANGEADDR for a device that
may not have completed register_netdevice() yet (where reg_state ==
NETREG_UNINITIALIZED), which could confuse listeners.
> + }
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260807104431.157230-1-nagadheeraj.rottela@amd.com?part=14
next prev parent reply other threads:[~2026-08-08 10:46 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-07 10:44 [PATCH 00/20] xilinx: tsn: Add TSN Endpoint Ethernet MAC driver support Nagadheeraj Rottela
2026-08-07 10:44 ` [PATCH 01/20] dt-bindings: net: add Xilinx TSN Endpoint Ethernet MAC Nagadheeraj Rottela
2026-08-08 10:46 ` sashiko-bot
2026-08-08 19:48 ` Jakub Kicinski
2026-08-07 10:44 ` [PATCH 02/20] net: xilinx: tsn: add TSN endpoint wrapper driver Nagadheeraj Rottela
2026-08-07 20:58 ` Uwe Kleine-König
2026-08-08 12:27 ` Neeli, Srinivas
2026-08-08 19:48 ` Jakub Kicinski
2026-08-07 10:44 ` [PATCH 03/20] net: xilinx: tsn: add endpoint MAC driver skeleton Nagadheeraj Rottela
2026-08-07 21:00 ` Uwe Kleine-König
2026-08-08 12:28 ` Neeli, Srinivas
2026-08-08 10:46 ` sashiko-bot
2026-08-08 19:48 ` Jakub Kicinski
2026-08-07 10:44 ` [PATCH 04/20] net: xilinx: tsn: parse endpoint DMA channel configuration Nagadheeraj Rottela
2026-08-08 19:48 ` Jakub Kicinski
2026-08-07 10:44 ` [PATCH 05/20] net: xilinx: tsn: bring up the endpoint MCDMA channels Nagadheeraj Rottela
2026-08-08 10:46 ` sashiko-bot
2026-08-08 19:48 ` Jakub Kicinski
2026-08-07 10:44 ` [PATCH 06/20] net: xilinx: tsn: add the endpoint RX data path Nagadheeraj Rottela
2026-08-08 10:46 ` sashiko-bot
2026-08-08 19:48 ` Jakub Kicinski
2026-08-07 10:44 ` [PATCH 07/20] net: xilinx: tsn: add the endpoint TX " Nagadheeraj Rottela
2026-08-08 10:46 ` sashiko-bot
2026-08-08 19:48 ` Jakub Kicinski
2026-08-07 10:44 ` [PATCH 08/20] net: xilinx: tsn: deliver endpoint RX frames to DSA user ports Nagadheeraj Rottela
2026-08-08 10:46 ` sashiko-bot
2026-08-08 19:48 ` Jakub Kicinski
2026-08-07 10:44 ` [PATCH 09/20] net: dsa: tag_xlnx_tsn: add skeleton tag protocol Nagadheeraj Rottela
2026-08-08 19:48 ` Jakub Kicinski
2026-08-07 10:44 ` [PATCH 10/20] net: dsa: xilinx: add skeleton driver for TSN switch Nagadheeraj Rottela
2026-08-07 10:44 ` [PATCH 11/20] net: dsa: xilinx: implement port_stp_state_set Nagadheeraj Rottela
2026-08-08 10:46 ` sashiko-bot
2026-08-08 19:48 ` Jakub Kicinski
2026-08-07 10:44 ` [PATCH 12/20] net: dsa: xilinx: register per-MAC MDIO buses Nagadheeraj Rottela
2026-08-08 10:46 ` sashiko-bot
2026-08-08 19:48 ` Jakub Kicinski
2026-08-07 10:44 ` [PATCH 13/20] net: dsa: xilinx: wire up phylink for the switch ports Nagadheeraj Rottela
2026-08-08 19:48 ` Jakub Kicinski
2026-08-07 10:44 ` [PATCH 14/20] net: dsa: xilinx: program MAC frame filter and per-port nibbles Nagadheeraj Rottela
2026-08-08 10:46 ` sashiko-bot [this message]
2026-08-08 19:48 ` Jakub Kicinski
2026-08-07 10:44 ` [PATCH 15/20] net: dsa: xilinx: register PHC backed by the RTC timer block Nagadheeraj Rottela
2026-08-08 10:46 ` sashiko-bot
2026-08-08 19:48 ` Jakub Kicinski
2026-08-07 10:44 ` [PATCH 16/20] net: dsa: xilinx: drive per-MAC PTP TX/RX hardware paths Nagadheeraj Rottela
2026-08-08 10:46 ` sashiko-bot
2026-08-08 19:48 ` Jakub Kicinski
2026-08-07 10:44 ` [PATCH 17/20] net: dsa: xilinx: opt into TX forwarding offload on bridge join Nagadheeraj Rottela
2026-08-08 10:46 ` sashiko-bot
2026-08-08 19:48 ` Jakub Kicinski
2026-08-07 10:44 ` [PATCH 18/20] net: dsa: xilinx: offload the bridge FDB to the switch CAM Nagadheeraj Rottela
2026-08-08 10:46 ` sashiko-bot
2026-08-08 19:48 ` Jakub Kicinski
2026-08-07 10:44 ` [PATCH 19/20] net: dsa: xilinx: offload bridge VLAN filtering to the switch Nagadheeraj Rottela
2026-08-08 10:46 ` sashiko-bot
2026-08-08 19:48 ` Jakub Kicinski
2026-08-07 10:44 ` [PATCH 20/20] net: dsa: xilinx: trap link-local control frames to the CPU port Nagadheeraj Rottela
2026-08-08 10:47 ` sashiko-bot
2026-08-08 19:48 ` Jakub Kicinski
2026-08-07 22:28 ` [PATCH 00/20] xilinx: tsn: Add TSN Endpoint Ethernet MAC driver support Jakub Kicinski
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=20260808104654.86A451F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=nagadheeraj.rottela@amd.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@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