Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: lirongqing <lirongqing@baidu.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>, linux-rdma@vger.kernel.org
Subject: Re: [PATCH] RDMA/mlx5: Fix NULL deref in del_sa_roce_rule() on allocation failure
Date: Sun, 11 Oct 2026 10:46:25 +0300	[thread overview]
Message-ID: <20261011074625.GA27033@unreal> (raw)
In-Reply-To: <20261002110329.2350-1-lirongqing@baidu.com>

On Fri, Oct 02, 2026 at 07:03:29PM +0800, lirongqing wrote:
> From: Li RongQing <lirongqing@baidu.com>
> 
> get_macsec_device() allocates and links a new mlx5_macsec_device when
> the macdev has no existing entry, and returns NULL when that allocation
> fails.  del_sa_roce_rule() only flagged the NULL case with WARN_ON() and
> kept dereferencing macsec_device, so a MACsec SA delete event for a
> macdev that was never set up by the RoCE GID path would dereference NULL
> under memory pressure.
> 
> Return after the warning so the SA delete event is dropped instead of
> oopsing.
> 
> Fixes: 58dbd6428a68 ("RDMA/mlx5: Handles RoCE MACsec steering rules addition and deletion")
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
> ---
>  drivers/infiniband/hw/mlx5/macsec.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/mlx5/macsec.c b/drivers/infiniband/hw/mlx5/macsec.c
> index 4732be5..37394ea 100644
> --- a/drivers/infiniband/hw/mlx5/macsec.c
> +++ b/drivers/infiniband/hw/mlx5/macsec.c
> @@ -119,7 +119,8 @@ static void del_sa_roce_rule(struct list_head *macsec_devices_list,
>  	struct mlx5_macsec_device *macsec_device;
>  
>  	macsec_device = get_macsec_device(data->macdev, macsec_devices_list);

At this point, `macsec_device` MUST already exist, and the allocation path
is used only during initialization.

Thanks

> -	WARN_ON(!macsec_device);
> +	if (WARN_ON(!macsec_device))
> +		return;
>  
>  	mlx5_macsec_del_roce_sa_rules(data->fs_id, data->macsec_fs,
>  				      &macsec_device->tx_rules_list,
> -- 
> 2.9.4
> 

      parent reply	other threads:[~2026-10-11  7:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-02 11:03 [PATCH] RDMA/mlx5: Fix NULL deref in del_sa_roce_rule() on allocation failure lirongqing
2026-10-02 11:14 ` sashiko-bot
2026-10-11  7:46 ` Leon Romanovsky [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=20261011074625.GA27033@unreal \
    --to=leon@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=linux-rdma@vger.kernel.org \
    --cc=lirongqing@baidu.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