Netdev List
 help / color / mirror / Atom feed
From: Yevgeny Kliteynik <kliteyn@nvidia.com>
To: Alexandre Cassen <acassen@corp.free.fr>,
	Saeed Mahameed <saeedm@nvidia.com>,
	Leon Romanovsky <leon@kernel.org>,
	Tariq Toukan <tariqt@nvidia.com>, Mark Bloch <mbloch@nvidia.com>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>, Moshe Shemesh <moshe@nvidia.com>,
	Vlad Dogaru <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 14:09:12 +0200	[thread overview]
Message-ID: <ac346bab-3e2b-47e5-9426-a55a60b7dff5@nvidia.com> (raw)
In-Reply-To: <20261123221310.4045513-1-acassen@corp.free.fr>

On 24-Nov-26 00:13, Alexandre Cassen wrote:
> An HWS rule keeps the chunk of its action STEs in rule->action_ste. An
> update saves it in rule->old_action_ste and frees it once the new match
> STE is written. When the new actions need no action STEs, the rule still
> points to that chunk. Its next update or its deletion free it again.
> 
> Two rules can then end up with the same action STEs. A packet of one can
> get the header rewrite or the meter of the other. The second free can
> also dereference an action STE table that the cleanup work has freed.
> Neither was observed.
> 
> The buddy allocator counts the same segment as free twice. After a few
> updates of several rules, it finds no segment where it counts one:
> 
>    ICM Buddy: failed finding free mem for order 0
>    WARNING: drivers/net/ethernet/mellanox/mlx5/core/steering/hws/buddy.c:93 at mlx5hws_buddy_alloc_mem+0x11a/0x140 [mlx5_core], CPU#34: tc/449154
>    Call Trace:
>     <TASK>
>     hws_pool_buddy_db_get_chunk+0x25/0x50 [mlx5_core]
>     mlx5hws_pool_chunk_alloc+0x30/0x80 [mlx5_core]
>     mlx5hws_action_ste_chunk_alloc+0x85/0x480 [mlx5_core]
>     hws_rule_create_hws+0x860/0x9c0 [mlx5_core]
>     mlx5hws_rule_action_update+0x81/0x140 [mlx5_core]
>     mlx5hws_bwc_rule_action_update+0x10d/0x200 [mlx5_core]
>     mlx5_cmd_hws_update_fte+0xb0/0x140 [mlx5_core]
>     del_hw_fte+0x1b2/0x390 [mlx5_core]
>     mlx5_del_flow_rules+0x10f/0x270 [mlx5_core]
>     __mlx5_eswitch_del_rule+0x5c/0x1b0 [mlx5_core]
>     mlx5_eswitch_del_offloaded_rule+0x10/0x20 [mlx5_core]
>     mlx5e_tc_rule_unoffload+0x4b/0x100 [mlx5_core]
>     mlx5e_tc_unoffload_fdb_rules+0x35/0x80 [mlx5_core]
>     mlx5e_tc_del_fdb_flow+0x2ca/0x310 [mlx5_core]
>     mlx5e_tc_del_flow+0x63/0x610 [mlx5_core]
>     mlx5e_flow_put+0x3a/0x80 [mlx5_core]
>     mlx5e_delete_flower+0x29b/0x460 [mlx5_core]
>     mlx5e_setup_tc_cls_flower+0x7d/0x90 [mlx5_core]
>     mlx5e_setup_tc_block_cb+0x58/0x90 [mlx5_core]
>     tc_setup_cb_destroy+0xcc/0x1b0
>     fl_hw_destroy_filter+0xa1/0xe0 [cls_flower]
>     fl_change+0x1bf1/0x20a9 [cls_flower]
>     tc_new_tfilter+0x432/0xea0
>     rtnetlink_rcv_msg+0x384/0x460
>     netlink_rcv_skb+0x61/0x120
>     rtnetlink_rcv+0x15/0x30
>     netlink_unicast+0x2a1/0x3d0
>     netlink_sendmsg+0x237/0x490
>     ____sys_sendmsg+0x32d/0x350
>     ___sys_sendmsg+0xaf/0x110
>     __sys_sendmsg+0x93/0x100
>     __x64_sys_sendmsg+0x1d/0x30
>     x64_sys_call+0x821/0x23d0
>     do_syscall_64+0xbd/0x570
>     </TASK>
> 
> The pool then holds more free elements than its size at close:
> 
>    mlx5_core 0000:31:00.0: mlx5hws_pool_destroy:386:(pid 448599): Attempting to destroy non-empty pool
> 
> Forget the chunk in rule->action_ste once it is saved, as the update
> flow did with the action STE index before the commit below.
> 
> Triggered during an endurance test of a 5G UPF code, on flower rules
> that lose their police action in place. The reproduction below gives
> the trace above on a ConnectX-7 with firmware 28.48.1000. It only
> uses tc and devlink, with no kernel change. DEV is the uplink
> representor and PCI its devlink handle:
> 
>    r() { for i in $(seq 128); do echo "filter $1 dev $DEV ingress prio 1 handle $i protocol ip flower skip_sw dst_ip 10.0.0.$i $2"; done | tc -b -; }
>    BIG="action pedit ex munge ip ttl set 63 pipe action csum ip pipe action police rate 1mbit burst 32k conform-exceed drop/pipe action drop"
>    devlink dev param set $PCI name flow_steering_mode value hmfs cmode runtime
>    devlink dev eswitch set $PCI mode switchdev
>    tc qdisc add dev $DEV ingress
>    r add "$BIG"
>    for n in 1 2 3; do r replace "action drop"; r replace "$BIG"; done
>    tc filter del dev $DEV ingress prio 1
>    devlink dev eswitch set $PCI mode legacy
> 
> With this fix, the reproduction runs clean on the same ConnectX-7.
> It was not tested against kernel selftests.
> 
> Not addressed here and not triggered: after a successful update,
> hws_rule_destroy_failed_hws() can free rule->old_action_ste again. A
> failed update can leak it now also when it needs no action STEs.
> 
> Fixes: 3fc44ca44d7c ("net/mlx5: HWS, update flow - support through bigger action RTC")
> Signed-off-by: Alexandre Cassen <acassen@corp.free.fr>
> ---
>   drivers/net/ethernet/mellanox/mlx5/core/steering/hws/rule.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> 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 0d4cb2b2393b..cc94d3149d76 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;

Reviewed-by: Yevgeny Kliteynik <kliteyn@nvidia.com>


      reply	other threads:[~2026-11-24 12:09 UTC|newest]

Thread overview: 2+ 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 [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=ac346bab-3e2b-47e5-9426-a55a60b7dff5@nvidia.com \
    --to=kliteyn@nvidia.com \
    --cc=acassen@corp.free.fr \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --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