net/mlx5: fix ASan issue in RSS flow creation
PATCH 1/1 net/mlx5: fix ASan issue in RSS flow creation
This patch addresses AddressSanitizer (ASan) stack-use-after-scope issues occurring during RSS flow creation in the MLX5 driver. The root cause stemmed from the use of compound literals to initialize flow action configurations, which could result in pointers to temporary stack memory being retained in flow structures. When these pointers were later accessed during flow conversion, the underlying stack memory was no longer valid,
leading to ASAN-detected errors.
Modifications:
In mlx5_hw_rss_ptype_create_base_flow(),
the struct rte_flow_action_jump is now constructed
at the start of the function, rather than within the do statement. This ensures a persistent stack allocation for the structure, preventing use-after-scope situations.
This change eliminates the following ASan errors:
stack-use-after-scope reported in rte_flow_conv_copy
--- drivers/net/mlx5/mlx5_nta_rss.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/mlx5/mlx5_nta_rss.c +4 -3
@@ -320,6 +320,9 @@ mlx5_hw_rss_ptype_create_base_flow(struct rte_eth_dev *dev,struct rte_flow_hw *flow =NULL ;struct rte_flow_action actions[MLX5_HW_MAX_ACTS ];enum mlx5_indirect_type indirect_type; +const struct rte_flow_action_jump jump_conf = { + .group = ptype_group + }; do { switch (orig_actions[i].type) {
@@ -334,9 +337,7 @@ mlx5_hw_rss_ptype_create_base_flow(struct rte_eth_dev *dev,/* Fall through */ case RTE_FLOW_ACTION_TYPE_RSS : actions[i].type =RTE_FLOW_ACTION_TYPE_JUMP ; - actions[i].conf = &(const struct rte_flow_action_jump ) { - .group = ptype_group - }; + actions[i].conf = &jump_conf;break ;default : actions[i] = orig_actions[i];
Signature · 1 line
2.21.0
Hi,
Quoted 16 lines · Maayan Kashani
This patch addresses AddressSanitizer (ASan) stack-use-after-scope issues occurring during RSS flow creation in the MLX5 driver. The root cause stemmed from the use of compound literals to initialize flow action configurations, which could result in pointers to temporary stack memory being retained in flow structures. When these pointers were later accessed during flow conversion, the underlying stack memory was no longer valid,
leading to ASAN-detected errors.Modifications:
Inmlx5_hw_rss_ptype_create_base_flow(),
the structrte_flow_action_jumpis now constructed
at the start of the function, rather than within the do statement. This ensures a persistent stack allocation for the structure, preventing use-after-scope situations.
Quoted 8 lines
This change eliminates the following ASan errors:
stack-use-after-scope reported inrte_flow_conv_copyFixes ae67e3c43dd5 ("net/mlx5: support RSS expansion in non-template HWS setup")Signed-off-by Maayan Kashani <[email protected]>
Patch applied to next-net-mlx,
Kindest regards
Raslan Darawsheh