Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ziyu Zhang" <ziyuzhang201@gmail.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH net v2] net/mlx5e: Fix deadlock when parsing flow actions fails
Date: Fri, 27 Nov 2026 08:42:39 +0000	[thread overview]
Message-ID: <sashiko-outbox-236897@kernel.org> (raw)
In-Reply-To: <20261126084216.26436-1-ziyuzhang201@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] net/mlx5e: unorted post-actions on mlx5e_tc_add_fdb_flow()
  failure
--

commit 80bfe544864e1741e156f9fe2cf078e4de48e16b
Author: Ziyu Zhang <ziyuzhang201@gmail.com>

net/mlx5e: Fix deadlock when parsing flow actions fails

This commit avoids a deadlock between flow action parsing failure cleanup
and neighbour or route updates by deleting post-action rules, setting
MLX5E_TC_FLOW_FLAG_PARSE_FAILED, and completing flow->init_done before
detaching encap entries under encap_tbl_lock.

> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> index 011741553f5b9..9175fd469fdcd 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c

[ ... ]

> @@ -4580,8 +4605,10 @@ __mlx5e_add_fdb_flow(struct mlx5e_priv *priv,
>  		goto err_free;
>  
>  	err = parse_tc_fdb_actions(priv, &rule->action, flow, extack);
> -	if (err)
> +	if (err) {
> +		abort_flow_post_acts(flow);
>  		goto err_free;
> +	}
>  
>  	err = mlx5e_tc_add_fdb_flow(priv, flow, extack);
>  	complete_all(&flow->init_done);

[Severity: High]
What happens when parse_tc_fdb_actions() succeeds (attaching post-action
encaps and offloading post-action rules in alloc_flow_post_acts()), and
then mlx5e_tc_add_fdb_flow() fails (other than the multipath -ENETUNREACH
unready case)?

On failure, mlx5e_tc_add_fdb_flow() sets MLX5E_TC_FLOW_FLAG_FAILED,
leaving PARSE_FAILED and OFFLOADED unset, and __mlx5e_add_fdb_flow()
calls complete_all(&flow->init_done) before mlx5e_flow_put().  Because
mlx5e_take_tmp_flow() now waits for init_done before mlx5e_flow_get() and
only skips flows with PARSE_FAILED set:

CPU0                                  CPU1
__mlx5e_add_fdb_flow()
  parse_tc_fdb_actions()
    alloc_flow_post_acts()
                                      mlx5e_tc_fib_event_work()
                                        mutex_lock(&esw->offloads.encap_tbl_lock)
                                        mlx5e_take_tmp_flow()
                                          wait_for_completion(&flow->init_done)
  mlx5e_tc_add_fdb_flow() -> fails
    flow_flag_set(flow, FAILED)
  complete_all(&flow->init_done)
                                          flow_flag_test(flow, PARSE_FAILED) -> false
                                          mlx5e_flow_get(flow) -> succeeds
                                          list_add(&flow->tmp_list, ...)
  mlx5e_flow_put(priv, flow)

If the route update encounters the failed flow through two encap entries
before cleanup detaches them, mlx5e_take_tmp_flow() calls
list_add(&flow->tmp_list, flow_list) twice on the same node, corrupting
flow_list.  In addition, because OFFLOADED is not set,
mlx5e_tc_encap_flows_del() skips unoffloading the flow's post-action rules
and calls mlx5_packet_reformat_dealloc() on e->pkt_reformat while the
installed post-action hardware rules still reference it.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126084216.26436-1-ziyuzhang201@gmail.com?part=1

      parent reply	other threads:[~2026-11-27  8:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  8:42 [PATCH net v2] net/mlx5e: Fix deadlock when parsing flow actions fails Ziyu Zhang
2026-11-26  8:48 ` netdev-bot+sinfo
2026-11-27  8:42 ` sashiko-bot [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=sashiko-outbox-236897@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=ziyuzhang201@gmail.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