Article View: linux.kernel.netdev
Article #22156Re: [PATCH net] net/mlx5: HWS, fix action STE double free on rule update
From: netdev-bot+sashiko
Date: Tue, 24 Nov 2026 22:47
Date: Tue, 24 Nov 2026 22:47
124 lines
12834 bytes
12834 bytes
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
Technical Details
Message-ID:
<179556046979.3135.2314506196260150359@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370850-linux-kernel-netdev=dewy.ruReferences:
<20261123221310.4045513-1-acassen@corp.free.fr>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370850-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] net/mlx5: HWS, fix action STE double free on rule update Date: Tue, 24 Nov 2026 22:47:49 +0000 Organization: Usenet Network Message-ID: <179556046979.3135.2314506196260150359@kernel.org> References: <20261123221310.4045513-1-acassen@corp.free.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="57114"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:RESZ1GEcYd8GtYxM0J8BHcl6A54= sha256:dDXvdi5NAQjMnDe6ZF1KJXBqoZlLk20ms6yyX32TKzE= sha1:S8JmoHsmHulNwVt1bHxbWEggp4U= sha256:3EMojWuBfOCo6lDIaLZsQ4z4beCdM/L5jkpl7mD91cA= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 83DE1125E2F; Wed, 25 Nov 2026 01:48:14 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cIZDahWEM3Tw; Wed, 25 Nov 2026 01:48:06 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-370850-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id D560A125E33; Wed, 25 Nov 2026 01:47:57 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id 48EA129DE4; Tue, 24 Nov 2026 22:47:53 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795560472; b=5oJ2OnwRTQrDWF9pByO3f2QHlC0AjOd9IAALbRdBoXdQZ0S+js+L8xum+x+MGpcwFC9W f0DluWgIh/1dmSe8sib+npWdyJ3k01CA7b75Kho6npOU0UROWwyKhO67ZNErrZru7+dMD jof5PG3U8ogdrzC9iTAqL8QLVNNwhUmrxFIEUSdQiLSGgbQ94A0HHu/PMpI8Z1JtceG5p G2kzO9eoJRV2LudLS40r2bnaABmRxHsC+R7LQzOdRC6st8Yq7EHrJk/wuP5IS7rC8tNnz COJxlVhWg/fA4Bl+uDtubE4PSlhDsRgzMDuR4CwNHCoRnFNywz8Io9I/G9N2pj5zRrg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795560472; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=0R1qd0ZsGZVW1mj41hnJZL6GPjctmE+pDYfhYYzhDAg=; b=cuj+AV6GsP2xFliOp7XBgrQ9QZcPIYHq40S2I44RWrstOdepgca1s6fCw1Bh7yV7zFQq 7MW2gdXtDjrK9h6zbb18iVIkF3cdH8NhdctdFuC4R6ETt23SoclGLNDSplpWuQJnehvi9 5drq2xof20Gu1cwRPVBXIkWOMc5Hjx5VJUI+om5CHcoNUubTkYjqvpQWVuS5pniR7Fmox FpQ8/5iLcArvGTnDxEH3xKODQkvjuAn4VMB0hARDKSkp+IBuG0qIUzQbyCDYD17Ou3O1L kOcEd34uRzbhmupZ3A2nvHg1crohaPfZ5w4FUNNUy9ofREWvPqDhwVTQvv3uWSpOWjw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NJ8pZ6EC; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 54703606A330; Tue, 24 Nov 2026 22:47:52 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NJ8pZ6EC X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795560471; b=OruRFVXnqtJlnwU0mDYm7wMHMhI5TETK2Ehntkn1vriJN0Af4NoEtFKHzSXC32idwRbF b9fkcY43aD9P8jj5+wI+52hFTLBUU2shCfcT/Icdi5LBVw81W8OdeuTnmlS19VIBx/TQ4 gCNovHVpk0u1oF9kHm7urCOT2M0vUOTDJ+5rb3RrU92UrlqUR0ZTXf+m0d7cFK0D9o0BX 2MFq/G0uobzlQTZoo4wsSIhARjkMD7d1J++7dQyw5fa1rA1Xxu4mODq2qV+SWy5i7BMqe FGkYlC6K1+GCL4kABMKYw/TvWydSq97LcfV6n4wZ6I+W5TteoosCYsIJAe24LRSYaSg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795560471; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=0R1qd0ZsGZVW1mj41hnJZL6GPjctmE+pDYfhYYzhDAg=; b=PDZp9VGgLX7aU9UdOWNTnyBisocrHAuKU3DjvXFV8jp191DphoZZeTadUCRcrK46FkcR w4JVQghhMi6ljR09g5wRIfXooYJYb28Gow7iUwQbK0LZ54f2f6fDsMspgOnAPlRA03v7I rqV8IGnYsQ+wO0FnLZh3SMEOrG8Ov/S/8MDIsQUSBYwRvVFcKtbUbqrZ5a5JjP1tt7RjE nlxdXiBnJf9l/sB7PGLdXS7WJXnio1ZuP1DyHc1d8dfYT/XU+OYV70QV1lY/MM12x9U1j PzaQEKmIAsBangIPgi6RMDB6tZya3I05F9WFvJficL8674HXpDpTmhP4v+Rwdy4OxDA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NJ8pZ6EC; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 731DB606A31E; Tue, 24 Nov 2026 22:47:51 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 470F01F000C6; Tue, 24 Nov 2026 22:47:50 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795560471; bh=0R1qd0ZsGZVW1mj41hnJZL6GPjctmE+pDYfhYYzhDAg=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=NJ8pZ6EC9yA6FRSGxZpPrg9xYa0CZA3wlj4Q1S5oCejZ5AfDJ+CTr9lIr26yq4V+v WuKi8qT3aisUBL5wIIGNiN3UcMAtUO2H3ISmywkAl/xlBWU636Lq8auPolmN1zjt+h U4Tpjs51k9zo3nTKtqV4NzoSltqnxSpzuEX8evEJFj+XWFcEZffcizl2DKg3ddaRm8 ndhQrqftOcO4KiYYWn0b6bfN4ZBSUX7wsWDC+kcJU9TLOykFnCFCiXUKLc2RoAIHVV sHf+52SoDO3xggbocnDKMNd6ssxfy5sTfTowj+XwNkZxZIcrTiba2vemmsVllkKYBp QTvxkI0RM2L+g== X-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 X-In-Reply-To: <20261123221310.4045513-1-acassen@corp.free.fr> X-sashiko-severity: High X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list