From: Tariq Toukan <tariqt@nvidia.com>
To: Runyu Xiao <runyu.xiao@seu.edu.cn>,
borisp@nvidia.com, saeedm@nvidia.com, leon@kernel.org,
tariqt@nvidia.com, mbloch@nvidia.com
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, sd@queasysnail.net,
dtatulea@nvidia.com, cjubran@nvidia.com, horms@kernel.org,
jianbol@nvidia.com, netdev@vger.kernel.org,
linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
jianhao.xu@seu.edu.cn
Subject: Re: [PATCH net-next] net/mlx5e: MACsec: annotate context list traversals
Date: Thu, 2 Jul 2026 16:19:28 +0300 [thread overview]
Message-ID: <127fd374-e03b-423a-b500-4d14c629e15b@nvidia.com> (raw)
In-Reply-To: <20260701124030.3208833-1-runyu.xiao@seu.edu.cn>
On 01/07/2026 15:40, Runyu Xiao wrote:
> The MACsec offload control paths take macsec->lock before looking up
> MACsec device and RX SC contexts. The lookup helpers walk RCU lists, but
> the iterators do not currently pass the mutex condition, so
> CONFIG_PROVE_RCU_LIST cannot see the existing writer/control-path
> protection.
>
> Pass lockdep_is_held(&macsec->lock) to the list iterators in the MACsec
> lookup helpers. The RX SC helper does not otherwise need the MACsec
> context, so pass it in only to express the existing lockdep condition.
>
> This was found by our static analysis tool and then manually reviewed
> against the current tree. The dynamic triage evidence is a
> target-matched CONFIG_PROVE_RCU_LIST warning; the change is limited
> to documenting the existing protection contract.
>
> This is a lockdep annotation cleanup. It does not change MACsec context
> lifetime or list updates.
>
> Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
> ---
> .../mellanox/mlx5/core/en_accel/macsec.c | 23 +++++++++++--------
> 1 file changed, 13 insertions(+), 10 deletions(-)
>
> 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 528b04d4de41..3028e327e36d 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
> @@ -405,11 +405,13 @@ static int mlx5e_macsec_init_sa(struct macsec_context *ctx,
> }
>
> static struct mlx5e_macsec_rx_sc *
> -mlx5e_macsec_get_rx_sc_from_sc_list(const struct list_head *list, sci_t sci)
> +mlx5e_macsec_get_rx_sc_from_sc_list(struct mlx5e_macsec *macsec,
> + const struct list_head *list, sci_t sci)
> {
> struct mlx5e_macsec_rx_sc *iter;
>
> - list_for_each_entry_rcu(iter, list, rx_sc_list_element) {
> + list_for_each_entry_rcu(iter, list, rx_sc_list_element,
> + lockdep_is_held(&macsec->lock)) {
> if (iter->sci == sci)
> return iter;
> }
> @@ -473,14 +475,15 @@ static bool mlx5e_macsec_secy_features_validate(struct macsec_context *ctx)
> }
>
> static struct mlx5e_macsec_device *
> -mlx5e_macsec_get_macsec_device_context(const struct mlx5e_macsec *macsec,
> +mlx5e_macsec_get_macsec_device_context(struct mlx5e_macsec *macsec,
Looking at the changes below, I don't find the const removal necessary.
> const struct macsec_context *ctx)
> {
> struct mlx5e_macsec_device *iter;
> const struct list_head *list;
>
> list = &macsec->macsec_device_list_head;
> - list_for_each_entry_rcu(iter, list, macsec_device_list_element) {
> + list_for_each_entry_rcu(iter, list, macsec_device_list_element,
> + lockdep_is_held(&macsec->lock)) {
> if (iter->netdev == ctx->secy->netdev)
> return iter;
> }
> @@ -692,7 +695,7 @@ static int mlx5e_macsec_add_rxsc(struct macsec_context *ctx)
> }
>
> rx_sc_list = &macsec_device->macsec_rx_sc_list_head;
> - rx_sc = mlx5e_macsec_get_rx_sc_from_sc_list(rx_sc_list, ctx_rx_sc->sci);
> + rx_sc = mlx5e_macsec_get_rx_sc_from_sc_list(macsec, rx_sc_list, ctx_rx_sc->sci);
> if (rx_sc) {
> netdev_err(ctx->netdev, "MACsec offload: rx_sc (sci %lld) already exists\n",
> ctx_rx_sc->sci);
> @@ -775,7 +778,7 @@ static int mlx5e_macsec_upd_rxsc(struct macsec_context *ctx)
> }
>
> list = &macsec_device->macsec_rx_sc_list_head;
> - rx_sc = mlx5e_macsec_get_rx_sc_from_sc_list(list, ctx_rx_sc->sci);
> + rx_sc = mlx5e_macsec_get_rx_sc_from_sc_list(macsec, list, ctx_rx_sc->sci);
> if (!rx_sc) {
> err = -EINVAL;
> goto out;
> @@ -853,7 +856,7 @@ static int mlx5e_macsec_del_rxsc(struct macsec_context *ctx)
> }
>
> list = &macsec_device->macsec_rx_sc_list_head;
> - rx_sc = mlx5e_macsec_get_rx_sc_from_sc_list(list, ctx->rx_sc->sci);
> + rx_sc = mlx5e_macsec_get_rx_sc_from_sc_list(macsec, list, ctx->rx_sc->sci);
> if (!rx_sc) {
> netdev_err(ctx->netdev,
> "MACsec offload rx_sc sci %lld doesn't exist\n",
> @@ -894,7 +897,7 @@ static int mlx5e_macsec_add_rxsa(struct macsec_context *ctx)
> }
>
> list = &macsec_device->macsec_rx_sc_list_head;
> - rx_sc = mlx5e_macsec_get_rx_sc_from_sc_list(list, sci);
> + rx_sc = mlx5e_macsec_get_rx_sc_from_sc_list(macsec, list, sci);
> if (!rx_sc) {
> netdev_err(ctx->netdev,
> "MACsec offload rx_sc sci %lld doesn't exist\n",
> @@ -978,7 +981,7 @@ static int mlx5e_macsec_upd_rxsa(struct macsec_context *ctx)
> }
>
> list = &macsec_device->macsec_rx_sc_list_head;
> - rx_sc = mlx5e_macsec_get_rx_sc_from_sc_list(list, sci);
> + rx_sc = mlx5e_macsec_get_rx_sc_from_sc_list(macsec, list, sci);
> if (!rx_sc) {
> netdev_err(ctx->netdev,
> "MACsec offload rx_sc sci %lld doesn't exist\n",
> @@ -1035,7 +1038,7 @@ static int mlx5e_macsec_del_rxsa(struct macsec_context *ctx)
> }
>
> list = &macsec_device->macsec_rx_sc_list_head;
> - rx_sc = mlx5e_macsec_get_rx_sc_from_sc_list(list, sci);
> + rx_sc = mlx5e_macsec_get_rx_sc_from_sc_list(macsec, list, sci);
> if (!rx_sc) {
> netdev_err(ctx->netdev,
> "MACsec offload rx_sc sci %lld doesn't exist\n",
prev parent reply other threads:[~2026-07-02 13:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-01 12:40 [PATCH net-next] net/mlx5e: MACsec: annotate context list traversals Runyu Xiao
2026-07-02 13:19 ` Tariq Toukan [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=127fd374-e03b-423a-b500-4d14c629e15b@nvidia.com \
--to=tariqt@nvidia.com \
--cc=andrew+netdev@lunn.ch \
--cc=borisp@nvidia.com \
--cc=cjubran@nvidia.com \
--cc=davem@davemloft.net \
--cc=dtatulea@nvidia.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jianbol@nvidia.com \
--cc=jianhao.xu@seu.edu.cn \
--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=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=runyu.xiao@seu.edu.cn \
--cc=saeedm@nvidia.com \
--cc=sd@queasysnail.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