From: Nuno Das Neves <nunodasneves@linux.microsoft.com>
To: mhklinux@outlook.com, kys@microsoft.com, haiyangz@microsoft.com,
wei.liu@kernel.org, decui@microsoft.com, tglx@linutronix.de,
mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com,
hpa@zytor.com, lpieralisi@kernel.org, kw@linux.com,
mani@kernel.org, robh@kernel.org, bhelgaas@google.com,
arnd@arndb.de
Cc: x86@kernel.org, linux-hyperv@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
linux-arch@vger.kernel.org
Subject: Re: [PATCH v4 4/7] Drivers: hv: Use hv_setup_*() to set up hypercall arguments
Date: Mon, 28 Jul 2025 10:02:32 -0700 [thread overview]
Message-ID: <1303b11c-0d84-4f42-995e-6dd2c5a528c7@linux.microsoft.com> (raw)
In-Reply-To: <20250718045545.517620-5-mhklinux@outlook.com>
On 7/17/2025 9:55 PM, mhkelley58@gmail.com wrote:
<snip>
> diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
> index 2b4080e51f97..d9b569b204d2 100644
> --- a/drivers/hv/hv_balloon.c
> +++ b/drivers/hv/hv_balloon.c
> @@ -1577,21 +1577,21 @@ static int hv_free_page_report(struct page_reporting_dev_info *pr_dev_info,
> {
> unsigned long flags;
> struct hv_memory_hint *hint;
> - int i, order;
> + int i, order, batch_size;
> u64 status;
> struct scatterlist *sg;
>
> - WARN_ON_ONCE(nents > HV_MEMORY_HINT_MAX_GPA_PAGE_RANGES);
> WARN_ON_ONCE(sgl->length < (HV_HYP_PAGE_SIZE << page_reporting_order));
> local_irq_save(flags);
> - hint = *this_cpu_ptr(hyperv_pcpu_input_arg);
> +
> + batch_size = hv_setup_in_array(&hint, sizeof(*hint), sizeof(hint->ranges[0]));
> if (!hint) {
> local_irq_restore(flags);
> return -ENOSPC;
> }
> + WARN_ON_ONCE(nents > batch_size);
>
I don't think WARN_ON_ONCE is sufficient here... this looks like a bug in the current code.
The loop below will go out of bounds of the input page if nents is too large.
Ideally this function would be refactored to batch the operation so that this isn't a
problem.
Nuno
> hint->heat_type = HV_EXTMEM_HEAT_HINT_COLD_DISCARD;
> - hint->reserved = 0;
> for_each_sg(sgl, sg, nents, i) {
> union hv_gpa_page_range *range;
>
<snip>
next prev parent reply other threads:[~2025-07-28 17:02 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-18 4:55 [PATCH v4 0/7] hyperv: Introduce new way to manage hypercall args mhkelley58
2025-07-18 4:55 ` [PATCH v4 1/7] Drivers: hv: Introduce hv_setup_*() functions for hypercall arguments mhkelley58
2025-08-14 7:58 ` Tianyu Lan
2025-07-18 4:55 ` [PATCH v4 2/7] x86/hyperv: Use hv_setup_*() to set up hypercall arguments -- part 1 mhkelley58
2025-08-13 0:22 ` Nuno Das Neves
2025-08-13 0:41 ` Wei Liu
2025-08-13 18:22 ` Nuno Das Neves
2025-08-14 18:48 ` Michael Kelley
2025-07-18 4:55 ` [PATCH v4 3/7] x86/hyperv: Use hv_setup_*() to set up hypercall arguments -- part 2 mhkelley58
2025-07-18 4:55 ` [PATCH v4 4/7] Drivers: hv: Use hv_setup_*() to set up hypercall arguments mhkelley58
2025-07-28 17:02 ` Nuno Das Neves [this message]
2025-07-29 0:23 ` Michael Kelley
2025-07-18 4:55 ` [PATCH v4 5/7] PCI: " mhkelley58
2025-07-28 17:12 ` Nuno Das Neves
2025-07-18 4:55 ` [PATCH v4 6/7] Drivers: hv: Use hv_setup_*() to set up hypercall arguments for mshv code mhkelley58
2025-08-13 22:18 ` Nuno Das Neves
2025-07-18 4:55 ` [PATCH v4 7/7] Drivers: hv: Replace hyperv_pcpu_input/output_arg with hyperv_pcpu_arg mhkelley58
2025-08-13 22:20 ` Nuno Das Neves
2025-07-18 16:33 ` [PATCH v4 0/7] hyperv: Introduce new way to manage hypercall args Easwar Hariharan
2025-07-18 17:13 ` Michael Kelley
2025-07-18 20:25 ` Easwar Hariharan
2025-07-19 1:15 ` Roman Kisel
2025-07-21 2:19 ` Michael Kelley
2025-07-21 17:14 ` Roman Kisel
2025-07-21 19:30 ` Michael Kelley
2025-08-12 23:58 ` Wei Liu
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=1303b11c-0d84-4f42-995e-6dd2c5a528c7@linux.microsoft.com \
--to=nunodasneves@linux.microsoft.com \
--cc=arnd@arndb.de \
--cc=bhelgaas@google.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=hpa@zytor.com \
--cc=kw@linux.com \
--cc=kys@microsoft.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=mhklinux@outlook.com \
--cc=mingo@redhat.com \
--cc=robh@kernel.org \
--cc=tglx@linutronix.de \
--cc=wei.liu@kernel.org \
--cc=x86@kernel.org \
/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