BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Dipayaan Roy" <dipayanroy@linux.microsoft.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH 2/3] net: mana: Skip WQ object destruction for uninitialized RXQ
Date: Fri, 01 May 2026 04:02:59 +0000	[thread overview]
Message-ID: <20260501040300.59883C2BCB7@smtp.kernel.org> (raw)
In-Reply-To: <20260430035935.1859220-3-dipayanroy@linux.microsoft.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Critical] Critical Use-After-Free and Double-Free in `mana_create_rxq()` error path.
- [High] Incomplete Fix: The identical bug fixed in `mana_destroy_rxq()` exists in `mana_destroy_txq()`.
--

commit c317e37e7bd422dc85e0c08611eda7f514d25eef
Author: Dipayaan Roy <dipayanroy@linux.microsoft.com>

net: mana: Skip WQ object destruction for uninitialized RXQ

This commit adds a check for INVALID_MANA_HANDLE in mana_destroy_rxq()
to prevent sending a bogus destroy command to the hardware when
mana_create_rxq() fails before the WQ object is created.

> diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
> index dfb4ba9f7664..f2a6ea162dc3 100644
> --- a/drivers/net/ethernet/microsoft/mana/mana_en.c
> +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
> @@ -2524,7 +2524,8 @@ static void mana_destroy_rxq(struct mana_port_context *apc,
>  	if (xdp_rxq_info_is_reg(&rxq->xdp_rxq))
>  		xdp_rxq_info_unreg(&rxq->xdp_rxq);
>  
> -	mana_destroy_wq_obj(apc, GDMA_RQ, rxq->rxobj);
> +	if (rxq->rxobj != INVALID_MANA_HANDLE)
> +		mana_destroy_wq_obj(apc, GDMA_RQ, rxq->rxobj);

Does this incomplete fix leave a regression in the TX queue destruction path?

In mana_create_txq(), apc->tx_qp is allocated via kzalloc_objs(), defaulting
tx_object to 0. It is set to INVALID_MANA_HANDLE only at the start of each
queue's loop iteration.

If mana_create_txq() fails early, it calls mana_destroy_txq(apc), which
unconditionally iterates over all apc->num_queues and calls:

    mana_destroy_wq_obj(apc, GDMA_SQ, apc->tx_qp[i].tx_object);

For the failing queue, it sends a destroy command for INVALID_MANA_HANDLE,
and for unreached queues, it sends 0. Should mana_destroy_txq() conditionally
check if tx_object is initialized before destroying it, similar to this fix?

While looking at this error path, I noticed a pre-existing regression that
is noted as fixed in a later commit (fbbff2b6d2993ad net: mana: remove
double CQ cleanup in mana_create_rxq error path).

In mana_create_rxq(), a local pointer cq is assigned to &rxq->rx_cq. If an
error occurs, it calls mana_destroy_rxq(), which frees rxq. Immediately
after, the error path checks if (cq) and calls mana_deinit_cq(apc, cq).

Since cq points into the freed rxq memory, does this result in a
use-after-free and double-free when mana_deinit_cq() reads cq->gdma_cq?

>  
>  	mana_deinit_cq(apc, &rxq->rx_cq);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260430035935.1859220-1-dipayanroy@linux.microsoft.com?part=2

  reply	other threads:[~2026-05-01  4:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-30  3:57 [PATCH 0/3] net: mana: Fix mana_destroy_rxq() cleanup for partial RXQ init Dipayaan Roy
2026-04-30  3:57 ` [PATCH 1/3] net: mana: check xdp_rxq registration before unreg in mana_destroy_rxq() Dipayaan Roy
2026-05-01  4:02   ` sashiko-bot
2026-04-30  3:57 ` [PATCH 2/3] net: mana: Skip WQ object destruction for uninitialized RXQ Dipayaan Roy
2026-05-01  4:02   ` sashiko-bot [this message]
2026-04-30  3:57 ` [PATCH 3/3] net: mana: remove double CQ cleanup in mana_create_rxq error path Dipayaan Roy
2026-04-30  4:14   ` Aditya Garg
2026-05-01  4:03   ` sashiko-bot
2026-05-02 16:52 ` [PATCH 0/3] net: mana: Fix mana_destroy_rxq() cleanup for partial RXQ init Simon Horman
2026-05-03  3:38   ` Dipayaan Roy
2026-05-05 10:20 ` patchwork-bot+netdevbpf

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=20260501040300.59883C2BCB7@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=dipayanroy@linux.microsoft.com \
    --cc=sashiko@lists.linux.dev \
    /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