From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793211604; b=IdBCuvqku52eijYIQARfn2lKI+bAf3a4DtikV3IWDa9YPBSfUmmvDlEHA3wGoVHHSdx1 4hO7UJFvqWdmBQgv2MQOlzKnHIOtIqX6dG6L6ucBfO51XQ5vG1sHZ6NO375qz9bDdsEIP NUSsTNNrxJu8cESOc+O1ubez6/KrP7y5q3TjzrD9+m4/I61be6wXaunBqvU46kfUeUVpu Rl96yU2Cs6Pw67EBthd2Aj27mTnoVD1QoLQIG9/uJjbA4UHMWQjB4ZLE0uKyDqBP48L+k yRQxX+J1NGeJQmeqiGC807uLu15iQP40Xw9vpBxORNlifFhWbsg+hc/l3pmBHoXS1Gw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793211604; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=XjzheMiKH5xkLbBfj5PUNdsFyqcIaoiGJ3MjUIyo+rI=; b=GWlmLr9y7mXgFgyFKx10i5/7mJVcv5M3lqU4yFRMKj6vRZklZT5bfaSTiuEAj40j7/de DejBpzDjPNRCC/7CjLTlAuX8Nq9WlxLUHHnPZ6Zvwf+MB3AT0yViainkwfDJtQNyOYLQS Fkotizkf7puOibG8tvB/GYhKVYfFjnQQeQH/GOq6wp6xAiBk99Ml85MN5GLF9qdIE4J5P pdyDSLJHLNKqh3pIppXeyZhv2wVvM3aDZuOIDVLsNbsO7g8qEb9TWTQCF/3RdxLlpAby8 ZiI3pLYh+/FWWtS4fimb1COKCdSDMOh1LLZz6XBw8u1SLl+eBOjQgQHhyPbRy8l+t2A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=nMqRDla6; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47602606A323; Wed, 28 Oct 2026 18:20:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=nMqRDla6 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99D381F01828; Wed, 28 Oct 2026 18:20:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1793211604; bh=XjzheMiKH5xkLbBfj5PUNdsFyqcIaoiGJ3MjUIyo+rI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nMqRDla6RS1VM19JwIiYq1GSi0b3rZT3EECm0xwKctPUXWNDRqdPxGnydvJN44q9F nDLczTMZiMK6PUf4khNKYJNyC0VlOmc1vhi/KICOpLhj/LhrEaZ6GALI4jWAsCKr6y moS9y1GZgfTbBCrIg29EBJ6WMf64G3xn5RSMLUNQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Youness HFA , Zack Rusin , Maaz Mombasawala , Sasha Levin Subject: [PATCH 5.15 436/571] drm/vmwgfx: validate pitch coming from userspace Date: Wed, 28 Oct 2026 17:59:43 +0100 Message-ID: <20261028170018.365518682@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261028170008.009143722@linuxfoundation.org> References: <20261028170008.009143722@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zack Rusin [ Upstream commit 21bc51cb89ced74d6645a138cc2f21184bc75094 ] Validate the pitch, alongside the box dimensions before trying to copy data from the underlying surface. Fixes possible out of bounds reads with cursor snooping. Fixes: 2ac863719e51 ("vmwgfx: Snoop DMA transfers with non-covering sizes") Cc: stable@vger.kernel.org Reported-by: Youness HFA Signed-off-by: Zack Rusin Reviewed-by: Maaz Mombasawala Link: https://patch.msgid.link/20260809204515.211045-1-zack.rusin@broadcom.com [ sashal: Adapted descriptor-based cursor sizing to hard-coded 64×64 dimensions and 4-byte pixels. ] Signed-off-by: Sasha Levin --- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c index 8a9b61920496a..590267c8a2fd9 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c @@ -155,6 +155,7 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf, unsigned long kmap_num; SVGA3dCopyBox *box; unsigned box_count; + u64 src_extent; void *virtual; bool dummy; struct vmw_dma_cmd { @@ -163,6 +164,8 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf, } *cmd; int i, ret; + BUILD_BUG_ON(sizeof(*srf->snooper.image) != 4); + cmd = container_of(header, struct vmw_dma_cmd, header); /* No snooper installed */ @@ -200,8 +203,19 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf, return; } + if (box->w == 0 || box->h == 0) + return; + + src_extent = (u64)(box->h - 1) * cmd->dma.guest.pitch + + (u64)box->w * 4; + if (src_extent > bo->base.size) { + DRM_ERROR("Cursor snoop source of %llu bytes exceeds the %zu byte buffer\n", + src_extent, bo->base.size); + return; + } + kmap_offset = cmd->dma.guest.ptr.offset >> PAGE_SHIFT; - kmap_num = (64*64*4) >> PAGE_SHIFT; + kmap_num = PFN_UP(src_extent); ret = ttm_bo_reserve(bo, true, false, NULL); if (unlikely(ret != 0)) { @@ -215,13 +229,13 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf, virtual = ttm_kmap_obj_virtual(&map, &dummy); - if (box->w == 64 && cmd->dma.guest.pitch == 64*4) { + if (box->w == 64 && box->h == 64 && cmd->dma.guest.pitch == 64*4) { memcpy(srf->snooper.image, virtual, 64*64*4); } else { - /* Image is unsigned pointer. */ + /* The destination stride is in pixels. */ for (i = 0; i < box->h; i++) memcpy(srf->snooper.image + i * 64, - virtual + i * cmd->dma.guest.pitch, + virtual + (size_t)i * cmd->dma.guest.pitch, box->w * 4); } -- 2.53.0