From: sashiko-bot@kernel.org
To: "Emerson Busson" <emersonbusson@gmail.com>
Cc: linux-hyperv@vger.kernel.org
Subject: Re: [PATCH v3 1/3] hv: vmbus: encapsulate buffer and GPADL state in struct vmbus_buffer
Date: Wed, 25 Nov 2026 21:41:07 +0000 [thread overview]
Message-ID: <sashiko-outbox-234197@kernel.org> (raw)
In-Reply-To: <20261124214030.174246-2-emersonbusson@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] hv: vmbus: memory leak in __vmbus_establish_gpadl() on header
post failure
--
commit 16a8eda5166da158148ed19c9564e3550cf77b17
Author: Emerson Busson <emersonbusson@gmail.com>
hv: vmbus: encapsulate buffer and GPADL state in struct vmbus_buffer
This commit introduces struct vmbus_buffer to combine VMBus buffer
allocation metadata, GPADL handle, and leak tracking into a single
descriptor, and converts hv_netvsc and uio_hv_generic to use it.
> diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
> index a0883ddf32e2f..9807ff35a1b7e 100644
> --- a/drivers/hv/channel.c
> +++ b/drivers/hv/channel.c
[ ... ]
> @@ -492,11 +497,9 @@ static int __vmbus_establish_gpadl(struct vmbus_channel *channel,
> gpadlmsg->child_relid = channel->offermsg.child_relid;
> gpadlmsg->gpadl = next_gpadl_handle;
>
> -
> spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
> list_add_tail(&msginfo->msglistentry,
> &vmbus_connection.chn_msg_list);
> -
> spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
>
> if (channel->rescind) {
> @@ -504,6 +507,7 @@ static int __vmbus_establish_gpadl(struct vmbus_channel *channel,
> goto cleanup;
> }
>
> + posted = true;
> ret = vmbus_post_msg(gpadlmsg, msginfo->msgsize -
> sizeof(*msginfo), true);
>
[ ... ]
> @@ -559,121 +562,100 @@ static int __vmbus_establish_gpadl(struct vmbus_channel *channel,
>
> vmbus_free_channel_msginfo(msginfo);
>
> - if (ret) {
> - /*
> - * If set_memory_encrypted() fails, the decrypted flag is
> - * left as true so the memory is leaked instead of being
> - * put back on the free list.
> - */
> - if (gpadl->decrypted) {
> - if (!set_memory_encrypted((unsigned long)kbuffer, PFN_UP(size)))
> - gpadl->decrypted = false;
> - }
> + if (ret && posted && leak)
> + *leak = true;
> +
> + if (ret && !posted && need_decrypt) {
> + if (!set_memory_encrypted((unsigned long)kbuffer, PFN_UP(size)) &&
> + decrypted)
> + *decrypted = false;
> }
>
> return ret;
> }
[Severity: Medium]
Does setting posted = true before vmbus_post_msg() leak the buffer when
posting the initial CHANNELMSG_GPADL_HEADER message fails?
vmbus_post_msg() only returns an error if the synchronous
HVCALL_POST_MESSAGE hypercall failed on every attempt and the header never
reached the host. Because posted is already true on that error path,
cleanup sets *leak = true (and skips set_memory_encrypted() and clearing
*decrypted for ring buffers), causing vmbus_free_buffer() or
vmbus_free_ring() to leak the backing pages. Should posted be set only
after the header vmbus_post_msg() succeeds?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124214030.174246-1-emersonbusson@gmail.com?part=1
next prev parent reply other threads:[~2026-11-25 21:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 21:40 [PATCH v3 0/3] hv: vmbus: make rings and host-visible buffers survive buddy fragmentation Emerson Busson
2026-11-24 21:40 ` [PATCH v3 1/3] hv: vmbus: encapsulate buffer and GPADL state in struct vmbus_buffer Emerson Busson
2026-11-25 21:41 ` sashiko-bot [this message]
2026-11-26 0:08 ` Kameron Carr
2026-11-24 21:40 ` [PATCH v3 2/3] hv: vmbus: allocate ring buffers via vmbus_alloc_buffer() Emerson Busson
2026-11-25 21:41 ` sashiko-bot
2026-11-25 23:53 ` Kameron Carr
2026-11-24 21:40 ` [PATCH v3 3/3] hv: vmbus: allocate requestor metadata with kvcalloc() Emerson Busson
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=sashiko-outbox-234197@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=emersonbusson@gmail.com \
--cc=linux-hyperv@vger.kernel.org \
--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.