From: netdev-bot+sashiko@kernel.org
To: tariqt@nvidia.com
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, netdev@vger.kernel.org, pabeni@redhat.com,
acassen@corp.free.fr, valex@nvidia.com, erezsh@nvidia.com,
gal@nvidia.com, kees+treewide@kernel.org, leon@kernel.org,
linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org,
mbloch@nvidia.com, moshe@nvidia.com,
prathameshdeshpande7@gmail.com, saeedm@nvidia.com,
horms@kernel.org, william@theesfeld.net, kliteyn@nvidia.com
Subject: Re: [PATCH net V2 1/2] net/mlx5: HWS, Handle NULL in vport destination action creation
Date: Fri, 20 Nov 2026 05:35:18 +0000 [thread overview]
Message-ID: <179515291858.3136.13333642056498222976@kernel.org> (raw)
In-Reply-To: <20261118173227.1957670-2-tariqt@nvidia.com>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message for "net/mlx5: HWS, Handle NULL in vport
destination action creation" describes only part of what the bug did.
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the same
caller, mlx5_fs_fte_get_hws_actions() in…
--
net/mlx5: HWS, Handle NULL in vport destination action creation
This patch makes mlx5_fs_get_dest_action_vport() return NULL as soon as
mlx5hws_action_create_dest_vport() fails. A NULL entry is therefore never
inserted into the vport destination xarray. Before this change, inserting
NULL could later cause a NULL dereference in hws_action_destroy_hws().
> The next mlx5hws_action_create_dest_vport() failure will try to
> insert NULL again, but xa_insert() will return -EBUSY, because
> we already have NULL entry. In such case the code will go into
> error flow of action creation, and eventually will cause NULL
> dereference at hws_action_destroy_hws().
[Severity: Low]
This isn't a bug, but does this describe the whole impact? The text covers
a later creation for the same idx failing again. What about a later
creation that succeeds?
When the entry is NULL, __xa_insert() stores XA_ZERO_ENTRY instead:
lib/xarray.c:__xa_insert() {
...
if (!entry)
entry = XA_ZERO_ENTRY;
...
}
xa_load() turns that back into NULL. The slot looks empty but stays
reserved.
Suppose a later mlx5hws_action_create_dest_vport() call succeeds, for
example once a transient kzalloc or STC pool failure has cleared. The old
code then appears to loop:
mlx5_fs_get_dest_action_vport()
dest_load:
xa_load() returns NULL
mlx5hws_action_create_dest_vport() returns a valid action
xa_insert() returns -EBUSY
mlx5hws_action_destroy(dest)
goto dest_load
Wouldn't this spin forever and hang rule insertion for that vport?
The fix covers both outcomes, since NULL is never inserted now. Could the
commit message also mention the livelock?
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.c
> index cbcbc2b62809d..de22e7279a312 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.c
> @@ -441,6 +441,8 @@ mlx5_fs_get_dest_action_vport(struct mlx5_fs_hws_context *fs_ctx,
>
> dest = mlx5hws_action_create_dest_vport(ctx, vport_num, vhca_id_valid,
> dest_attr->vport.vhca_id, flags);
> + if (!dest)
> + return NULL;
>
> err = xa_insert(dests_xa, idx, dest, GFP_KERNEL);
> if (err) {
[Severity: High]
This is a pre-existing issue, but can the same caller,
mlx5_fs_fte_get_hws_actions(), still oops on a NULL action in other
destination cases?
In three cases the result goes into fs_actions[] and is counted before
the NULL check. These are FLOW_TABLE_NUM (when the action has to be
created), RANGE and FLOW_SAMPLER:
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.c:mlx5_fs_fte_get_hws_actions() {
...
dest_action = mlx5_fs_create_dest_action_table_num(fs_ctx,
dst);
fs_actions[num_fs_actions++].action = dest_action;
break;
case MLX5_FLOW_DESTINATION_TYPE_RANGE:
dest_action = mlx5_fs_create_dest_action_range(ctx, dst);
fs_actions[num_fs_actions++].action = dest_action;
break;
...
case MLX5_FLOW_DESTINATION_TYPE_FLOW_SAMPLER:
dest_action =
mlx5_fs_get_dest_action_sampler(fs_ctx,
dst);
fs_actions[num_fs_actions].action = dest_action;
fs_actions[num_fs_actions++].sampler_id =
dst->dest_attr.sampler_id;
break;
...
if (!dest_action) {
err = -ENOMEM;
goto free_actions;
}
...
}
Each of these can return NULL:
mlx5hws_action_create_dest_table_num(): allocation failure or STC pool
exhaustion
mlx5hws_action_create_dest_match_range(): invalid range parameters, or
allocation, definer or STC failure
mlx5_fs_get_dest_action_sampler(): GFP_ATOMIC allocation or
__xa_insert() failure, or failure to create the sampler action
The free_actions path then calls teardown on every counted entry:
mlx5_fs_destroy_fs_actions()
mlx5_fs_destroy_fs_action()
mlx5hws_action_get_type(fs_action->action)
return action->type; <-- NULL dereference
The other patch in this series, "net/mlx5: DR, Fix out-of-bounds write
when sync to HW fails", only touches sws/dr_icm_pool.c and does not fix
this.
Could dest_action be checked before it goes into fs_actions[]?
Alternatively, mlx5_fs_destroy_fs_actions() could skip NULL entries.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118173227.1957670-1-tariqt%40nvidia.com
next prev parent reply other threads:[~2026-11-20 5:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 17:32 [PATCH net V2 0/2] net/mlx5: Fix HWS and DR steering memory safety bugs Tariq Toukan
2026-11-18 17:32 ` [PATCH net V2 1/2] net/mlx5: HWS, Handle NULL in vport destination action creation Tariq Toukan
2026-11-20 5:35 ` netdev-bot+sashiko [this message]
2026-11-18 17:32 ` [PATCH net V2 2/2] net/mlx5: DR, Fix out-of-bounds write when sync to HW fails Tariq Toukan
2026-11-20 5:35 ` netdev-bot+sashiko
2026-11-18 17:37 ` [PATCH net V2 0/2] net/mlx5: Fix HWS and DR steering memory safety bugs netdev-bot+sinfo
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=179515291858.3136.13333642056498222976@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=erezsh@nvidia.com \
--cc=gal@nvidia.com \
--cc=horms@kernel.org \
--cc=kees+treewide@kernel.org \
--cc=kliteyn@nvidia.com \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.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=prathameshdeshpande7@gmail.com \
--cc=saeedm@nvidia.com \
--cc=tariqt@nvidia.com \
--cc=valex@nvidia.com \
--cc=william@theesfeld.net \
/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
all inboxes | Powered by JetHome®