From: sashiko-bot@kernel.org
To: "Zhao Li" <enderaoelyther@gmail.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH net] net/mlx5e: TC, fix a NULL pointer write in the peer flow error path
Date: Thu, 19 Nov 2026 02:57:56 +0000 [thread overview]
Message-ID: <sashiko-outbox-222352@kernel.org> (raw)
In-Reply-To: <20261118025708.86215-1-enderaoelyther@gmail.com>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] net/mlx5e: missing lock in mlx5e_tc_clean_fdb_peer_flows()
[1]
--
commit ee17d0ca384445e08f72eadef94d22d26656d903
Author: Zhao Li <enderaoelyther@gmail.com>
net/mlx5e: TC, fix a NULL pointer write in the peer flow error path
This commit moves the peer_flows xarray lookup before __mlx5e_add_fdb_flow()
in mlx5e_tc_add_fdb_peer_flow() so a missing peer entry returns -ENODEV
before creating and linking the duplicated flow.
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> index 708b7987ea4cd..d41969117d303 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> @@ -4630,6 +4630,10 @@ static int mlx5e_tc_add_fdb_peer_flow(struct flow_cls_offload *f,
> else
> in_mdev = priv->mdev;
>
> + dup_peer_flows = xa_load(&esw->offloads.peer_flows, peer_vhca_id);
> + if (!dup_peer_flows)
> + return -ENODEV;
> +
> flow_flags |= BIT(MLX5E_TC_FLOW_FLAG_PEER);
> parse_attr = flow->attr->parse_attr;
> peer_flow = __mlx5e_add_fdb_flow(peer_priv, f, flow_flags,
> @@ -4643,9 +4647,6 @@ static int mlx5e_tc_add_fdb_peer_flow(struct flow_cls_offload *f,
> peer_flow->peer_orig = flow;
> list_add_tail(&peer_flow->peer_flows, &flow->peer_flows);
> flow_flag_set(flow, DUP);
> - dup_peer_flows = xa_load(&esw->offloads.peer_flows, peer_vhca_id);
> - if (!dup_peer_flows)
> - return -ENODEV;
> mutex_lock(&esw->offloads.peer_mutex);
> list_add_tail(&peer_flow->peer, dup_peer_flows);
> mutex_unlock(&esw->offloads.peer_mutex);
[Severity: Critical]
This problem wasn't introduced by this patch, but can
mlx5e_tc_clean_fdb_peer_flows() corrupt the dup_peer_flows list or cause a
use-after-free when racing with concurrent flow additions or deletions
[1]?
mlx5e_tc_add_fdb_peer_flow() and mlx5e_tc_del_fdb_peer_flow() hold
esw->offloads.peer_mutex while modifying dup_peer_flows, whereas
mlx5e_tc_clean_fdb_peer_flows() walks the same list without taking
peer_mutex:
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c:mlx5e_tc_clean_fdb_peer_flows() {
xa_for_each(&esw->offloads.peer_flows, index, dup_peer_flows)
list_for_each_entry_safe(peer_flow, tmp_peer_flow,
dup_peer_flows, peer)
mlx5e_tc_del_fdb_peer_flow(peer_flow);
}
list_for_each_entry_safe() only tolerates removals by the current iteration;
a concurrent mlx5e_tc_add_fdb_peer_flow() or mlx5e_tc_del_fdb_peer_flow()
modifying dup_peer_flows can invalidate tmp_peer_flow or corrupt the list
pointers mid-traversal.
[1] https://sashiko.dev/#/bug/linux-184eb70a-9503-4852-b7bd-b8b8cdd3b641
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261118025708.86215-1-enderaoelyther@gmail.com?part=1
prev parent reply other threads:[~2026-11-19 2:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 2:57 [PATCH net] net/mlx5e: TC, fix a NULL pointer write in the peer flow error path Zhao Li
2026-11-19 2:57 ` 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-222352@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=enderaoelyther@gmail.com \
--cc=linux-rdma@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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