[SRU][OEM-6.0/HWE-5.19][PATCH] drm/vmwgfx: Validate the box size for the snooped cursor

Yuxuan Luo yuxuan.luo at canonical.com
Fri Mar 17 20:26:11 UTC 2023


From: Zack Rusin <zackr at vmware.com>

Invalid userspace dma surface copies could potentially overflow
the memcpy from the surface to the snooped image leading to crashes.
To fix it the dimensions of the copybox have to be validated
against the expected size of the snooped cursor.

Signed-off-by: Zack Rusin <zackr at vmware.com>
Fixes: 2ac863719e51 ("vmwgfx: Snoop DMA transfers with non-covering sizes")
Cc: <stable at vger.kernel.org> # v3.2+
Reviewed-by: Michael Banack <banackm at vmware.com>
Reviewed-by: Martin Krastev <krastevm at vmware.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221026031936.1004280-1-zack@kde.org
(cherry picked from commit 4cf949c7fafe21e085a4ee386bb2dade9067316e)
CVE-2022-36280
Signed-off-by: Yuxuan Luo <yuxuan.luo at canonical.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index e5fcd6cacf47a..864f2df3ff5c2 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -186,7 +186,8 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf,
 	if (cmd->dma.guest.ptr.offset % PAGE_SIZE ||
 	    box->x != 0    || box->y != 0    || box->z != 0    ||
 	    box->srcx != 0 || box->srcy != 0 || box->srcz != 0 ||
-	    box->d != 1    || box_count != 1) {
+	    box->d != 1    || box_count != 1 ||
+	    box->w > 64 || box->h > 64) {
 		/* TODO handle none page aligned offsets */
 		/* TODO handle more dst & src != 0 */
 		/* TODO handle more then one copy */
-- 
2.34.1




More information about the kernel-team mailing list