From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43E5528F933; Wed, 23 Apr 2025 15:35:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745422538; cv=none; b=n0wX4wJ1XK/8etQs5I6xfMHRl4T8HwMaoncYvsSVfDYR694+WUrAs9OSS4E6oA2sy4lmqfUfLibxesInlHRqiT1XZuiGvZbtsygfOGBVA3BJCOSHUtZ4U/UqQlXW90mqdNrr20LaDrlEf6wqnwuYzv3PST4KuYBe5H3bDISI9nc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745422538; c=relaxed/simple; bh=oNpnBbM9V3bCOb15p7DdmMaWOVcSAwBWxkQUNSar+tU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qmd0QOk8c9b1wKc9GDp76eqdZVJdedVwfZIXE5ox8hD6UY+PqekSrVN8qNJAxz9JwJ66/W1EGRbCXbX0hlLxSvj2cnYDqkzO46CmQgn7gyDTBuNZDDEr6aA+vez5yc3QmZcS+0A72/aZQsDurgLBJ2MdWOAqfVfPxSLTLWNTkIM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=eeDNgFHE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="eeDNgFHE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA0F7C4CEE2; Wed, 23 Apr 2025 15:35:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745422538; bh=oNpnBbM9V3bCOb15p7DdmMaWOVcSAwBWxkQUNSar+tU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eeDNgFHEOUeST3nbH1s9fXjXcoQcdoBRHNPfnRwCtq3FsKJ6BVs4IAqFZcEWPLUe1 JkERQlFYji3O/KE6okAHndEvJS2tapiEOdLf/Xm1CfzPEUgJqQolZmGvF8IFXvZ1Qe ZDalI/AlIUE2GHM4rqJJlxYPdpUmKqVpICtU0x68= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kees Cook , Nicolas Chauvet , Damian Tometzki , Zhenyu Wang , Jani Nikula Subject: [PATCH 6.6 358/393] drm/i915/gvt: fix unterminated-string-initialization warning Date: Wed, 23 Apr 2025 16:44:14 +0200 Message-ID: <20250423142658.123030115@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250423142643.246005366@linuxfoundation.org> References: <20250423142643.246005366@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jani Nikula 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 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 Tested-by: Damian Tometzki Cc: stable@vger.kernel.org Reviewed-by: Zhenyu Wang Link: https://lore.kernel.org/r/20250327124739.2609656-1-jani.nikula@intel.com Signed-off-by: Jani Nikula (cherry picked from commit 4f8207469094bd04aad952258ceb9ff4c77b6bfa) Signed-off-by: Jani Nikula Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/i915/gvt/opregion.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/drivers/gpu/drm/i915/gvt/opregion.c +++ b/drivers/gpu/drm/i915/gvt/opregion.c @@ -222,7 +222,6 @@ int intel_vgpu_init_opregion(struct inte u8 *buf; struct opregion_header *header; struct vbt v; - const char opregion_signature[16] = OPREGION_SIGNATURE; gvt_dbg_core("init vgpu%d opregion\n", vgpu->id); vgpu_opregion(vgpu)->va = (void *)__get_free_pages(GFP_KERNEL | @@ -236,8 +235,10 @@ 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)); + + static_assert(sizeof(header->signature) == sizeof(OPREGION_SIGNATURE) - 1); + memcpy(header->signature, OPREGION_SIGNATURE, sizeof(header->signature)); + header->size = 0x8; header->opregion_ver = 0x02000000; header->mboxes = MBOX_VBT;