net/mlx5e: Release FIB event work flows before dropping RTNL
Subsystems (4)
Tariq Toukan
maintainerPATCH 1/1 net/mlx5e: Release FIB event work flows before dropping RTNL
From: Gal Pressman <[email protected]>
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.
--- drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c +1 -1
@@ -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
Signature · 1 line
2.44.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 14 lines
From: Gal Pressman <[email protected]>
The FIB event work, neigh update work and the neigh stats work all use
flow->tmp_listto 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):
Quoted 7 lines
BUG: KASAN: stack-out-of-bounds in mlx5e_flow_put+0x23/0x80 [mlx5_core][ ... ]
Fixes 8914add2c9e5 ("net/mlx5e: Handle FIB events to update tunnel endpoint device")Signed-off-by Gal Pressman <[email protected]>Reviewed-by Jianbo Liu <[email protected]>Signed-off-by Tariq Toukan <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Wed, 18 Nov 2026 16:36:53 +0200 you wrote:
From: Gal Pressman <[email protected]>
The FIB event work, neigh update work and the neigh stats work all use
flow->tmp_listto 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.[...]
Here is the summary with links:
- [net] net/mlx5e: Release FIB event work flows before dropping RTNL
https://git.kernel.org/netdev/net/c/bfccb4e44e47
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html