linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Kubiak <michal.kubiak@intel.com>
To: Vlad Dogaru <vdogaru@nvidia.com>
Cc: Tariq Toukan <tariqt@nvidia.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	"Eric Dumazet" <edumazet@google.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"Gal Pressman" <gal@nvidia.com>,
	Leon Romanovsky <leonro@nvidia.com>,
	"Saeed Mahameed" <saeedm@nvidia.com>,
	Leon Romanovsky <leon@kernel.org>, <netdev@vger.kernel.org>,
	<linux-rdma@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Moshe Shemesh <moshe@nvidia.com>, Mark Bloch <mbloch@nvidia.com>,
	Yevgeny Kliteynik <kliteyn@nvidia.com>
Subject: Re: [PATCH net-next 01/12] net/mlx5: HWS, Fix matcher action template attach
Date: Wed, 9 Apr 2025 18:00:52 +0200	[thread overview]
Message-ID: <Z/aZtDJdSSunX1Fz@localhost.localdomain> (raw)
In-Reply-To: <8358f9a8-3a39-4e85-b2fe-5298da3d36cf@nvidia.com>

On Wed, Apr 09, 2025 at 05:56:19PM +0200, Vlad Dogaru wrote:
> On 4/9/25 17:21, Michal Kubiak wrote:
> > On Tue, Apr 08, 2025 at 05:00:45PM +0300, Tariq Toukan wrote:
> > > From: Vlad Dogaru <vdogaru@nvidia.com>
> > > 
> > > The procedure of attaching an action template to an existing matcher had
> > > a few issues:
> > > 
> > > 1. Attaching accidentally overran the `at` array in bwc_matcher, which
> > >     would result in memory corruption. This bug wasn't triggered, but it
> > >     is possible to trigger it by attaching action templates beyond the
> > >     initial buffer size of 8. Fix this by converting to a dynamically
> > >     sized buffer and reallocating if needed.
> > > 
> > > 2. Similarly, the `at` array inside the native matcher was never
> > >     reallocated. Fix this the same as above.
> > > 
> > > 3. The bwc layer treated any error in action template attach as a signal
> > >     that the matcher should be rehashed to account for a larger number of
> > >     action STEs. In reality, there are other unrelated errors that can
> > >     arise and they should be propagated upstack. Fix this by adding a
> > >     `need_rehash` output parameter that's orthogonal to error codes.
> > > 
> > > Fixes: 2111bb970c78 ("net/mlx5: HWS, added backward-compatible API handling")
> > > Signed-off-by: Vlad Dogaru <vdogaru@nvidia.com>
> > > Reviewed-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
> > > Reviewed-by: Mark Bloch <mbloch@nvidia.com>
> > > Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
> > 
> > In general the patch looks OK to me.
> > Just one request for clarification inline.
> 
> Thank you for reviewing.
> 
> > > ---
> > >   .../mellanox/mlx5/core/steering/hws/bwc.c     | 55 ++++++++++++++++---
> > >   .../mellanox/mlx5/core/steering/hws/bwc.h     |  9 ++-
> > >   .../mellanox/mlx5/core/steering/hws/matcher.c | 48 +++++++++++++---
> > >   .../mellanox/mlx5/core/steering/hws/matcher.h |  4 ++
> > >   .../mellanox/mlx5/core/steering/hws/mlx5hws.h |  5 +-
> > >   5 files changed, 97 insertions(+), 24 deletions(-)
> > > 
> > 
> > [...]
> > 
> > > @@ -520,6 +529,23 @@ hws_bwc_matcher_extend_at(struct mlx5hws_bwc_matcher *bwc_matcher,
> > >   			  struct mlx5hws_rule_action rule_actions[])
> > >   {
> > >   	enum mlx5hws_action_type action_types[MLX5HWS_BWC_MAX_ACTS];
> > > +	void *p;
> > > +
> > > +	if (unlikely(bwc_matcher->num_of_at >= bwc_matcher->size_of_at_array)) {
> > > +		if (bwc_matcher->size_of_at_array >= MLX5HWS_MATCHER_MAX_AT)
> > > +			return -ENOMEM;
> > > +		bwc_matcher->size_of_at_array *= 2;
> > 
> > Is it possible that `num_of_at` is even greater than twice `size_of_array`?
> > If so, shouldn't you calculate how many multiplications by 2 you need to
> > do?
> 
> We only extend the array by one template at a time, immediately after this
> check, so this can't happen.
> 
> Cheers,
> Vlad

Thank you for the clarification! Just double checking :-).

Cheers,
Reviewed-by: Michal Kubiak <michal.kubiak@intel.com>


  reply	other threads:[~2025-04-09 16:01 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-08 14:00 [PATCH net-next 00/12] net/mlx5: HWS, Refactor action STE handling Tariq Toukan
2025-04-08 14:00 ` [PATCH net-next 01/12] net/mlx5: HWS, Fix matcher action template attach Tariq Toukan
2025-04-09 15:21   ` Michal Kubiak
2025-04-09 15:56     ` Vlad Dogaru
2025-04-09 16:00       ` Michal Kubiak [this message]
2025-04-08 14:00 ` [PATCH net-next 02/12] net/mlx5: HWS, Remove unused element array Tariq Toukan
2025-04-09 15:50   ` Michal Kubiak
2025-04-08 14:00 ` [PATCH net-next 03/12] net/mlx5: HWS, Make pool single resource Tariq Toukan
2025-04-09 20:04   ` Michal Kubiak
2025-04-08 14:00 ` [PATCH net-next 04/12] net/mlx5: HWS, Refactor pool implementation Tariq Toukan
2025-04-09 21:24   ` Michal Kubiak
2025-04-08 14:00 ` [PATCH net-next 05/12] net/mlx5: HWS, Cleanup after pool refactoring Tariq Toukan
2025-04-09 21:23   ` Michal Kubiak
2025-04-10  9:39     ` Vlad Dogaru
2025-04-08 14:00 ` [PATCH net-next 06/12] net/mlx5: HWS, Add fullness tracking to pool Tariq Toukan
2025-04-10 11:38   ` Michal Kubiak
2025-04-08 14:00 ` [PATCH net-next 07/12] net/mlx5: HWS, Fix pool size optimization Tariq Toukan
2025-04-10 12:21   ` Michal Kubiak
2025-04-10 15:45     ` Vlad Dogaru
2025-04-08 14:00 ` [PATCH net-next 08/12] net/mlx5: HWS, Implement action STE pool Tariq Toukan
2025-04-10 15:09   ` Michal Kubiak
2025-04-08 14:00 ` [PATCH net-next 09/12] net/mlx5: HWS, Use the new " Tariq Toukan
2025-04-10 16:48   ` Michal Kubiak
2025-04-08 14:00 ` [PATCH net-next 10/12] net/mlx5: HWS, Cleanup matcher action STE table Tariq Toukan
2025-04-10 17:01   ` Michal Kubiak
2025-04-10 18:45     ` Vlad Dogaru
2025-04-08 14:00 ` [PATCH net-next 11/12] net/mlx5: HWS, Free unused action STE tables Tariq Toukan
2025-04-10 17:28   ` Michal Kubiak
2025-04-10 18:20     ` Vlad Dogaru
2025-04-11 11:22       ` Michal Kubiak
2025-04-08 14:00 ` [PATCH net-next 12/12] net/mlx5: HWS, Export action STE tables to debugfs Tariq Toukan
2025-04-10 17:06   ` Michal Kubiak

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=Z/aZtDJdSSunX1Fz@localhost.localdomain \
    --to=michal.kubiak@intel.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gal@nvidia.com \
    --cc=kliteyn@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=leonro@nvidia.com \
    --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=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;
as well as URLs for NNTP newsgroup(s).