]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.15-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Aug 2026 12:19:18 +0000 (14:19 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Aug 2026 12:19:18 +0000 (14:19 +0200)
added patches:
drm-vmwgfx-bound-dma-command-body-size-against-suffix-pointer.patch
drm-vmwgfx-validate-draw_primitives-header-size-before-division.patch

queue-5.15/drm-vmwgfx-bound-dma-command-body-size-against-suffix-pointer.patch [new file with mode: 0644]
queue-5.15/drm-vmwgfx-validate-draw_primitives-header-size-before-division.patch [new file with mode: 0644]
queue-5.15/series

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 (file)
index 0000000..096a04f
--- /dev/null
@@ -0,0 +1,49 @@
+From f4f1db96bfd68b81053693ba53405b6f510ac16c Mon Sep 17 00:00:00 2001
+From: Zack Rusin <zack.rusin@broadcom.com>
+Date: Tue, 5 May 2026 18:22:28 -0400
+Subject: drm/vmwgfx: bound DMA command body size against suffix pointer
+
+From: Zack Rusin <zack.rusin@broadcom.com>
+
+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 <zack.rusin@broadcom.com>
+Reviewed-by: Ian Forbes <ian.forbes@broadcom.com>
+Link: https://patch.msgid.link/20260505222728.519626-8-zack.rusin@broadcom.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ 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 (file)
index 0000000..c91742a
--- /dev/null
@@ -0,0 +1,54 @@
+From 85891d174707d8bddcec7a888fb4e1d17def34f3 Mon Sep 17 00:00:00 2001
+From: Zack Rusin <zack.rusin@broadcom.com>
+Date: Tue, 5 May 2026 18:22:27 -0400
+Subject: drm/vmwgfx: validate DRAW_PRIMITIVES header size before division
+
+From: Zack Rusin <zack.rusin@broadcom.com>
+
+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 <zack.rusin@broadcom.com>
+Reviewed-by: Ian Forbes <ian.forbes@broadcom.com>
+Link: https://patch.msgid.link/20260505222728.519626-7-zack.rusin@broadcom.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ 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)) {
index b46a71752beaccfc16f507182d6671a56eb3e527..58bb74cf2c8dd7fe2827e60e12683aa5e1f66be5 100644 (file)
@@ -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