From: netdev-bot+sashiko@kernel.org
To: acassen@corp.free.fr
Cc: saeedm@nvidia.com, leon@kernel.org, tariqt@nvidia.com,
mbloch@nvidia.com, andrew+netdev@lunn.ch, davem@davemloft.net,
edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
horms@kernel.org, moshe@nvidia.com, kliteyn@nvidia.com,
vdogaru@nvidia.com, netdev@vger.kernel.org,
linux-rdma@vger.kernel.org
Subject: Re: [PATCH net] net/mlx5: HWS, fix action STE double free on rule update
Date: Tue, 24 Nov 2026 22:47:49 +0000 [thread overview]
Message-ID: <179556046979.3135.2314506196260150359@kernel.org> (raw)
In-Reply-To: <20261123221310.4045513-1-acassen@corp.free.fr>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] The patch leaves a second double free of action STEs on rule
update in place.
- [Medium] This patch adds a new leak of the old action STE chunk when an
update partially fails and the new actions need no action STEs…
--
net/mlx5: HWS, fix action STE double free on rule update
This patch clears rule->action_ste.action_tbl in hws_rule_create_init()
once the current chunk is saved into rule->old_action_ste during an
update. If the new actions need no action STEs, a later update or delete
no longer frees the same action STE chunk again.
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/rule.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/rule.c
> index 0d4cb2b2393b9..cc94d3149d76a 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/rule.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/rule.c
> @@ -243,6 +243,8 @@ static void hws_rule_create_init(struct mlx5hws_rule *rule,
> * new action STEs and a corresponding match STE.
> */
> rule->old_action_ste = rule->action_ste;
> + /* The rule may need no action STEs once updated */
> + rule->action_ste.action_tbl = NULL;
> }
[Severity: High]
The subject says this fixes the action STE double free on rule update.
Can the old_action_ste slot still be freed twice, though?
When an update succeeds, hws_send_engine_update_rule() in send.c frees
the old chunk:
} else if (priv->rule->status == MLX5HWS_RULE_STATUS_UPDATED) {
/* Rule was updated, free the old action STEs */
mlx5hws_rule_free_action_ste(&priv->rule->old_action_ste);
Neither mlx5hws_rule_free_action_ste() nor mlx5hws_action_ste_chunk_free()
clears old_action_ste.action_tbl after that. So the only guard in the
helper still passes on a later call:
if (!action_ste->action_tbl)
return;
One CQE with an opcode other than MLX5_CQE_REQ makes
hws_send_engine_poll_cq() set queue->err, and nothing clears it. After
that, every destroy on the queue goes through
hws_rule_destroy_hws()->hws_rule_destroy_failed_hws(), which does:
/* Perhaps the rule failed updating - release old action STEs as well */
mlx5hws_rule_free_action_ste(&rule->old_action_ste);
Any rule that was updated successfully before gets its old chunk freed a
second time here. The reproducer's flower rules, which lose and regain
their police action, are such rules. Eswitch teardown is one way to
reach this destroy path.
The cleanup work (hws_action_ste_pool_cleanup()->
hws_action_ste_table_destroy()) may kfree() the now empty table between
the two frees. In that case, mlx5hws_action_ste_chunk_free() would read
chunk->action_tbl->parent_elem->parent_pool->lock from freed memory.
The commit message calls this path "Not addressed here and not
triggered".
Would clearing action_ste->action_tbl inside
mlx5hws_rule_free_action_ste() after the free make every free site safe
to repeat? Combined with this change, that would cover this path as
well as the one fixed here.
[Severity: Medium]
Does this hunk now leak the old chunk when an update to actions with no
action STEs partially fails?
After this hunk, old_action_ste is the only reference to the old chunk.
Take an FDB rule with both RX and TX RTCs. One WQE may complete with an
error status without setting queue->err. Then
hws_send_engine_update_rule() zeroes only that RTC's used_id. The status
stays FAILING and does not become FAILED:
if (!priv->rule->rtc_0 && !priv->rule->rtc_1)
priv->rule->status = MLX5HWS_RULE_STATUS_FAILED;
hws_rule_destroy_hws() then takes either the skip_delete branch or the
normal DEACTIVATE path. Both free only rule->action_ste. The skip_delete
branch does:
mlx5hws_rule_free_action_ste(&rule->action_ste);
and the DELETED completion in hws_send_engine_update_rule() does:
mlx5hws_rule_free_action_ste(&priv->rule->action_ste);
action_ste.action_tbl is now NULL, so neither call frees anything. The
chunk held in old_action_ste is never released, so the pool is still
non-empty at teardown. Before this patch, the chunk was still in
action_ste, and delete freed it once.
The commit message notes "A failed update can leak it now also when it
needs no action STEs".
Would either of these avoid the leak?
- free old_action_ste in the DELETED completion and in the
skip_delete branch
- restore action_ste from old_action_ste on partial failure
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123221310.4045513-1-acassen%40corp.free.fr
prev parent reply other threads:[~2026-11-24 22:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 22:13 [PATCH net] net/mlx5: HWS, fix action STE double free on rule update Alexandre Cassen
2026-11-24 12:09 ` Yevgeny Kliteynik
2026-11-24 22:13 ` sashiko-bot
2026-11-24 22:47 ` netdev-bot+sashiko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179556046979.3135.2314506196260150359@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=acassen@corp.free.fr \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kliteyn@nvidia.com \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mbloch@nvidia.com \
--cc=moshe@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saeedm@nvidia.com \
--cc=tariqt@nvidia.com \
--cc=vdogaru@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox