Linux kernel -stable discussions
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] drm/vmwgfx: bound MKSSTAT lengths before rounding to pages" failed to apply to 6.1-stable tree
@ 2026-12-02 12:50 gregkh
  2026-12-04  2:12 ` [PATCH 6.1.y 1/2] drm/vmwgfx: Fix frame-size warning in vmw_mksstat_add_ioctl Sasha Levin
  0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2026-12-02 12:50 UTC (permalink / raw)
  To: zack.rusin, maaz.mombasawala; +Cc: stable


The patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 9725b0454e65f15ae76788f2004a7ba8b493362a
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026120236-drool-cupbearer-6389@gregkh' --subject-prefix 'PATCH 6.1.y' 'HEAD^..'

Possible dependencies:



thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 9725b0454e65f15ae76788f2004a7ba8b493362a Mon Sep 17 00:00:00 2001
From: Zack Rusin <zack.rusin@broadcom.com>
Date: Thu, 29 Oct 2026 10:45:07 -0400
Subject: [PATCH] drm/vmwgfx: bound MKSSTAT lengths before rounding to pages

vmw_mksstat_add_ioctl rounds the user-supplied 64bit lengths to page
counts before comparing them with the descriptors page arrays. PFN_UP
can wrap for lengths near U64_MAX. On 32bit kernels, storing a large page
count in size_t can also truncate it to a value that passes the checks.

A render-node client can therefore register a descriptor with lengths
that exceed its pinned page arrays, including nonzero lengths with no
backing pages.

Compare each byte length with its page array's capacity before rounding
or narrowing it. Compute those capacities in 64 bits and calculate the
page counts only after all three lengths have passed validation.

Sashiko reported this while reviewing the i386 hypercall changes.

Fixes: 7a7a933edd6c ("drm/vmwgfx: Introduce VMware mks-guest-stats")
Cc: stable@vger.kernel.org
Closes: https://sashiko.dev/#/patchset/4ab10678a8f50053934b62b56af81f881c1d3798.1788414669.git.zack.rusin%40broadcom.com
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Reviewed-by: Maaz Mombasawala <maaz.mombasawala@broadcom.com>
Link: https://patch.msgid.link/20261029215738.3010276-2-zack.rusin@broadcom.com

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
index 49e04a50c6ed..58da332486bd 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
@@ -939,9 +939,12 @@ int vmw_mksstat_add_ioctl(struct drm_device *dev, void *data,
 
 	struct vmw_private *const dev_priv = vmw_priv(dev);
 
-	const size_t num_pages_stat = PFN_UP(arg->stat_len);
-	const size_t num_pages_info = PFN_UP(arg->info_len);
-	const size_t num_pages_strs = PFN_UP(arg->strs_len);
+	const u64 max_stat_len = (u64)MKS_GUEST_STAT_INSTANCE_MAX_STAT_PPNS * PAGE_SIZE;
+	const u64 max_info_len = (u64)MKS_GUEST_STAT_INSTANCE_MAX_INFO_PPNS * PAGE_SIZE;
+	const u64 max_strs_len = (u64)MKS_GUEST_STAT_INSTANCE_MAX_STRS_PPNS * PAGE_SIZE;
+	size_t num_pages_stat;
+	size_t num_pages_info;
+	size_t num_pages_strs;
 	long desc_len;
 	long nr_pinned_stat;
 	long nr_pinned_info;
@@ -965,11 +968,15 @@ int vmw_mksstat_add_ioctl(struct drm_device *dev, void *data,
 	if (!arg->description)
 		return -EINVAL;
 
-	if (num_pages_stat > ARRAY_SIZE(pdesc->statPPNs) ||
-		num_pages_info > ARRAY_SIZE(pdesc->infoPPNs) ||
-		num_pages_strs > ARRAY_SIZE(pdesc->strsPPNs))
+	if (arg->stat_len > max_stat_len ||
+	    arg->info_len > max_info_len ||
+	    arg->strs_len > max_strs_len)
 		return -EINVAL;
 
+	num_pages_stat = PFN_UP(arg->stat_len);
+	num_pages_info = PFN_UP(arg->info_len);
+	num_pages_strs = PFN_UP(arg->strs_len);
+
 	/* Find an available slot in the mksGuestStats user array and reserve it */
 	for (slot = 0; slot < ARRAY_SIZE(dev_priv->mksstat_user_pids); ++slot)
 		if (!atomic_cmpxchg(&dev_priv->mksstat_user_pids[slot], 0, MKSSTAT_PID_RESERVED))


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-04  2:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 12:50 FAILED: patch "[PATCH] drm/vmwgfx: bound MKSSTAT lengths before rounding to pages" failed to apply to 6.1-stable tree gregkh
2026-12-04  2:12 ` [PATCH 6.1.y 1/2] drm/vmwgfx: Fix frame-size warning in vmw_mksstat_add_ioctl Sasha Levin
2026-12-04  2:12   ` [PATCH 6.1.y 2/2] drm/vmwgfx: bound MKSSTAT lengths before rounding to pages Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox