Skip to content

Commit ef4c5af

Browse files
kliteynSaeed Mahameed
authored andcommitted
net/mlx5: DR, Fix wrong action data allocation in decap action
When TUNNEL_L3_TO_L2 decap action was created, a pointer to a local variable was passed as its HW action data, resulting in attempt to free invalid address: BUG: KASAN: invalid-free in mlx5dr_action_destroy+0x318/0x410 [mlx5_core] Fixes: 4781df9 ("net/mlx5: DR, Move STEv0 modify header logic") Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com> Reviewed-by: Alex Vesker <valex@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
1 parent 87cd064 commit ef4c5af

File tree

1 file changed

+7
-1
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/steering

1 file changed

+7
-1
lines changed

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1421,16 +1421,21 @@ dr_action_create_reformat_action(struct mlx5dr_domain *dmn,
14211421
}
14221422
case DR_ACTION_TYP_TNL_L3_TO_L2:
14231423
{
1424-
u8 hw_actions[DR_ACTION_CACHE_LINE_SIZE] = {};
1424+
u8 *hw_actions;
14251425
int ret;
14261426

1427+
hw_actions = kzalloc(DR_ACTION_CACHE_LINE_SIZE, GFP_KERNEL);
1428+
if (!hw_actions)
1429+
return -ENOMEM;
1430+
14271431
ret = mlx5dr_ste_set_action_decap_l3_list(dmn->ste_ctx,
14281432
data, data_sz,
14291433
hw_actions,
14301434
DR_ACTION_CACHE_LINE_SIZE,
14311435
&action->rewrite->num_of_actions);
14321436
if (ret) {
14331437
mlx5dr_dbg(dmn, "Failed creating decap l3 action list\n");
1438+
kfree(hw_actions);
14341439
return ret;
14351440
}
14361441

@@ -1440,6 +1445,7 @@ dr_action_create_reformat_action(struct mlx5dr_domain *dmn,
14401445
ret = mlx5dr_ste_alloc_modify_hdr(action);
14411446
if (ret) {
14421447
mlx5dr_dbg(dmn, "Failed preparing reformat data\n");
1448+
kfree(hw_actions);
14431449
return ret;
14441450
}
14451451
return 0;

0 commit comments

Comments
 (0)