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=1796382223; b=RT4kQBgy2sGK9x4Jg1b1v/s20PFQtSP8LI7DuxT7i5o4CqjM6ReLjeso8pPfyTLCt4N0 UWpPgg47fpv1/vEnZYQz3AvgtGY9MXpfPJma9dxx5RnmTbNyAxiUJ7eZLWcKnGmXcDuDb yD0Zk7iUL4rkywudK8EnHFKVEqjX5lb7TXpSpSleYhMB1r1U75ArctyCbhL1BqnBYfigN 8cGM4jXhNUp10rab9NOxyW24eK0iTwTLAXWNJl78mzBmsH7ken4kePgfDqhVPOmdvDQrw 2UjfjxSWedjffB1QO2bqfXUdrkA6la9/RNrug8qgPXCBFcsGsYscBJNwF23eWODR6uA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382223; 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=4v37rX77m2RC3SJpa+RBqwZdimluG/ZBjBvqe+0XCLM=; b=xgBMkpelY06gqyAITzeAnp59X/2OD1nkmQKVX9k2nOKYEnPifKtRn4midItJb4LuQ+zU jxaD88a4cumBGI1vf0wVfrA/1beIEcxyK8N5lmuFIwd99QOoLpbhMg2uG67Rr+zjGAx49 0Is3mSyre/BVGSywEODCGDB6eSid3vtAi2PcrGsirDvdjzqJ9PbaUzSrAkLUTOauBos/9 Bt9VMMZtZXIIldd63OXaDEBwUKsMo2FEeqaXF5z48KWrL5jsNlXYwKhCuq+/uV78ozMgB rZFM3zooaZrbA55fLCYl+vJPtj7hJWruSABmFyuRSy3DTMHQXQPpTNOlDXNtK/oK4OA== 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=1Ht3XGjn; 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 5202C606A322; Fri, 4 Dec 2026 11:03: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=1Ht3XGjn Received: by smtp.kernel.org (Postfix) with ESMTPSA id C40EB1F00897; Fri, 4 Dec 2026 11:03:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382223; bh=4v37rX77m2RC3SJpa+RBqwZdimluG/ZBjBvqe+0XCLM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=1Ht3XGjnOKN92dpGp6Qi3opLulfL39mNzliucKi4tSISyH7O896purU/SOuZNRhnW fGipp93guAz7w4rUBLEAQFoEZuahtiyzjSaUKF26aS3/GEIB1G+ZYLsqgkT5d5YhKh 52BzG/4AKpwhFWGjI/eDHcbgGqIlB4PfzS+ZxQ+I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Leo Liu , Ruijing Dong , David Rosca , Alex Deucher Subject: [PATCH 6.18 359/703] drm/amdgpu: Fix VCE buffer size check for DPB and input surface Date: Fri, 4 Dec 2026 19:04:18 +0900 Message-ID: <20261204100637.360487973@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: David Rosca commit 87a841d8c0b711519fb76e2412bb293743f602bd upstream. In create command we get pitch and height for DPB, input surface pitch and height is in encode command. Fix the calculation to also consider different luma and chroma pitch. Acked-by: Leo Liu Reviewed-by: Ruijing Dong Signed-off-by: David Rosca Signed-off-by: Alex Deucher (cherry picked from commit 24c0be8ac3ef2eaa20f614b540e41382b5e97afc) Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 35 +++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c @@ -748,6 +748,7 @@ int amdgpu_vce_ring_parse_cs(struct amdg uint32_t allocated = 0; uint32_t tmp, handle = 0; uint32_t dummy = 0xffffffff; + uint32_t luma_pitch, chroma_pitch, height; uint32_t *size = &dummy; unsigned int idx; int i, r = 0; @@ -853,19 +854,19 @@ int amdgpu_vce_ring_parse_cs(struct amdg goto out; } - uint32_t width, height; - width = amdgpu_ib_get_value(ib, idx + 8); - height = amdgpu_ib_get_value(ib, idx + 10); - - if (width == 0 || height == 0 || - width > 4096 || height > 2304) { - DRM_ERROR("invalid VCE image size: %ux%u\n", - width, height); + luma_pitch = amdgpu_ib_get_value(ib, idx + 8); + chroma_pitch = amdgpu_ib_get_value(ib, idx + 9); + height = amdgpu_ib_get_value(ib, idx + 10); /* encRefYHeightInQw */ + + if (luma_pitch == 0 || chroma_pitch == 0 || height == 0 || + luma_pitch > 4096 || chroma_pitch > 4096 || height > 2304 / 8) { + DRM_ERROR("invalid VCE ref image size: (%u %u)x%u\n", + luma_pitch, chroma_pitch, height * 8); r = -EINVAL; goto out; } - *size = width * height * 8 * 3 / 2; + *size = luma_pitch * height * 8 + chroma_pitch * height * 8 / 2; break; @@ -894,13 +895,25 @@ int amdgpu_vce_ring_parse_cs(struct amdg break; case 0x03000001: /* encode */ + height = amdgpu_ib_get_value(ib, idx + 13); + luma_pitch = amdgpu_ib_get_value(ib, idx + 14); + chroma_pitch = amdgpu_ib_get_value(ib, idx + 15); + + if (luma_pitch == 0 || chroma_pitch == 0 || height == 0 || + luma_pitch > 4096 || chroma_pitch > 4096 || height > 2304) { + DRM_ERROR("invalid VCE image size: (%u %u)x%u\n", + luma_pitch, chroma_pitch, height); + r = -EINVAL; + goto out; + } + r = amdgpu_vce_cs_reloc(p, ib, idx + 10, idx + 9, - *size, 0); + luma_pitch * height, 0); if (r) goto out; r = amdgpu_vce_cs_reloc(p, ib, idx + 12, idx + 11, - *size / 3, 0); + chroma_pitch * height / 2, 0); if (r) goto out; break;