net/mlx5e: TC, Fix double free of branch in failure
Subsystems (5)
PATCH 1/1 net/mlx5e: TC, Fix double free of branch in failure
When allocating the false branch fails in parse_branch_ctrl(), the already allocated true branch is freed but attr->branch_true is left pointing to it. The caller parse_tc_actions() fails the flow, and free_flow_post_acts(), mlx5_free_flow_attr_actions() which calls again free_branch_attr() on attr->branch_true.
Clear the pointer after freeing it.
This bug is theoretical and was compile tested only.
--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +1 -0
@@ -4005,6 +4005,7 @@ parse_branch_ctrl(struct flow_action_entry *act, struct mlx5e_tc_act *tc_act, err_branch_false:free_branch_attr (flow, attr->branch_true); + attr->branch_true =NULL ; out_err:return err; }
Signature · 1 line
2.53.0
[email protected]
AI reviewThis is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
Hi!
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.
Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then.
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 6 lines
When allocating the false branch fails in
parse_branch_ctrl(), the already allocated true branch is freed butattr->branch_trueis left pointing to it. The callerparse_tc_actions()fails the flow, andfree_flow_post_acts(),mlx5_free_flow_attr_actions()which calls againfree_branch_attr()onattr->branch_true.
Quoted 6 lines
Clear the pointer after freeing it.
This bug is theoretical and was compile tested only.
Fixes f86488cb4685 ("net/mlx5e: TC, initialize branch flow attributes")Signed-off-by Thomas Fourier <[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
Paolo Abeni
maintainerQuoted 6 lines · Thomas Fourier
When allocating the false branch fails in
parse_branch_ctrl(), the already allocated true branch is freed butattr->branch_trueis left pointing to it. The callerparse_tc_actions()fails the flow, andfree_flow_post_acts(),mlx5_free_flow_attr_actions()which calls againfree_branch_attr()onattr->branch_true.
Quoted 6 lines
Clear the pointer after freeing it.
This bug is theoretical and was compile tested only.
Fixes f86488cb4685 ("net/mlx5e: TC, initialize branch flow attributes")Signed-off-by Thomas Fourier <[email protected]>
Given the lack of H/W testing I would appreciate an explicit ack from the mlx crew.
Thanks,
Paolo
Quoted 11 lines · Paolo Abeni
Quoted 10 lines · Thomas Fourier
When allocating the false branch fails in
parse_branch_ctrl(), the already allocated true branch is freed butattr->branch_trueis left pointing to it. The callerparse_tc_actions()fails the flow, andfree_flow_post_acts(),mlx5_free_flow_attr_actions()which calls againfree_branch_attr()onattr->branch_true.Clear the pointer after freeing it.
This bug is theoretical and was compile tested only.
I reproduced it on ConnectX-6 Dx in switchdev mode, with KASAN:
tc filter add dev $UPLINK ingress protocol ip flower skip_sw \
dst_ip 192.0.2.2 action police rate 1mbit burst 20k \
conform-exceed jump 1 / jump 1 action pass action dropEvery attempt reports a double-free in mlx5_free_flow_attr_actions(). With this patch, 50 attempts reported none.
Quoted 8 lines
Quoted 2 lines
Fixes f86488cb4685 ("net/mlx5e: TC, initialize branch flow attributes")Signed-off-by Thomas Fourier <[email protected]>Given the lack of H/W testing I would appreciate an explicit ack from the mlx crew.
Thanks,
Paolo
The same command also leaks the parse_attr of the false branch, as alloc_branch_attr() frees only the attr on its error path. I'll send a separate fix for that.
Thanks,
Tariq
This patch was applied to netdev/net.git (main) by Dave Miller <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main) by Dave Miller <[email protected]>:
Quoted 9 lines · On Wed, 28 Oct 2026 15:57:02 +0100 you wrote:
When allocating the false branch fails in
parse_branch_ctrl(), the already allocated true branch is freed butattr->branch_trueis left pointing to it. The callerparse_tc_actions()fails the flow, andfree_flow_post_acts(),mlx5_free_flow_attr_actions()which calls againfree_branch_attr()onattr->branch_true.Clear the pointer after freeing it.
[...]
Here is the summary with links:
- [net] net/mlx5e: TC, Fix double free of branch in failure
https://git.kernel.org/netdev/net/c/31f9b43a3bb3
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html