]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.10-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 May 2025 11:41:12 +0000 (13:41 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 May 2025 11:41:12 +0000 (13:41 +0200)
added patches:
drm-i915-gvt-fix-unterminated-string-initialization-warning.patch

queue-5.10/drm-i915-gvt-fix-unterminated-string-initialization-warning.patch [new file with mode: 0644]
queue-5.10/series

diff --git a/queue-5.10/drm-i915-gvt-fix-unterminated-string-initialization-warning.patch b/queue-5.10/drm-i915-gvt-fix-unterminated-string-initialization-warning.patch
new file mode 100644 (file)
index 0000000..7d92014
--- /dev/null
@@ -0,0 +1,63 @@
+From 8df71970af64794683e6c537fbd2c8d6613ab9cf Mon Sep 17 00:00:00 2001
+From: Jani Nikula <jani.nikula@intel.com>
+Date: Thu, 27 Mar 2025 14:47:39 +0200
+Subject: drm/i915/gvt: fix unterminated-string-initialization warning
+
+From: Jani Nikula <jani.nikula@intel.com>
+
+commit 2e43ae7dd71cd9bb0d1bce1d3306bf77523feb81 upstream.
+
+Initializing const char opregion_signature[16] = OPREGION_SIGNATURE
+(which is "IntelGraphicsMem") drops the NUL termination of the
+string. This is intentional, but the compiler doesn't know this.
+
+Switch to initializing header->signature directly from the string
+litaral, with sizeof destination rather than source. We don't treat the
+signature as a string other than for initialization; it's really just a
+blob of binary data.
+
+Add a static assert for good measure to cross-check the sizes.
+
+Reported-by: Kees Cook <kees@kernel.org>
+Closes: https://lore.kernel.org/r/20250310222355.work.417-kees@kernel.org
+Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/13934
+Tested-by: Nicolas Chauvet <kwizart@gmail.com>
+Tested-by: Damian Tometzki <damian@riscv-rocks.de>
+Cc: stable@vger.kernel.org
+Reviewed-by: Zhenyu Wang <zhenyuw.linux@gmail.com>
+Link: https://lore.kernel.org/r/20250327124739.2609656-1-jani.nikula@intel.com
+Signed-off-by: Jani Nikula <jani.nikula@intel.com>
+(cherry picked from commit 4f8207469094bd04aad952258ceb9ff4c77b6bfa)
+Signed-off-by: Jani Nikula <jani.nikula@intel.com>
+[nathan: Move static_assert() to top of function to avoid instance of
+         -Wdeclaration-after-statement due to lack of b5ec6fd286df]
+Signed-off-by: Nathan Chancellor <nathan@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/gpu/drm/i915/gvt/opregion.c |    8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+--- a/drivers/gpu/drm/i915/gvt/opregion.c
++++ b/drivers/gpu/drm/i915/gvt/opregion.c
+@@ -222,7 +222,8 @@ int intel_vgpu_init_opregion(struct inte
+       u8 *buf;
+       struct opregion_header *header;
+       struct vbt v;
+-      const char opregion_signature[16] = OPREGION_SIGNATURE;
++
++      static_assert(sizeof(header->signature) == sizeof(OPREGION_SIGNATURE) - 1);
+       gvt_dbg_core("init vgpu%d opregion\n", vgpu->id);
+       vgpu_opregion(vgpu)->va = (void *)__get_free_pages(GFP_KERNEL |
+@@ -236,8 +237,9 @@ int intel_vgpu_init_opregion(struct inte
+       /* emulated opregion with VBT mailbox only */
+       buf = (u8 *)vgpu_opregion(vgpu)->va;
+       header = (struct opregion_header *)buf;
+-      memcpy(header->signature, opregion_signature,
+-             sizeof(opregion_signature));
++
++      memcpy(header->signature, OPREGION_SIGNATURE, sizeof(header->signature));
++
+       header->size = 0x8;
+       header->opregion_ver = 0x02000000;
+       header->mboxes = MBOX_VBT;
index 66784b0d719345df3f66e87a4f472a082811633a..e9e8732f7d6d767bb357c72029378cc0a3dce505 100644 (file)
@@ -250,3 +250,4 @@ spi-spi-fsl-dspi-restrict-register-range-for-regmap-.patch
 spi-spi-fsl-dspi-halt-the-module-after-a-new-message.patch
 spi-spi-fsl-dspi-reset-sr-flags-before-sending-a-new.patch
 kbuild-disable-wdefault-const-init-unsafe.patch
+drm-i915-gvt-fix-unterminated-string-initialization-warning.patch