Linux-HyperV List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Long Li" <longli@microsoft.com>
Cc: linux-hyperv@vger.kernel.org
Subject: Re: [PATCH net-next v4 1/4] net: mana: track when the HWC has been handed to the PF
Date: Wed, 02 Sep 2026 20:01:17 +0000	[thread overview]
Message-ID: <20260902200117.C71181F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260901200018.3194525-2-longli@microsoft.com>

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

Pre-existing issues:
- [High] If `mana_smc_teardown_hwc()` fails, the driver proceeds to unconditionally destroy the hardware queues and free their backing DMA memory, which can lead to a DMA use-after-free by the device.
--

commit 0af150088ed8994a134d0a328a359e4cea4bbce5
Author: Long Li <longli@microsoft.com>

net: mana: track when the HWC has been handed to the PF

This commit introduces a new setup_active flag to reliably track whether the
hardware queues have been handed to the physical function, addressing a gap
where the previous queue depth check was insufficient. This ensures accurate
state tracking during teardown to prepare for a future reinitialization path.

> diff --git a/drivers/net/ethernet/microsoft/mana/hw_channel.c b/drivers/net/ethernet/microsoft/mana/hw_channel.c
> index 263e7c4e29341..75fdccdc8c482 100644
> --- a/drivers/net/ethernet/microsoft/mana/hw_channel.c
> +++ b/drivers/net/ethernet/microsoft/mana/hw_channel.c
[ ... ]
> @@ -815,13 +815,20 @@ void mana_hwc_destroy_channel(struct gdma_context *gc)
>  	if (!hwc)
>  		return;
>  
> -	/* gc->max_num_cqs is set in mana_hwc_init_event_handler(). If it's
> -	 * non-zero, the HWC worked and we should tear down the HWC here.
> +	/* Tear down only if setup_hwc() handed the queues to the PF.  Until
> +	 * then the device never saw them, so there is nothing to undo.
>  	 */
> -	if (gc->max_num_cqs > 0) {
> -		mana_smc_teardown_hwc(&gc->shm_channel, false);
> -		gc->max_num_cqs = 0;
> +	if (hwc->setup_active) {
> +		/* Only a successful teardown invalidates the MST entries.  If
> +		 * it fails the device may still be using the queues, so leave
> +		 * the flag set rather than record a clean teardown.
> +		 */
> +		if (!mana_smc_teardown_hwc(&gc->shm_channel, false))
> +			hwc->setup_active = false;
> +		else
> +			dev_err(hwc->dev, "Failed to tear down HWC\n");
>  	}
> +	gc->max_num_cqs = 0;
>  
>  	if (hwc->txq)
>  		mana_hwc_destroy_wq(hwc, hwc->txq);

[Severity: High]
This is a pre-existing issue, but if mana_smc_teardown_hwc() fails, does the
driver proceed to unconditionally destroy the hardware queues and free their
backing DMA memory?

As the newly added comment acknowledges that "the device may still be using
the queues", calling mana_hwc_destroy_wq() unconditionally unmaps and frees
the DMA memory. If the physical function hardware is still active, could this
result in a DMA use-after-free leading to memory corruption or IOMMU faults?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260901200018.3194525-1-longli@microsoft.com?part=1

  reply	other threads:[~2026-09-02 20:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01 20:00 [PATCH net-next v4 0/4] net: mana: concurrent HWC requests and dynamic queue depth Long Li
2026-09-01 20:00 ` [PATCH net-next v4 1/4] net: mana: track when the HWC has been handed to the PF Long Li
2026-09-02 20:01   ` sashiko-bot [this message]
2026-09-02 20:04     ` [EXTERNAL] " Long Li
2026-09-01 20:00 ` [PATCH net-next v4 2/4] net: mana: give each HWC message slot its own completion state Long Li
2026-09-01 20:00 ` [PATCH net-next v4 3/4] net: mana: support concurrent HWC requests Long Li
2026-09-01 20:00 ` [PATCH net-next v4 4/4] net: mana: add dynamic HWC queue depth with reinit path Long Li
2026-09-02 20:01   ` sashiko-bot
2026-09-02 20:04     ` [EXTERNAL] " Long Li

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=20260902200117.C71181F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=longli@microsoft.com \
    --cc=sashiko-reviews@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