From: vdso@mailbox.org
To: Junrui Luo <moonafterrain@outlook.com>,
Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
Cc: "K. Y. Srinivasan" <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>,
Long Li <longli@microsoft.com>,
Nuno Das Neves <nunodasneves@linux.microsoft.com>,
Anirudh Rayabharam <anrayabh@linux.microsoft.com>,
Mukesh Rathor <mrathor@linux.microsoft.com>,
Muminul Islam <muislam@microsoft.com>,
Praveen K Paladugu <prapal@linux.microsoft.com>,
Jinank Jain <jinankjain@microsoft.com>,
"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Yuhao Jiang <danisjiang@gmail.com>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH v2] Drivers: hv: mshv: fix integer overflow in memory region overlap check
Date: Mon, 13 Apr 2026 10:10:46 -0800 (PST) [thread overview]
Message-ID: <1644495552.14476.1776103846016@app.mailbox.org> (raw)
In-Reply-To: <19EDB8B0-A6F4-460F-8ABA-E9D3E239511B@outlook.com>
> On 04/13/2026 1:43 AM PDT Junrui Luo <moonafterrain@outlook.com> wrote:
>
>
> On Fri, Apr 10, 2026 at 09:05:35PM -0800, vdso@mailbox.org wrote:
> > All in all, from the three options of (generic check for overflow, simple check
> > for arch bad PFNs/GFNs, an elaborated check with all specifics) I suggested the simple check.
> > Fast and still more useful than checking for overflow in my opinion.
>
> Thanks Roman for the thorough write-up. Since the original patch mixes
> host and hypervisor-side constants with an unclear unit, IMO we should
> do the bounds check in bytes instead.
>
> For instance:
>
> u64 start_gpa, end_gpa;
>
> if (check_mul_overflow(mem->guest_pfn, HV_HYP_PAGE_SIZE,
> &start_gpa) ||
> check_add_overflow(start_gpa, mem->size, &end_gpa) ||
> end_gpa > (1ULL << MAX_PHYSMEM_BITS))
> return -EINVAL;
>
> Both sides of the final comparison are bytes, so no host-vs-hv page
> unit conversion is needed.
I like that better indeed!
>
> In addition, it changes return value from -EOVERFLOW to -EINVAL.
I think that good, too: -EOVERFLOW originated iiuc and is more used
in VFS from my cursory glance.
>
> Does this approach look reasonable? Happy to iterate if either of you
> would prefer a different choice.
I agree with all your points, feels like a better place now :)
I'd defer the final smell check to Stanislav. Stanislav maintains this code
as the daily job, and might have a better feel and perspective for it. I've
been happy to add my 2c!
>
> Thanks,
> Junrui Luo
prev parent reply other threads:[~2026-04-13 18:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-28 9:18 [PATCH v2] Drivers: hv: mshv: fix integer overflow in memory region overlap check Junrui Luo
2026-03-30 21:13 ` Stanislav Kinsburskii
2026-04-01 15:23 ` Junrui Luo
2026-04-02 23:25 ` Stanislav Kinsburskii
2026-04-10 3:06 ` Junrui Luo
2026-04-11 5:05 ` vdso
2026-04-13 8:43 ` Junrui Luo
2026-04-13 18:10 ` vdso [this message]
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=1644495552.14476.1776103846016@app.mailbox.org \
--to=vdso@mailbox.org \
--cc=anrayabh@linux.microsoft.com \
--cc=danisjiang@gmail.com \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=jinankjain@microsoft.com \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=moonafterrain@outlook.com \
--cc=mrathor@linux.microsoft.com \
--cc=muislam@microsoft.com \
--cc=nunodasneves@linux.microsoft.com \
--cc=prapal@linux.microsoft.com \
--cc=skinsburskii@linux.microsoft.com \
--cc=stable@vger.kernel.org \
--cc=wei.liu@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