All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/vmwgfx: avoid underflow when stripping short GuestInfo replies
@ 2026-10-29 21:57 Zack Rusin
  2026-10-29 21:57 ` [PATCH 2/2] drm/vmwgfx: bound MKSSTAT lengths before rounding to pages Zack Rusin
  2026-10-30  0:51 ` [PATCH 1/2] drm/vmwgfx: avoid underflow when stripping short GuestInfo replies Maaz Mombasawala <maaz.mombasawala@broadcom.com>
  0 siblings, 2 replies; 4+ messages in thread
From: Zack Rusin @ 2026-10-29 21:57 UTC (permalink / raw)
  To: dri-devel
  Cc: bcm-kernel-feedback-list, ian.forbes, maaz.mombasawala,
	Zack Rusin, stable

vmw_host_get_guestinfo subtracts the two-byte reply prefix using
max(reply_len - 2, (size_t)0). Since reply_len is unsigned, a one-byte
reply wraps to SIZE_MAX instead of being clamped to zero. The subsequent
copy can read past the host reply allocation.

Theoretically malformed host reply can reach this path when the driver
queries the GuestInfo parameter used to enable VKMS.

Check the reply length before subtracting the prefix so short replies
produce an empty payload and cannot cause an out-of-bounds read.

Sashiko reported this while reviewing the i386 hypercall changes.

Fixes: 89da76fde68d ("drm/vmwgfx: Add VMWare host messaging capability")
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>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_msg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
index fd77ab6568cb..49e04a50c6ed 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
@@ -431,7 +431,7 @@ int vmw_host_get_guestinfo(const char *guest_info_param,
 		/* Remove reply code, which are the first 2 characters of
 		 * the reply
 		 */
-		reply_len = max(reply_len - 2, (size_t) 0);
+		reply_len = reply_len > 2 ? reply_len - 2 : 0;
 		reply_len = min(reply_len, *length);
 
 		if (reply_len > 0)
-- 
2.53.0


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

end of thread, other threads:[~2026-10-30  0:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-29 21:57 [PATCH 1/2] drm/vmwgfx: avoid underflow when stripping short GuestInfo replies Zack Rusin
2026-10-29 21:57 ` [PATCH 2/2] drm/vmwgfx: bound MKSSTAT lengths before rounding to pages Zack Rusin
2026-10-30  0:57   ` Maaz Mombasawala <maaz.mombasawala@broadcom.com>
2026-10-30  0:51 ` [PATCH 1/2] drm/vmwgfx: avoid underflow when stripping short GuestInfo replies Maaz Mombasawala <maaz.mombasawala@broadcom.com>

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.