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=1796382283; b=w1WI+7XyZto9bP4PVZiuQotMmvN2r7gCxtDeThxgz/2hp/pBVRsT96OzkzBe0LHXWaWp Jh1WdvNMYUjJ7yFs5ArMRbOk/m5s0d9caKtQzVVIwTFGnaEmq65oU5apuW746kAZE7JHU ZZe4P8sseqNOo4u+5RI0xoFI2JHnPImDInvaFTnIY4ZW4Jsfl0Tt2i1FAuvoU+jw2AEGB tkcmtn8pUlU/9Q4MaHjC7wfRecpActspbt7CoPgSztES6NqP0WsFJEZaNVazdKQAbF1yV S82fhzhWome0C0dC2iTsS7gYcY29Kgb6jeX2XvuT5/Uzf/Z2nZQPa25wgFSFaED3Cvw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382283; 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=SDedzo8ZnbKKIEp2eQtl9dGDfyQiapJZ/zdYUCqjrro=; b=erQZz+jNqHO8pszOkLPVn+xv5T1FhjKP1Nh7SIn1Yf7pHH7Fnkfu4QE2l+R3j7+AVI5C SZK9rOOkNIz9WhShR3WQzRsVTIOvRl/Zm0geVilPlgi9CTuSeH9xcWYs2U3+w1wHZhp/2 rv2IJo9+1LSYfCDHX5iZSfLRqwWskI2F3oP991iVU7hwJqWEzvlJAeARPbvFPHE9GxWdf NRa2UeGIGE1PjpjpYTARlzWo3dVYxZ33D2Ea5ynVMnxsJiKCRLJSmdDAu0nuuQTiBN9K2 lgLcva6jkfyaP1EoaIKhoaD3+1PyLxS6xLDdX/Umwqq1m1NqRMOS7ieVAz6punQ3H9g== 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=N9JdAAFy; 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 C0650606A322; Fri, 4 Dec 2026 11:04:43 +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=N9JdAAFy Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A93C1F000CE; Fri, 4 Dec 2026 11:04:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382283; bh=SDedzo8ZnbKKIEp2eQtl9dGDfyQiapJZ/zdYUCqjrro=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=N9JdAAFynJ/rC4GwCRHkUGDxM/pC0IO7+hXbWamMZHEwvWsa7ABL9zfMAwkN659dd qGQ95tNtO6NSXHhns/0AhYZOxhyfQCya9OL6m5JNWm+z0ftOAZ2UTvdgPTuyddeYcc 8rXnF9USNgcYZi3ZaJ311HWIsgDCdujUW8+v+zWk= 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 6.18 387/703] drm/vmwgfx: validate GB-only cursor command limits Date: Fri, 4 Dec 2026 19:04:46 +0900 Message-ID: <20261204100638.135051333@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@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 6.18-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);