From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 D6728472F89; Fri, 7 Aug 2026 15:25:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786116355; cv=none; b=BH1xXfGg1RXZQHBVD8srr5zfjsmqab7xwtY3orW65zZ/80WM03CAc8oUBeiQ2aj6Gi0/Q1p7z0El/APx6x61IXd+d6bBS6Q94fUHXg8YpGmakQ+fAIZGyYvlwv+X3FUiscYDiAHiMCIR3BLrEyO9FbTF02Gvdx91HAyIEyoDteM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786116355; c=relaxed/simple; bh=xq6bFk8UowVUbLxrnsCaMg8/Bm8euSezoyztybIt9lA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=keAEiS1t/Z1MsBuvA74k/WCtTV/dpf5er/jnRgttfnUkSGB6eU5o5qIWd7gxljz1aSjpgTZbrw0MoSH2xod/mOhxY1jtjIZvmrPK53AarNSZ2vd4zJZJaEyxJcIwhT6R/DmY2CZgukcEpEd1emg08CV+NuEQfSJxWHve1VPcj50= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=SDKpA8AD; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="SDKpA8AD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3EEA11F000E9; Fri, 7 Aug 2026 15:25:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786116353; bh=DsJ1Qs4jiGNDvlYc3p/qfhKIOfcfzQO0jjSY0pEOUBo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SDKpA8ADsBEVwppbgozeajj9lIMbCTZ/SyNE3AeSpQMvetivNj2ul93Vdzg/JiYiR nFGsmFtGIdety7DjAB6RBWkoaZU/36plDZw8GKIo+Dx1Us4GUukPcGcGK67pCQLF1i OCZQCwYgN7wpBrUPwyVj/QLcIKXDThqIB1+/GN+c= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zack Rusin , Ian Forbes Subject: [PATCH 6.6 200/261] drm/vmwgfx: validate DRAW_PRIMITIVES header size before division Date: Fri, 7 Aug 2026 16:39:17 +0200 Message-ID: <20260807143419.681719625@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260807143415.358597922@linuxfoundation.org> References: <20260807143415.358597922@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev 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: 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 @@ -1588,11 +1588,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)) {