Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
* [PATCH net] net/mlx5: Fix slab-out-of-bounds when handling team device events
@ 2026-09-22 13:51 Anirudh Virdi
  2026-09-22 13:58 ` sashiko-bot
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Anirudh Virdi @ 2026-09-22 13:51 UTC (permalink / raw)
  To: netdev
  Cc: saeedm, leon, tariqt, mbloch, andrew+netdev, davem, edumazet,
	kuba, pabeni, shayd, ohartoov, maorg, linux-rdma, Anirudh Virdi

The mlx5_handle_changeupper_event() and mlx5_handle_changeinfodata_event()
functions assume the upper device is a bonding device and call bonding-
specific
APIs like bond_slave_get_rcu() and bond_is_slave_inactive().

When a device is enslaved to a team master instead of bonding, the code
attempts to access the team_port structure as if it were a bond slave
structure. Since team_port is smaller than slave, this causes KASAN to
detect an out-of-bounds memory access.

Fix this by checking explicitly for bonding devices using
netif_is_bond_master() instead of the generic netif_is_lag_master() which
includes both bonding and team devices. This ensures mlx5 only processes
bonding events, not team events, preventing the invalid memory access.

Tested with Mellanox ConnectX-5 on Linux 7.2.0-rc6:
- Bonding: PASS (no regressions)
- Team device: PASS (no KASAN errors)

Fixes: 54493a08e21f ("net/mlx5: Lag, record inactive state of bond device")
Signed-off-by: Anirudh Virdi <avirdi@redhat.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
index 28d16fdc3f06..022a69cdebaf 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
@@ -1897,7 +1897,7 @@ static int mlx5_handle_changeupper_event(struct mlx5_lag *ldev,
 	int changed = 0;
 	int i, idx = -1;
 
-	if (!netif_is_lag_master(upper))
+	if (!netif_is_bond_master(upper))
 		return 0;
 
 	if (info->linking)
@@ -2004,7 +2004,7 @@ static int mlx5_handle_changeinfodata_event(struct mlx5_lag *ldev,
 	bool has_inactive = 0;
 	int idx;
 
-	if (!netif_is_lag_master(ndev))
+	if (!netif_is_bond_master(ndev))
 		return 0;
 
 	rcu_read_lock();
-- 
2.55.0


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

end of thread, other threads:[~2026-09-25  6:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-22 13:51 [PATCH net] net/mlx5: Fix slab-out-of-bounds when handling team device events Anirudh Virdi
2026-09-22 13:58 ` sashiko-bot
2026-09-22 17:50 ` Shay Drori
2026-09-22 18:37 ` Mark Bloch
2026-09-24 13:54 ` netdev-bot+sashiko
     [not found]   ` <CAJHXLyHH-RG_y04yT-SV+r3+_scac15iKrMtVfNG9Ti3wQFmrw@mail.gmail.com>
2026-09-25  6:45     ` Anirudh Virdi

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