Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Michael Kelley" <mhkelley58@gmail.com>
Cc: linux-hyperv@vger.kernel.org, linux-scsi@vger.kernel.org,
	dri-devel@lists.freedesktop.org
Subject: Re: [RESEND PATCH net-next 3/6] hv_netvsc: Remove GPADL teardown special case for old Hyper-V hosts
Date: Fri, 31 Jul 2026 20:12:09 +0000	[thread overview]
Message-ID: <20260731201210.3653C1F00AC4@smtp.kernel.org> (raw)
In-Reply-To: <20260730201123.1767-4-mhklinux@outlook.com>

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

Pre-existing issues:
- [High] If GPADL teardown fails, the receive/send buffers are mistakenly returned to the kernel allocator via vfree() instead of being intentionally leaked, creating a guest memory corruption vulnerability (DMA-after-free).
--

--- Patch [3]: [RESEND PATCH net-next 3/6] hv_netvsc: Remove GPADL teardown special case for old Hyper-V hosts ---
commit eeed9aa2167381d7fb4f1e329217b52e4689eb18
Author: Michael Kelley <mhkelley58@gmail.com>

hv_netvsc: Remove GPADL teardown special case for old Hyper-V hosts
    
With the overall removal of Linux support for running on Hyper-V
hosts earlier than WS2016 and Windows 10, the special case handling of
GPADL teardown is no longer necessary. Remove it.

> diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
> index 4d319c50955ed..4295b96b43127 100644
> --- a/drivers/net/hyperv/netvsc.c
> +++ b/drivers/net/hyperv/netvsc.c

[ ... ]

> @@ -733,14 +724,9 @@ void netvsc_device_remove(struct hv_device *device)
>  	/* Now, we can close the channel safely */
>  	vmbus_close(device->channel);
>  
> -	/*
> -	 * If host is Win2016 or higher then we do the GPADL tear down
> -	 * here after VMBus is closed.
> -	*/
> -	if (vmbus_proto_version >= VERSION_WIN10) {
> -		netvsc_teardown_recv_gpadl(device, net_device, ndev);
> -		netvsc_teardown_send_gpadl(device, net_device, ndev);
> -	}
> +	/* Must do the GPADL teardown after channel is closed */
> +	netvsc_teardown_recv_gpadl(device, net_device, ndev);
> +	netvsc_teardown_send_gpadl(device, net_device, ndev);
>  
>  	/* Release all resources */
>  	free_netvsc_device_rcu(net_device);

[Severity: High]
This is a pre-existing issue, but I noticed a potential DMA-after-free
related to these teardown functions.

If vmbus_teardown_gpadl() fails inside netvsc_teardown_recv_gpadl() (or the
send equivalent), the code attempts to intentionally leak the buffer rather
than bugchk:

drivers/net/hyperv/netvsc.c:netvsc_teardown_recv_gpadl() {
    ...
    ret = vmbus_teardown_gpadl(device->channel,
                               &net_device->recv_buf_gpadl_handle);
    if (ret != 0) {
        netdev_err(ndev, "unable to teardown receive buffer's gpadl\n");
        return;
    }
}

However, because net_device->recv_buf isn't set to NULL on this error path,
execution continues to free_netvsc_device_rcu() just below, which ends up
unconditionally freeing it:

drivers/net/hyperv/netvsc.c:free_netvsc_device() {
    ...
    if (!nvdev->recv_buf_gpadl_handle.decrypted)
        vfree(nvdev->recv_buf);
    ...
}

Since the GPADL teardown failed, does the host still have this memory mapped
when it gets returned to the kernel allocator via vfree(), leading to
potential guest memory corruption if the host writes to it?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260730201123.1767-1-mhklinux@outlook.com?part=3

  reply	other threads:[~2026-07-31 20:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-30 20:11 [RESEND PATCH 0/6] Remove support for Windows Server 2012/2012R2 & Win8/Win8.1 versions of Hyper-V Michael Kelley
2026-07-30 20:11 ` [RESEND PATCH 1/6] Drivers: hv: Remove support for WS2012/2012R2 & Win8/8.1 version " Michael Kelley
2026-07-31 20:12   ` sashiko-bot
2026-07-30 20:11 ` [RESEND PATCH net-next 2/6] hv_sock: Remove check for old Hyper-V hosts Michael Kelley
2026-07-30 20:46   ` Andrew Lunn
2026-07-31  3:06     ` Michael Kelley
2026-07-30 20:11 ` [RESEND PATCH net-next 3/6] hv_netvsc: Remove GPADL teardown special case " Michael Kelley
2026-07-31 20:12   ` sashiko-bot [this message]
2026-07-30 20:11 ` [RESEND PATCH 4/6] drm_hyperv: Remove support for synth video protocol of " Michael Kelley
2026-07-31 20:12   ` sashiko-bot
2026-07-30 20:11 ` [RESEND PATCH 5/6] scsi: storvsc: Remove support for storvsc " Michael Kelley
2026-07-30 20:11 ` [RESEND PATCH 6/6] clocksource: hyper-v: Remove support for stimer interrupts in message mode Michael Kelley
2026-07-30 22:24 ` [RESEND PATCH 0/6] Remove support for Windows Server 2012/2012R2 & Win8/Win8.1 versions of Hyper-V Hamza Mahfooz
2026-07-31  3:12   ` Michael Kelley
2026-07-30 22:45 ` Dave Hansen
2026-07-31  3:13   ` Michael Kelley

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=20260731201210.3653C1F00AC4@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mhkelley58@gmail.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