Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next v2] mlxsw: spectrum_switchdev: fix wrong list member in flood rollback
@ 2026-12-01 14:05 Ziheng Wei
  2026-12-03 14:06 ` netdev-bot+sashiko
  0 siblings, 1 reply; 4+ messages in thread
From: Ziheng Wei @ 2026-12-01 14:05 UTC (permalink / raw)
  To: Ido Schimmel, Petr Machata, Andrew Lunn, David S . Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: netdev, linux-kernel

mlxsw_sp_bridge_vlans_flood_set() inserts and walks entries on
bridge_vlan->port_vlan_list via mlxsw_sp_port_vlan->bridge_vlan_node,
but its err_fid_flood_set rollback path instead uses the list member in
list_for_each_entry_continue_reverse().

Use bridge_vlan_node so rollback computes the proper container address
and walks the same list as the forward loop.

Found by LLM-assisted static analysis. Compile-tested on x86_64 with
CONFIG_MLXSW_SPECTRUM=m; no hardware test.

Signed-off-by: Ziheng Wei <zihengw03@163.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
---
v1 -> v2:
- Retarget from net to net-next, drop non-regression Fixes tag, and add
  Petr Machata's Reviewed-by.
- v1: https://lore.kernel.org/r/20261130103229.1383713-1-zihengw03@163.com

 drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
index de60b698bea9..e54a4ec75ff1 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
@@ -787,7 +787,7 @@ mlxsw_sp_bridge_vlans_flood_set(struct mlxsw_sp_bridge_vlan *bridge_vlan,
 err_fid_flood_set:
 	list_for_each_entry_continue_reverse(mlxsw_sp_port_vlan,
 					     &bridge_vlan->port_vlan_list,
-					     list) {
+					     bridge_vlan_node) {
 		u16 local_port = mlxsw_sp_port_vlan->mlxsw_sp_port->local_port;
 
 		mlxsw_sp_fid_flood_set(mlxsw_sp_port_vlan->fid, packet_type,

base-commit: 34d30f9e1f2d8cb25c12ae48572143411a6d278b


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next v2] mlxsw: spectrum_switchdev: fix wrong list member in flood rollback
  2026-12-01 14:05 [PATCH net-next v2] mlxsw: spectrum_switchdev: fix wrong list member in flood rollback Ziheng Wei
@ 2026-12-03 14:06 ` netdev-bot+sashiko
  2026-12-03 14:40   ` Ziheng Wei
  2026-12-03 15:07   ` Petr Machata
  0 siblings, 2 replies; 4+ messages in thread
From: netdev-bot+sashiko @ 2026-12-03 14:06 UTC (permalink / raw)
  To: zihengw03
  Cc: idosch, petrm, andrew+netdev, davem, edumazet, kuba, pabeni,
	netdev, linux-kernel

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

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

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The v2 changelog says the Fixes: tag was dropped as "non-
  regression".
- [Low] The commit message for "mlxsw: spectrum_switchdev: fix wrong list
  member in flood rollback" explains the mechanics: rollback now…

--

mlxsw: spectrum_switchdev: fix wrong list member in flood rollback

This patch fixes the err_fid_flood_set rollback loop in
mlxsw_sp_bridge_vlans_flood_set(). The loop now iterates with the
bridge_vlan_node member instead of the list member, so it walks
bridge_vlan->port_vlan_list just like the forward loop.

> Use bridge_vlan_node so rollback computes the proper container address
> and walks the same list as the forward loop.

[Severity: Low]
Could the commit message also say what the old rollback did when
mlxsw_sp_fid_flood_set() failed?

In struct mlxsw_sp_port_vlan, list links the entry into
mlxsw_sp_port->vlans_list. bridge_vlan_node links it into
bridge_vlan->port_vlan_list:

struct mlxsw_sp_port_vlan {
	struct list_head list;
	struct mlxsw_sp_port *mlxsw_sp_port;
	struct mlxsw_sp_fid *fid;
	...
	struct list_head bridge_vlan_node;
};

So the old loop walked the failing port's vlans_list. It called
mlxsw_sp_fid_flood_set(..., !member) on the FIDs of unrelated VLANs on
that port and rewrote their hardware flood membership.

The check against &bridge_vlan->port_vlan_list could never match, so the
loop never stopped there. When the walk reached &mlxsw_sp_port->vlans_list,
it treated the list head as an entry. Since list is at offset 0, ->fid
pointed at mlxsw_sp_port->qdisc and ->mlxsw_sp_port pointed at
mlxsw_sp_port->default_vlan:

struct mlxsw_sp_port {
	...
	struct list_head vlans_list;
	struct mlxsw_sp_port_vlan *default_vlan;
	struct mlxsw_sp_qdisc_state *qdisc;
	...
};

mlxsw_sp_fid_flood_set() then follows fid->fid_family and
fid_family->flood_profile through that garbage pointer, which would likely
oops. If it doesn't oops, the walk goes round the circular list forever.

A bridge mcast_snooping toggle can reach this path:

mlxsw_sp_port_attr_set()->mlxsw_sp_port_mc_disabled_set()->
mlxsw_sp_bridge_ports_flood_table_set()->mlxsw_sp_bridge_vlans_flood_set()

It triggers when mlxsw_sp_fid_flood_set() -> mlxsw_sp_pgt_entry_port_add()
fails because an allocation or a register write fails.

Documentation/process/submitting-patches.rst asks for the user-visible
impact even when a problem was found by code review. Could the changelog
mention the possible oops or endless loop? Otherwise the fix may look like
a cosmetic error-path cleanup.

> v1 -> v2:
> - Retarget from net to net-next, drop non-regression Fixes tag, and add
>   Petr Machata's Reviewed-by.

[Severity: Medium]
Should this keep a Fixes: tag?

git blame shows that this commit added both
mlxsw_sp_bridge_vlans_flood_set() and the list member in its rollback
loop:

a6f43b1dad800d ("mlxsw: spectrum_switchdev: Simplify mlxsw_sp_port_mc_disabled_set()")

That commit is in v6.0 and later.

Documentation/process/maintainer-netdev.rst says the Fixes: tag is
required for fixes regardless of the tree. That applies whether or not the
bug is a regression.

Without the tag or a Cc: stable, stable kernels from v6.0 on have nothing
telling them they need this one-line fix. They would keep the rollback
path described above.

Something like:

Fixes: a6f43b1dad800d ("mlxsw: spectrum_switchdev: Simplify mlxsw_sp_port_mc_disabled_set()")

I couldn't see the v1 review discussion. If a maintainer asked for the tag
to be dropped there, please disregard this.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201140545.1572541-1-zihengw03%40163.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next v2] mlxsw: spectrum_switchdev: fix wrong list member in flood rollback
  2026-12-03 14:06 ` netdev-bot+sashiko
@ 2026-12-03 14:40   ` Ziheng Wei
  2026-12-03 15:07   ` Petr Machata
  1 sibling, 0 replies; 4+ messages in thread
From: Ziheng Wei @ 2026-12-03 14:40 UTC (permalink / raw)
  To: netdev-bot+sashiko
  Cc: Ido Schimmel, Petr Machata, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel

On Thu, Dec 03, 2026 at 02:06:09PM +0000, netdev-bot+sashiko@kernel.org wrote:
> [Severity: Medium]
> Should this keep a Fixes: tag?
> ...
> I couldn't see the v1 review discussion. If a maintainer asked for the tag
> to be dropped there, please disregard this.

Good catch — in v1 Petr only requested retargeting from net to net-next
and did not ask to drop the Fixes: tag. I will restore the Fixes: tag
and describe the rollback failure impact in v3.

pw-bot: cr


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next v2] mlxsw: spectrum_switchdev: fix wrong list member in flood rollback
  2026-12-03 14:06 ` netdev-bot+sashiko
  2026-12-03 14:40   ` Ziheng Wei
@ 2026-12-03 15:07   ` Petr Machata
  1 sibling, 0 replies; 4+ messages in thread
From: Petr Machata @ 2026-12-03 15:07 UTC (permalink / raw)
  To: netdev-bot+sashiko
  Cc: zihengw03, idosch, petrm, andrew+netdev, davem, edumazet, kuba,
	pabeni, netdev, linux-kernel

netdev-bot+sashiko@kernel.org writes:

> So the old loop walked the failing port's vlans_list. It called
> mlxsw_sp_fid_flood_set(..., !member) on the FIDs of unrelated VLANs on
> that port and rewrote their hardware flood membership.

> mlxsw_sp_fid_flood_set() then follows fid->fid_family and
> fid_family->flood_profile through that garbage pointer, which would likely
> oops. If it doesn't oops, the walk goes round the circular list forever.
>
> A bridge mcast_snooping toggle can reach this path:
>
> mlxsw_sp_port_attr_set()->mlxsw_sp_port_mc_disabled_set()->
> mlxsw_sp_bridge_ports_flood_table_set()->mlxsw_sp_bridge_vlans_flood_set()
>
> It triggers when mlxsw_sp_fid_flood_set() -> mlxsw_sp_pgt_entry_port_add()
> fails because an allocation or a register write fails.

> Documentation/process/submitting-patches.rst asks for the user-visible
> impact even when a problem was found by code review. Could the changelog
> mention the possible oops or endless loop? Otherwise the fix may look like
> a cosmetic error-path cleanup.

Thanks for digging up this info, which is henceforth available on the
list! Let's not respin for this though, please.

>> v1 -> v2:
>> - Retarget from net to net-next, drop non-regression Fixes tag, and add
>>   Petr Machata's Reviewed-by.
>
> [Severity: Medium]
> Should this keep a Fixes: tag?

I don't thik so. This is allocating non-atomic memory, the failure
there, especially in context of a typical deployment of that code, is
not very likely. Register writes don't really fail either, at all. Let's
treat it as a nice cleanup that it is and not stir the pot with the
backports the Fixes tag would inevitably prompt.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-12-03 15:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 14:05 [PATCH net-next v2] mlxsw: spectrum_switchdev: fix wrong list member in flood rollback Ziheng Wei
2026-12-03 14:06 ` netdev-bot+sashiko
2026-12-03 14:40   ` Ziheng Wei
2026-12-03 15:07   ` Petr Machata

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox