[PATCH net] net/mlx5e: Release FIB event work flows before dropping RTNL

From: Tariq Toukan

Date: Wed Nov 18 2026 - 09:38:20 EST


From: Gal Pressman <gal@xxxxxxxxxx>

The FIB event work, neigh update work and the neigh stats work all use
flow->tmp_list to hold the encap flows they work on, while RTNL is what
keeps them from using it at the same time.

mlx5e_tc_fib_event_work() drops RTNL before it is done with its list.
A neigh work can then take the same flows while the FIB work is still
walking them, and the two overwrite each other's list.

Release the flow list before dropping RTNL.

The issue was hit once in our regression testing (OVS connection
tracking with the VXLAN endpoint on a VF, KASAN build):
BUG: KASAN: stack-out-of-bounds in mlx5e_flow_put+0x23/0x80 [mlx5_core]
Write of size 4 at addr ffff8881226d7b20 by task kworker/u40:1/20171
Workqueue: mlx5e mlx5e_tc_fib_event_work [mlx5_core]
Call Trace:
mlx5e_flow_put+0x23/0x80 [mlx5_core]
mlx5e_put_flow_list+0x82/0xe0 [mlx5_core]
mlx5e_tc_fib_event_work+0x704/0x1fb0 [mlx5_core]
process_one_work+0x8df/0x1660

The race was also reproduced with an msleep() inserted between
rtnl_unlock() and mlx5e_put_flow_list() to widen the window, a VXLAN
encap rule whose endpoint IP is on a VF, and route churn on the endpoint
address.

Fixes: 8914add2c9e5 ("net/mlx5e: Handle FIB events to update tunnel endpoint device")
Signed-off-by: Gal Pressman <gal@xxxxxxxxxx>
Reviewed-by: Jianbo Liu <jianbol@xxxxxxxxxx>
Signed-off-by: Tariq Toukan <tariqt@xxxxxxxxxx>
---
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c
index 5e40107efa26..4f9f8beffbc8 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c
@@ -1718,9 +1718,9 @@ static void mlx5e_tc_fib_event_work(struct work_struct *work)
r->flags |= MLX5E_ROUTE_ENTRY_VALID;
out:
mutex_unlock(&esw->offloads.encap_tbl_lock);
+ mlx5e_put_flow_list(priv, &flow_list);
rtnl_unlock();

- mlx5e_put_flow_list(priv, &flow_list);
mlx5e_route_put(priv, event_data->r);
dev_put(event_data->ul_dev);
kfree(event_data);

base-commit: aa40afa831ebfe45e40a23721711059f2ac584d4
--
2.44.0