All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Michael Kelley" <mhkelley58@gmail.com>
Cc: linux-hyperv@vger.kernel.org
Subject: Re: [PATCH net 2/2] hv_netvsc: Leak send/recv buffers if GPADL teardown fails
Date: Fri, 04 Sep 2026 16:07:24 +0000	[thread overview]
Message-ID: <20260904160724.82AB51F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260903160651.1637-3-mhklinux@outlook.com>

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

Pre-existing issues:
- [High] `vmbus_teardown_gpadl` silently overwrites its error code on failure, hiding GPADL teardown failures and defeating the memory leak safeguard.
--

commit 67f15c255388157724c433ac1cc78395f8454d37
Author: Michael Kelley <mhkelley58@gmail.com>

hv_netvsc: Leak send/recv buffers if GPADL teardown fails

This commit updates the receive and send buffer teardown paths to call
vmbus_leak_buffer() when GPADL teardown fails. This ensures the buffers
are intentionally leaked rather than freed while the Hyper-V host might
still retain access to them.

Link: https://lore.kernel.org/linux-hyperv/20260731201210.3653C1F00AC4@smtp.kernel.org/

> diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
> index 5cd084e5696cd..449dc928cc445 100644
> --- a/drivers/net/hyperv/netvsc.c
> +++ b/drivers/net/hyperv/netvsc.c
> @@ -316,6 +316,9 @@ static void netvsc_teardown_recv_gpadl(struct hv_device *device,
>  		 * rather than continue and a bugchk
>  		 */
>  		if (ret != 0) {

[Severity: High]
This is a pre-existing issue, but this intended safeguard appears to be
ineffective because vmbus_teardown_gpadl() silently overwrites its error
code on failure.

If vmbus_post_msg() fails inside vmbus_teardown_gpadl(), the original error
code in ret is unconditionally overwritten with 0 when gpadl->decrypted is
false (the standard VM case):

drivers/hv/channel.c:vmbus_teardown_gpadl() {
    ...
post_msg_err:
        if (gpadl->decrypted)
                ret = set_memory_encrypted((unsigned long)gpadl->buffer,
                                           PFN_UP(gpadl->size));
        else
                ret = 0;
        ...
        return ret;
}

Because vmbus_teardown_gpadl() returns success despite failing, the
if (ret != 0) condition here will not evaluate to true, and the memory leak
safeguard will be skipped. Will this allow the buffers to be freed while the
Hyper-V host retains access, potentially causing memory corruption or a
use-after-free?

> +			vmbus_leak_buffer(&net_device->recv_buf,
> +					  &net_device->recv_buf_chunks,
> +					  &net_device->recv_buf_chunk_cnt);
>  			netdev_err(ndev,
>  				   "unable to teardown receive buffer's gpadl\n");
>  			return;

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

  reply	other threads:[~2026-09-04 16:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03 16:06 [PATCH 0/2] hv_netvsc: Fix leaking of send/receive buffers after GPADL teardown error Michael Kelley
2026-09-03 16:06 ` [PATCH 1/2] Drivers: hv: Add vmbus_leak_buffer() Michael Kelley
2026-09-03 16:06 ` [PATCH net 2/2] hv_netvsc: Leak send/recv buffers if GPADL teardown fails Michael Kelley
2026-09-04 16:07   ` sashiko-bot [this message]
2026-09-07 21:48 ` [PATCH 0/2] hv_netvsc: Fix leaking of send/receive buffers after GPADL teardown error 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=20260904160724.82AB51F00A3D@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-hyperv@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.