From: Wei Liu <wei.liu@kernel.org>
To: Junrui Luo <moonafterrain@outlook.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>,
Jinank Jain <jinankjain@microsoft.com>,
Praveen K Paladugu <prapal@linux.microsoft.com>,
Mukesh Rathor <mrathor@linux.microsoft.com>,
Nuno Das Neves <nunodasneves@linux.microsoft.com>,
Anirudh Rayabharam <anrayabh@linux.microsoft.com>,
Roman Kisel <romank@linux.microsoft.com>,
Muminul Islam <muislam@microsoft.com>,
linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org,
Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>,
Yuhao Jiang <danisjiang@gmail.com>
Subject: Re: [PATCH] Drivers: hv: mshv: add bounds check on vp_index in mshv_intercept_isr()
Date: Sun, 7 Jun 2026 23:23:10 -0700 [thread overview]
Message-ID: <20260608062310.GC1555293@liuwe-devbox-debian-v2.local> (raw)
In-Reply-To: <SYBPR01MB7881B8B5D35E02A0E8404E4FAF232@SYBPR01MB7881.ausprd01.prod.outlook.com>
On Thu, Apr 16, 2026 at 10:18:05PM +0800, Junrui Luo wrote:
> mshv_intercept_isr() extracts vp_index from the hypervisor message
> payload and uses it directly to index into pt_vp_array without
> validation. handle_bitset_message() and handle_pair_message() already
> validate vp_index against MSHV_MAX_VPS before array access.
>
> A vp_index exceeding MSHV_MAX_VPS leads to an out-of-bounds read from
> pt_vp_array.
>
> Add the same MSHV_MAX_VPS bounds check for consistency with the other
> message handlers.
>
> Fixes: 621191d709b1 ("Drivers: hv: Introduce mshv_root module to expose /dev/mshv to VMMs")
> Reported-by: Yuhao Jiang <danisjiang@gmail.com>
> Signed-off-by: Junrui Luo <moonafterrain@outlook.com>
Like other places say, the hypervisor shouldn't give us an out-of-bound
index. It has many different ways to screw with the root kernel, so I'm
not overly concerned about this.
That said, having a bit more consistency and defensive programming
doesn't hurt. I have applied this patch. Thanks.
Wei
> ---
> drivers/hv/mshv_synic.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/hv/mshv_synic.c b/drivers/hv/mshv_synic.c
> index 43f1bcbbf2d3..5bceb8122981 100644
> --- a/drivers/hv/mshv_synic.c
> +++ b/drivers/hv/mshv_synic.c
> @@ -384,6 +384,10 @@ mshv_intercept_isr(struct hv_message *msg)
> */
> vp_index =
> ((struct hv_opaque_intercept_message *)msg->u.payload)->vp_index;
> + if (unlikely(vp_index >= MSHV_MAX_VPS)) {
> + pr_debug("VP index %u out of bounds\n", vp_index);
> + goto unlock_out;
> + }
> vp = partition->pt_vp_array[vp_index];
> if (unlikely(!vp)) {
> pr_debug("failed to find VP %u\n", vp_index);
>
> ---
> base-commit: 7aaa8047eafd0bd628065b15757d9b48c5f9c07d
> change-id: 20260416-fixes-693196e52f93
>
> Best regards,
> --
> Junrui Luo <moonafterrain@outlook.com>
>
prev parent reply other threads:[~2026-06-08 6:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-16 14:18 [PATCH] Drivers: hv: mshv: add bounds check on vp_index in mshv_intercept_isr() Junrui Luo
2026-06-08 6:23 ` Wei Liu [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=20260608062310.GC1555293@liuwe-devbox-debian-v2.local \
--to=wei.liu@kernel.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=romank@linux.microsoft.com \
--cc=skinsburskii@linux.microsoft.com \
/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