Skip to content

Commit

Permalink
net/mlx5e: Always clear dest encap in neigh-update-del
Browse files Browse the repository at this point in the history
[ Upstream commit 2951b2e ]

The cited commit introduced a bug for multiple encapsulations flow.
If one dest encap becomes invalid, the flow is set slow path flag.
But when other dests encap become invalid, they are not cleared due
to slow path flag of the flow. When neigh-update-add is running, it
will use invalid encap.

Fix it by checking slow path flag after clearing dest encap.

Fixes: 9a5f9cc ("net/mlx5e: Fix possible use-after-free deleting fdb rule")
Signed-off-by: Chris Mi <cmi@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Chris Mi authored and gregkh committed Jan 12, 2023
1 parent b36783b commit 6c72abb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c
Expand Up @@ -188,12 +188,19 @@ void mlx5e_tc_encap_flows_del(struct mlx5e_priv *priv,
int err;

list_for_each_entry(flow, flow_list, tmp_list) {
if (!mlx5e_is_offloaded_flow(flow) || flow_flag_test(flow, SLOW))
if (!mlx5e_is_offloaded_flow(flow))
continue;
attr = flow->attr;
esw_attr = attr->esw_attr;
spec = &attr->parse_attr->spec;

/* Clear pkt_reformat before checking slow path flag. Because
* in next iteration, the same flow is already set slow path
* flag, but still need to clear the pkt_reformat.
*/
if (flow_flag_test(flow, SLOW))
continue;

/* update from encap rule to slow path rule */
rule = mlx5e_tc_offload_to_slow_path(esw, flow, spec);
/* mark the flow's encap dest as non-valid */
Expand Down

0 comments on commit 6c72abb

Please sign in to comment.