mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 10:31:46 +09:00
net/mlx5: DR, Fix wrong action data allocation in decap action
[ Upstream commitef4c5afc78] 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:4781df92f4("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
b062caf4f7
commit
0bbb8164ed
@@ -1200,9 +1200,13 @@ dr_action_create_reformat_action(struct mlx5dr_domain *dmn,
|
|||||||
}
|
}
|
||||||
case DR_ACTION_TYP_TNL_L3_TO_L2:
|
case DR_ACTION_TYP_TNL_L3_TO_L2:
|
||||||
{
|
{
|
||||||
u8 hw_actions[ACTION_CACHE_LINE_SIZE] = {};
|
u8 *hw_actions;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
hw_actions = kzalloc(ACTION_CACHE_LINE_SIZE, GFP_KERNEL);
|
||||||
|
if (!hw_actions)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
ret = mlx5dr_ste_set_action_decap_l3_list(dmn->ste_ctx,
|
ret = mlx5dr_ste_set_action_decap_l3_list(dmn->ste_ctx,
|
||||||
data, data_sz,
|
data, data_sz,
|
||||||
hw_actions,
|
hw_actions,
|
||||||
@@ -1210,6 +1214,7 @@ dr_action_create_reformat_action(struct mlx5dr_domain *dmn,
|
|||||||
&action->rewrite->num_of_actions);
|
&action->rewrite->num_of_actions);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
mlx5dr_dbg(dmn, "Failed creating decap l3 action list\n");
|
mlx5dr_dbg(dmn, "Failed creating decap l3 action list\n");
|
||||||
|
kfree(hw_actions);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1217,6 +1222,7 @@ dr_action_create_reformat_action(struct mlx5dr_domain *dmn,
|
|||||||
DR_CHUNK_SIZE_8);
|
DR_CHUNK_SIZE_8);
|
||||||
if (!action->rewrite->chunk) {
|
if (!action->rewrite->chunk) {
|
||||||
mlx5dr_dbg(dmn, "Failed allocating modify header chunk\n");
|
mlx5dr_dbg(dmn, "Failed allocating modify header chunk\n");
|
||||||
|
kfree(hw_actions);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1230,6 +1236,7 @@ dr_action_create_reformat_action(struct mlx5dr_domain *dmn,
|
|||||||
if (ret) {
|
if (ret) {
|
||||||
mlx5dr_dbg(dmn, "Writing decap l3 actions to ICM failed\n");
|
mlx5dr_dbg(dmn, "Writing decap l3 actions to ICM failed\n");
|
||||||
mlx5dr_icm_free_chunk(action->rewrite->chunk);
|
mlx5dr_icm_free_chunk(action->rewrite->chunk);
|
||||||
|
kfree(hw_actions);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user