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=1796380781; b=upbY3YEsTZ83j1vxReTQOxyNmTy2Am4trynvFiF0HBq02qj8theeJxj/BhQk7UP2jkD7 4UEgBwtj7qcMsJwoEOxg2m24CnexE0Jmz4mEq2frcj2h/Y3rF6D/F6yZ8b8jZtM+rXRd5 LeNz6AB0Pnna2YDdDCibYpk8Uko0iBDCG+yV69y/WRo1Fa5KEAG7+FrmqAMBaJbPhfCIO ndVxn5kZTBVEICi/JyrlOo0jDhQXoMY3TzZ7pfs/8NP7pj35YHox1MtjCQzDlBLFNx8EU ujgTXRvV//imSKAcMEyTe1AL+ZoGg+HOC1xB4p9i3J9oZrZs47co89HZQ4qoDDjEn/A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380781; 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-Transfer-Encoding; bh=EvjZ2yElx6jb2XoJNvwOR7x+bUL41ITN+v9fzTUtFjM=; b=Y8AdYF3N7gQQB05CMRZRX2wIR4dZocoaEFlB3M15rdxUeEchEVmTwe9JeXJ0puSkLtMR E+W86BQgnMLoUwJ5Xsu+7I50tDGNMw0he1jdzW/BzCxKuvGZhFItPbz1ba6a9voyfeNRq 0p5VTfjohxL+3Dr4RVjIaSyS2278nMWs0Dlq0D5j6tM3yViNI4aT7cPgBCPBoev3JOvUj SvGMuP1gkNy7+UTAsAHqhpEtsWPpVrPLA55mqS+4qUQJwto9Fp9n82Dn7ImAGPDaiTtMg b6VMaqten11Al67cu3fU6gsZBsUdYhs9/w1y596dF+u0L2UwExXYuuQ0bZVwnE9bEKA== 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="fRBEA/a6"; 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 7E9F4606A32F; Fri, 4 Dec 2026 10:39:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=fRBEA/a6 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E99FC1F000C2; Fri, 4 Dec 2026 10:39:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380781; bh=EvjZ2yElx6jb2XoJNvwOR7x+bUL41ITN+v9fzTUtFjM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fRBEA/a6+2dc9VYQmMOHVH0rOmLtWZwIqd0qTAH9J2MNThkODzFNq1KL4acydVXQP B1lENie5YEH0MADMNYSfLR9OWU6VAGmEWQOiR4K+KO/s635X29C5vyiCBAnRLtrkaq OBJUktwizT2ES9K10orT4loVFxR6F3HraTvxIyBM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yunfeng Li , Zack Rusin , Maaz Mombasawala Subject: [PATCH 7.3 422/742] drm/vmwgfx: validate GB-only cursor command limits Date: Fri, 4 Dec 2026 19:04:46 +0900 Message-ID: <20261204100646.314297562@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zack Rusin commit 6baeb251d709d5f31f2a0ae89ca5ca054d0e04e7 upstream. Guest-backed devices without cursor MOB support define cursor images with SVGA_CMD_DEFINE_ALPHA_CURSOR. SVGA_REG_CURSOR_MAX_DIMENSION belongs to the cursor MOB register class and reads as zero on devices that do not expose that class. Applying this register to GB-only cursors rejects every nonempty image submitted by KMS clients, leaving Xorg without a hardware cursor. The submission transport also limits the command size. A 96x96 image fits the 40 KiB FIFO image limit, but exceeds the 32 KiB command-buffer limit and causes a device command error when submitted through that transport. Validate GB-only images against SVGA_MAX_CURSOR_CMD_DIMENSION and SVGA_MAX_CURSOR_CMD_BYTES. For command-buffer submission, also bound the whole command by SVGA_CB_MAX_COMMAND_SIZE, including its header. Calculate the image byte count in 64 bits and keep the register-based dimension and MOB size checks for MOB cursors. Fixes: d5ed8749168a ("drm/vmwgfx: enforce cursor size limits for MOB cursors") Cc: stable@vger.kernel.org Reported-by: Yunfeng Li Closes: https://patch.msgid.link/20260830151619.2452307-1-yunfeng.li.nb@gmail.com Assisted-by: LLM Signed-off-by: Zack Rusin Reviewed-by: Maaz Mombasawala Tested-by: fausten Link: https://patch.msgid.link/20261027211729.646988-3-zack.rusin@broadcom.com Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) --- a/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c @@ -785,8 +785,27 @@ int vmw_cursor_plane_atomic_check(struct "surface not suitable for cursor\n"); return -EINVAL; } - } else if (update_type == VMW_CURSOR_UPDATE_GB_ONLY || - update_type == VMW_CURSOR_UPDATE_MOB) { + } else if (update_type == VMW_CURSOR_UPDATE_GB_ONLY) { + u64 image_size = (u64)new_state->crtc_w * + new_state->crtc_h * sizeof(u32); + u32 max_size = SVGA_MAX_CURSOR_CMD_BYTES; + + /* The command-buffer limit includes the define-cursor header. */ + if (vmw->cman) + max_size = min_t(u32, max_size, + SVGA_CB_MAX_COMMAND_SIZE - + sizeof(struct vmw_svga_fifo_cmd_define_cursor)); + + if (!new_state->crtc_w || !new_state->crtc_h || + new_state->crtc_w > SVGA_MAX_CURSOR_CMD_DIMENSION || + new_state->crtc_h > SVGA_MAX_CURSOR_CMD_DIMENSION || + image_size > max_size) { + drm_dbg_kms(&vmw->drm, + "Cursor dimensions (%u, %u) violate command limits\n", + new_state->crtc_w, new_state->crtc_h); + return -EINVAL; + } + } else if (update_type == VMW_CURSOR_UPDATE_MOB) { u32 cursor_max_dim = vmw_read(vmw, SVGA_REG_CURSOR_MAX_DIMENSION);