From: Greg Kroah-Hartman Date: Wed, 5 Aug 2026 12:19:18 +0000 (+0200) Subject: 5.15-stable patches X-Git-Url: http://git.ipfire.org/index.cgi?a=commitdiff_plain;h=bd7fab747fecf5d14ed1001c8daa5a5018518385;p=thirdparty%2Fkernel%2Fstable-queue.git 5.15-stable patches added patches: drm-vmwgfx-bound-dma-command-body-size-against-suffix-pointer.patch drm-vmwgfx-validate-draw_primitives-header-size-before-division.patch --- diff --git a/queue-5.15/drm-vmwgfx-bound-dma-command-body-size-against-suffix-pointer.patch b/queue-5.15/drm-vmwgfx-bound-dma-command-body-size-against-suffix-pointer.patch new file mode 100644 index 0000000000..096a04f12c --- /dev/null +++ b/queue-5.15/drm-vmwgfx-bound-dma-command-body-size-against-suffix-pointer.patch @@ -0,0 +1,49 @@ +From f4f1db96bfd68b81053693ba53405b6f510ac16c Mon Sep 17 00:00:00 2001 +From: Zack Rusin +Date: Tue, 5 May 2026 18:22:28 -0400 +Subject: drm/vmwgfx: bound DMA command body size against suffix pointer + +From: Zack Rusin + +commit f4f1db96bfd68b81053693ba53405b6f510ac16c upstream. + +vmw_cmd_dma() locates the DMA suffix at + + (unsigned long) &cmd->body + header->size - sizeof(*suffix) + +without checking that header->size is large enough to contain both +cmd->body and the suffix. An undersized header makes the suffix +pointer underflow back into the previous command in the bounce +buffer. The verifier later writes suffix->maximumOffset, clobbering +verified fields of an already-relocated earlier command -- a TOCTOU +on the device-visible command stream that lets one command rewrite +another's GMR id, surface id, or other authenticated fields. + +Reject the command if the body is too small for the suffix to fit. + +Fixes: 4e4ddd477743 ("drm/vmwgfx: Fix queries if no dma buffer thrashing is occuring.") +Cc: stable@vger.kernel.org +Assisted-by: Claude:claude-opus-4.7 +Signed-off-by: Zack Rusin +Reviewed-by: Ian Forbes +Link: https://patch.msgid.link/20260505222728.519626-8-zack.rusin@broadcom.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c ++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +@@ -1534,6 +1534,12 @@ static int vmw_cmd_dma(struct vmw_privat + bool dirty; + + cmd = container_of(header, typeof(*cmd), header); ++ ++ if (unlikely(header->size < sizeof(cmd->body) + sizeof(*suffix))) { ++ VMW_DEBUG_USER("Illegal SVGA_3D_CMD_SURFACE_DMA size.\n"); ++ return -EINVAL; ++ } ++ + suffix = (SVGA3dCmdSurfaceDMASuffix *)((unsigned long) &cmd->body + + header->size - sizeof(*suffix)); + diff --git a/queue-5.15/drm-vmwgfx-validate-draw_primitives-header-size-before-division.patch b/queue-5.15/drm-vmwgfx-validate-draw_primitives-header-size-before-division.patch new file mode 100644 index 0000000000..c91742a7e8 --- /dev/null +++ b/queue-5.15/drm-vmwgfx-validate-draw_primitives-header-size-before-division.patch @@ -0,0 +1,54 @@ +From 85891d174707d8bddcec7a888fb4e1d17def34f3 Mon Sep 17 00:00:00 2001 +From: Zack Rusin +Date: Tue, 5 May 2026 18:22:27 -0400 +Subject: drm/vmwgfx: validate DRAW_PRIMITIVES header size before division + +From: Zack Rusin + +commit 85891d174707d8bddcec7a888fb4e1d17def34f3 upstream. + +vmw_cmd_draw() computes + + maxnum = (header->size - sizeof(cmd->body)) / sizeof(*decl); + +where header->size is u32 and is taken straight from the user-supplied +command stream. When header->size is less than sizeof(cmd->body) the +unsigned subtraction wraps to nearly 4 GiB, producing a huge maxnum. +Any user-controlled cmd->body.numVertexDecls then passes the bound and +the loop dereferences decl[i] far past the end of the kernel command +bounce buffer, producing an out-of-bounds read of kernel memory. + +Reject undersized headers up front. + +Fixes: 7a73ba7469cb ("drm/vmwgfx: Use TTM handles instead of SIDs as user-space surface handles.") +Cc: stable@vger.kernel.org +Assisted-by: Claude:claude-opus-4.7 +Signed-off-by: Zack Rusin +Reviewed-by: Ian Forbes +Link: https://patch.msgid.link/20260505222728.519626-7-zack.rusin@broadcom.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c ++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +@@ -1595,11 +1595,17 @@ static int vmw_cmd_draw(struct vmw_priva + uint32_t maxnum; + int ret; + ++ cmd = container_of(header, typeof(*cmd), header); ++ ++ if (unlikely(header->size < sizeof(cmd->body))) { ++ VMW_DEBUG_USER("Illegal DRAW_PRIMITIVES header size.\n"); ++ return -EINVAL; ++ } ++ + ret = vmw_cmd_cid_check(dev_priv, sw_context, header); + if (unlikely(ret != 0)) + return ret; + +- cmd = container_of(header, typeof(*cmd), header); + maxnum = (header->size - sizeof(cmd->body)) / sizeof(*decl); + + if (unlikely(cmd->body.numVertexDecls > maxnum)) { diff --git a/queue-5.15/series b/queue-5.15/series index b46a71752b..58bb74cf2c 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -356,3 +356,5 @@ can-peak_usb-validate-ucan-receive-record-lengths.patch drm-vc4-zero-the-tile-state-data-array-before-each-bin-job.patch drm-amdgpu-restore-umd-profile-pstate-after-runtime-resume.patch drm-amdgpu-cap-gtt-size-to-physical-ram-on-apus.patch +drm-vmwgfx-validate-draw_primitives-header-size-before-division.patch +drm-vmwgfx-bound-dma-command-body-size-against-suffix-pointer.patch