Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Alexandre Cassen" <acassen@corp.free.fr>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH net v2 2/2] net/mlx5: HWS, fix modify header pool creation race
Date: Tue, 13 Oct 2026 10:08:11 +0000	[thread overview]
Message-ID: <sashiko-outbox-169457@kernel.org> (raw)
In-Reply-To: <20261012100555.1317878-3-acassen@corp.free.fr>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] mlx5: hws: 32-bit truncation in modify header action match
--

commit 33535690e64312a76a1dd5c1afe587641631b515
Author: Alexandre Cassen <acassen@corp.free.fr>

net/mlx5: HWS, fix modify header pool creation race

This commit addresses a race condition during modify header pool creation
where concurrent callers might allocate pools at the same index. It fixes
this by keeping created pools until cleanup, allowing lockless lookups for
existing pools while using a mutex for creation.

> 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 66edb42268cbd..11cced847186e 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
[ ... ]
> @@ -1457,6 +1459,23 @@ mlx5_fs_destroy_mh_pool(struct mlx5_fs_pool *pool, struct xarray *mh_pools,
>  	kfree(pool);
>  }
>  
> +static struct mlx5_fs_pool *
> +mlx5_fs_find_mh_pool(struct xarray *mh_pools,
> +		     struct mlx5hws_action_mh_pattern *pattern,
> +		     unsigned long *cnt)
> +{
> +	struct mlx5_fs_pool *pool;
> +	unsigned long i;
> +
> +	*cnt = 0;
> +	xa_for_each(mh_pools, i, pool) {
> +		if (mlx5_fs_hws_mh_pool_match(pool, pattern))

[Severity: High]
Does this code rely on a matching function that truncates 64-bit payload
data?

Looking at mlx5_fs_hws_mh_pool_match() in
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws_pools.c, it
casts the 64-bit modify action words down to 32 bits:

		if ((__force __be32)pattern->data[i] !=
		    (__force __be32)pool_pattern->data[i])
			return false;

Since data is an array of 64-bit elements (__be64 *data), this discards 32
bits which include fields like action_type, field, offset, and length.
Consequently, two distinct modify actions sharing the same lower 32 bits will
incorrectly match, and the driver might apply the wrong header modifications.

Can this be triggered by user-space or network admin configurations setting
up similar TC or RDMA flow rules, resulting in wrong hardware pool reuse and
corrupted traffic headers?

> +			return pool;
> +		(*cnt)++;
> +	}
> +	return NULL;
> +}
> +

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261012100555.1317878-1-acassen@corp.free.fr?part=2

      parent reply	other threads:[~2026-10-13 10:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-12 10:05 [PATCH net v2 0/2] net/mlx5: HWS, fix pool creation races Alexandre Cassen
2026-10-12 10:05 ` [PATCH net v2 1/2] net/mlx5: HWS, fix reformat pool creation race Alexandre Cassen
2026-10-13 10:08   ` sashiko-bot
2026-10-13 10:25   ` netdev-bot+sashiko
2026-10-12 10:05 ` [PATCH net v2 2/2] net/mlx5: HWS, fix modify header " Alexandre Cassen
2026-10-12 18:03   ` Moshe Shemesh
2026-10-13 10:08   ` 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-169457@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=acassen@corp.free.fr \
    --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