BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tariq Toukan" <tariqt@nvidia.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net-next V3 07/15] net/mlx5e: macsec: Move RX marker from ft_metadata to flow_tag
Date: Fri, 04 Sep 2026 08:56:29 +0000	[thread overview]
Message-ID: <20260904085630.232B01F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260903085215.3691657-8-tariqt@nvidia.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Kernel panic in error path of MACsec rx/tx rule addition due to unconditional cleanup of uninitialized IDs.
--

commit 427d364a8074fd7354a5aec874b383f2ef24a88c
Author: Cosmin Ratiu <cratiu@nvidia.com>

net/mlx5e: macsec: Move RX marker from ft_metadata to flow_tag

This commit moves the MACsec RX marker from ft_metadata to flow_tag to
avoid conflicts with PSP SPI values. It defines a new marker for MACsec in
flow_tag, updating steering rules while keeping fs_id in ft_metadata.

> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/macsec_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/macsec_fs.c
> index efc5167493c12..4ca3a6ded2841 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/macsec_fs.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/macsec_fs.c
[ ... ]
> @@ -1803,6 +1805,11 @@ macsec_fs_rx_add_rule(struct mlx5_macsec_fs *macsec_fs,
>  
>  		macsec_fs_rx_setup_fte(spec, &flow_act, attrs, false);
>  
> +		spec->flow_context.flags |= FLOW_CONTEXT_HAS_TAG;
> +		spec->flow_context.flow_tag =
> +			FIELD_PREP(MLX5E_ACCEL_FLOW_TAG_PROTO_MASK,
> +				   MLX5E_ACCEL_FLOW_TAG_PROTO_MACSEC);
> +
>  		flow_act.modify_hdr = modify_hdr;
>  		flow_act.action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST |
>  				  MLX5_FLOW_CONTEXT_ACTION_CRYPTO_DECRYPT |

[Severity: High]
This is a pre-existing issue, but does the error path in macsec_fs_rx_add_rule()
have a potential NULL pointer dereference?

If macsec_fs_rx_add_rule() fails before macsec_fs_id_add() is called (for
example, if mlx5_add_flow_rules() fails), the error cleanup path unconditionally
calls macsec_fs_id_del() via macsec_fs_rx_del_rule():

err:
	macsec_fs_rx_del_rule(macsec_fs, rx_rule, macsec_ctx->secy->netdev, fs_id);
	macsec_rule = NULL;

If this happens on the very first rule added for a device, the device hasn't
been added to macsec_devices_list yet. In macsec_fs_id_del(), this causes
macsec_device to remain NULL:

	WARN_ON(!macsec_device);
	
	fs_id_xa = (is_tx) ? &macsec_device->tx_id_xa :
			     &macsec_device->rx_id_xa;
	xa_lock(fs_id_xa);
	fs_id_found = xa_load(fs_id_xa, fs_id);

This dereferences the NULL macsec_device when generating the address for
fs_id_xa, which is then passed to xa_lock(), leading to a kernel panic.

Could this be triggered under memory pressure or if firmware rejects a rule
creation request?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260903085215.3691657-1-tariqt@nvidia.com?part=7

  reply	other threads:[~2026-09-04  8:56 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03  8:52 [PATCH net-next V3 00/15] net/mlx5e: Add support for HW-GRO to PSP Tariq Toukan
2026-09-03  8:52 ` [PATCH net-next V3 01/15] net/mlx5e: Generalize TC <-> IPsec mutual exclusion Tariq Toukan
2026-09-03  8:52 ` [PATCH net-next V3 02/15] net/mlx5e: ipsec: Block TC offload when IPsec is enabled Tariq Toukan
2026-09-03  8:52 ` [PATCH net-next V3 03/15] net/mlx5e: psp: Block TC offload when PSP " Tariq Toukan
2026-09-03  8:52 ` [PATCH net-next V3 04/15] net/mlx5e: macsec: Block TC offload when MACsec " Tariq Toukan
2026-09-03  8:52 ` [PATCH net-next V3 05/15] net/mlx5e: psp: Move RX marker from ft_metadata to flow_tag Tariq Toukan
2026-09-03  8:52 ` [PATCH net-next V3 06/15] net/mlx5e: ipsec: " Tariq Toukan
2026-09-03  8:52 ` [PATCH net-next V3 07/15] net/mlx5e: macsec: " Tariq Toukan
2026-09-04  8:56   ` sashiko-bot [this message]
2026-09-03  8:52 ` [PATCH net-next V3 08/15] net/mlx5e: psp: Handle HW-decapsulated RX PSP packets Tariq Toukan
2026-09-03  8:52 ` [PATCH net-next V3 09/15] net/mlx5e: psp: Add an rx_decap steering table Tariq Toukan
2026-09-03  8:52 ` [PATCH net-next V3 10/15] net/mlx5e: shampo: Flush session on PSP mismatch Tariq Toukan
2026-09-03  8:52 ` [PATCH net-next V3 11/15] net/mlx5e: psp: Dynamically reconfigure based on SHAMPO mode Tariq Toukan
2026-09-03  8:52 ` [PATCH net-next V3 12/15] selftests: drv-net: psp: Extract shared helpers into psp_lib.py Tariq Toukan
2026-09-03  8:52 ` [PATCH net-next V3 13/15] selftests: drv-net: gro: Extract shared helpers into gro_lib.py Tariq Toukan
2026-09-04 12:34   ` Daniel Zahka
2026-09-03  8:52 ` [PATCH net-next V3 14/15] selftests: net: gro: Add PSP encapsulation and encryption Tariq Toukan
2026-09-03 10:26   ` Loktionov, Aleksandr
2026-09-04  8:56   ` sashiko-bot
2026-09-03  8:52 ` [PATCH net-next V3 15/15] selftests: drv-net: Add PSP HW GRO conformance tests Tariq Toukan

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=20260904085630.232B01F00A3D@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --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