From: Cosmin Ratiu <cratiu@nvidia.com>
To: Tariq Toukan <tariqt@nvidia.com>,
"netdev-bot+sashiko@kernel.org" <netdev-bot+sashiko@kernel.org>
Cc: Boris Pismenny <borisp@nvidia.com>,
"andrew+netdev@lunn.ch" <andrew+netdev@lunn.ch>,
"daniel.zahka@gmail.com" <daniel.zahka@gmail.com>,
"davem@davemloft.net" <davem@davemloft.net>,
Jianbo Liu <jianbol@nvidia.com>,
"sd@queasysnail.net" <sd@queasysnail.net>,
Emeel Hakim <ehakim@nvidia.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"edumazet@google.com" <edumazet@google.com>,
"pabeni@redhat.com" <pabeni@redhat.com>,
"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
Raed Salem <raeds@nvidia.com>,
"leon@kernel.org" <leon@kernel.org>,
Dragos Tatulea <dtatulea@nvidia.com>,
Carolina Jubran <cjubran@nvidia.com>, Roi Dayan <roid@nvidia.com>,
"kuba@kernel.org" <kuba@kernel.org>,
Mark Bloch <mbloch@nvidia.com>,
Lior Nahmanson <liorna@nvidia.com>,
Parav Pandit <parav@nvidia.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Rahul Rameshbabu <rrameshbabu@nvidia.com>,
Gal Pressman <gal@nvidia.com>,
"steffen.klassert@secunet.com" <steffen.klassert@secunet.com>,
Saeed Mahameed <saeedm@nvidia.com>
Subject: Re: [PATCH net 4/7] net/mlx5e: macsec: Track hardware object ownership for SA teardown
Date: Wed, 23 Sep 2026 08:32:01 +0000 [thread overview]
Message-ID: <5428938a1a365b235c864aaa440722f03a4d2b68.camel@nvidia.com> (raw)
In-Reply-To: <179001654813.2160803.1439419935536020425@kernel.org>
On Mon, 2026-09-21 at 18:49 +0000, netdev-bot+sashiko@kernel.org wrote:
> 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] `mlx5e_macsec_destroy_object()`
> (drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c:303-
> 312)…
>
> Pre-existing issues:
> - [High] TX steering rules are still programmed with an unallocated
> MACsec object ID.
> - [Medium] `mlx5e_macsec_upd_txsa()` commits `tx_sa->active =
> ctx_tx_sa->active;`…
>
> --
>
> net/mlx5e: macsec: Track hardware object ownership for SA teardown
>
> This adds a macsec_obj_created flag to struct mlx5e_macsec_sa, sets
> it after
> a successful hardware MACsec object creation, and checks it in
> mlx5e_macsec_cleanup_sa() before issuing the destroy command. The
> intent is
> to avoid destroying an object the driver never allocated, or one that
> was
> already destroyed while the driver SA kept its object ID.
>
> > diff --git
> > a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
> > b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
> > index daff53ba7d09f..20eec345b36cd 100644
> > --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
> > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
> > @@ -58,6 +58,7 @@ struct mlx5e_macsec_async_work {
> >
> > struct mlx5e_macsec_sa {
> > bool active;
> > + bool macsec_obj_created;
> > u8 assoc_num;
> > u32 macsec_obj_id;
> > u32 enc_key_id;
> > @@ -331,7 +332,10 @@ static void mlx5e_macsec_cleanup_sa(struct
> > mlx5e_macsec *macsec,
> > struct net_device *netdev, u32
> > fs_id)
> > {
> > mlx5e_macsec_cleanup_sa_fs(macsec, sa, is_tx, netdev,
> > fs_id);
> > - mlx5e_macsec_destroy_object(macsec->mdev, sa-
> > >macsec_obj_id);
> > + if (sa->macsec_obj_created) {
> > + mlx5e_macsec_destroy_object(macsec->mdev, sa-
> > >macsec_obj_id);
> > + sa->macsec_obj_created = false;
> > + }
> > }
>
> [Severity: High]
>
> This isn't a bug introduced by this patch, but the new flag
> establishes that
> macsec_obj_id is only meaningful while macsec_obj_created is set, and
> the
> paths that consume the ID do not honour that. Should the rule
> creation path
> check it too?
>
> mlx5e_macsec_init_sa_fs() copies the ID with no check:
>
> rule_attrs.macsec_obj_id = sa->macsec_obj_id;
> rule_attrs.sci = sa->sci;
> rule_attrs.assoc_num = sa->assoc_num;
>
> and macsec_fs_tx_setup_fte() in lib/macsec_fs.c hands that value to
> the
> device as the crypto object of the encrypt rule:
>
> flow_act->crypto.obj_id = macsec_obj_id;
>
> A TX SA can reach that point with macsec_obj_id == 0 and
> macsec_obj_created == false, because mlx5e_macsec_add_txsa() keeps
> the SA
> after creating only the key:
>
> macsec_device->tx_sa[assoc_num] = tx_sa;
> if (!secy->operational)
> goto out;
>
> Nothing creates the object afterwards: mlx5e_macsec_upd_txsa() and
> mlx5e_macsec_upd_secy() only call mlx5e_macsec_init_sa_fs(), never
> mlx5e_macsec_init_sa().
>
> Can the following plain configuration sequence reach that state, with
> no
> failure injection?
>
> ip macsec add <dev> tx sa 0 on key ... /* object created */
> ip macsec set <dev> tx sa 0 off /* macsec_upd_txsa() in
> drivers/net/macsec.c
> sets
> secy->operational =
> false */
> ip macsec add <dev> tx sa 1 on key ... /* assoc_num !=
> encoding_sa, so
> operational stays
> false and
>
> mlx5e_macsec_add_txsa()
> takes the early exit
> */
> ip link set <dev> type macsec encoding-sa 1 /*
> macsec_changelink_common()
> sets secy-
> >operational and
> macsec_changelink()
> calls
> mdo_upd_secy */
>
> mlx5e_macsec_upd_secy() then deletes all TX rules in its first loop
> and, in
> the second loop, matches SA 1:
>
> if (tx_sa->assoc_num == tx_sc->encoding_sa && tx_sa-
> >active) {
> err = mlx5e_macsec_init_sa_fs(ctx, tx_sa,
> tx_sc->encrypt, true, NULL);
> if (err)
> goto out;
> }
>
> so the encrypt rule is installed against object ID 0, which the
> driver never
> allocated. If firmware rejects it, the error surfaces as -ENOMEM
> from
> mlx5e_macsec_init_sa_fs() after the previous TX rules were already
> removed;
> if it accepts it, the SecY is operational with an encrypt rule bound
> to an
> object the driver does not own. Would guarding init_sa_fs() on
> macsec_obj_created (or creating the object when the SecY becomes
> operational)
> be the matching change?
>
> The ASO event lookups have the same predicate mismatch.
> get_macsec_tx_sa_from_obj_id() and get_macsec_rx_sa_from_obj_id()
> select SAs
> by activity, not by ownership:
>
> macsec_sa = iter->tx_sa[i];
> if (!macsec_sa || !macsec_sa->active)
> continue;
> if (macsec_sa->macsec_obj_id == obj_id)
> return macsec_sa;
>
> An active SA that carries an ID it does not own can be picked up for
> macsec_epn_update()/mlx5e_macsec_modify_obj(), while the inactive TX
> SA whose
> object this patch deliberately keeps alive is skipped and its EPN
> event is
> dropped as not found. Should these lookups test macsec_obj_created
> instead
> of active?
Seems serious enough, will address (two new patches required).
Cosmin.
next prev parent reply other threads:[~2026-09-23 8:32 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 17:54 [PATCH net 0/7] net/mlx5e: Fix offload lifetime, cleanup and exclusion bugs Tariq Toukan
2026-09-17 17:54 ` [PATCH net 1/7] net/mlx5e: ipsec: Block eswitch mode changes during policy creation Tariq Toukan
2026-09-21 18:49 ` netdev-bot+sashiko
2026-09-23 7:27 ` Cosmin Ratiu
2026-09-17 17:54 ` [PATCH net 2/7] net/mlx5e: ipsec: Block eswitch mode changes before accessing priv->ipsec Tariq Toukan
2026-09-21 18:49 ` netdev-bot+sashiko
2026-09-23 7:52 ` Cosmin Ratiu
2026-09-17 17:54 ` [PATCH net 3/7] net/mlx5e: tc: Tie esw & accel blocking refs to the flow's lifetime Tariq Toukan
2026-09-21 18:49 ` netdev-bot+sashiko
2026-09-23 7:59 ` Cosmin Ratiu
2026-09-17 17:54 ` [PATCH net 4/7] net/mlx5e: macsec: Track hardware object ownership for SA teardown Tariq Toukan
2026-09-21 18:49 ` netdev-bot+sashiko
2026-09-23 8:32 ` Cosmin Ratiu [this message]
2026-09-17 17:54 ` [PATCH net 5/7] net/mlx5e: macsec: Delete remaining SecYs during cleanup Tariq Toukan
2026-09-21 18:49 ` netdev-bot+sashiko
2026-09-23 8:49 ` Cosmin Ratiu
2026-09-17 17:54 ` [PATCH net 6/7] net/mlx5e: Serialize TC and IPsec offload exclusion counters Tariq Toukan
2026-09-17 17:54 ` [PATCH net 7/7] net/mlx5e: shampo: Do not merge PSP packets Tariq Toukan
2026-09-21 18:49 ` netdev-bot+sashiko
2026-09-23 8:50 ` Cosmin Ratiu
2026-09-22 10:44 ` [PATCH net 0/7] net/mlx5e: Fix offload lifetime, cleanup and exclusion bugs Paolo Abeni
2026-09-23 10:47 ` Cosmin Ratiu
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=5428938a1a365b235c864aaa440722f03a4d2b68.camel@nvidia.com \
--to=cratiu@nvidia.com \
--cc=andrew+netdev@lunn.ch \
--cc=borisp@nvidia.com \
--cc=cjubran@nvidia.com \
--cc=daniel.zahka@gmail.com \
--cc=davem@davemloft.net \
--cc=dtatulea@nvidia.com \
--cc=edumazet@google.com \
--cc=ehakim@nvidia.com \
--cc=gal@nvidia.com \
--cc=jianbol@nvidia.com \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=liorna@nvidia.com \
--cc=mbloch@nvidia.com \
--cc=netdev-bot+sashiko@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=parav@nvidia.com \
--cc=raeds@nvidia.com \
--cc=roid@nvidia.com \
--cc=rrameshbabu@nvidia.com \
--cc=saeedm@nvidia.com \
--cc=sd@queasysnail.net \
--cc=steffen.klassert@secunet.com \
--cc=tariqt@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
all inboxes | Powered by JetHome®