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=1796383805; b=lIaBMbGMpvHcu248Fboo6xtq6rxlqeyB0MBxggWv4h8JrZAI/MXiOjqOCFICuU8srLay I0zyXIf+kyZXf+Q3d2mN1s9+KgKLHJWUAb/0lINkPJ8O5cx7bWXiYSVkbHM8vHfeHq/Zb JWzLpnJwC9pTBo48xe9AWyOpXxl2Z6rs/eeU6aGetRkPK7PIigqRAbPfHfpePLZ4mujcq sfFNzGEqeQkNxI9HgwBUULwTLYMlM6lM1Dj5tqKDhCPZf4XlhYNboayBsP5Oho9kpUFQk ncr8ZAS54UrhSmKfOKcvqUQstcZIdCNAZK4F9sUbG5MdGz2wNeFtSpiv49EYS/evSMg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383805; 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=fXTo55oFQ1efrnhcMU9s6TLZh9FqhH8eCmFlVSjMezU=; b=MdiNYuu5nLSu5g1Gkhg+O8p2KMDbAj1AZmhFHPRZmof4HTBcrYSA91Qo5F2B8cqqI3H6 QF4PWhh9FPMELi8UB233JnRmdTN+UIRVOqpmNMLTPQgQS9L+eYOa/wU5KzF4VoK2ugzPD J9ZvdBbE+3aA5ATp/FBskq9AeGDYaE08Sapx4K47j58JxWTI/pX9pHxDc8Llh+Agqrn8Y HyHnl/VIVZZFO+o+TQIBTgDEQFz44sXS8mXHVFN1WxkxgbGFGkZArD2cErHofwVozHNnj VajbaaRphQQoUUzPCUICAoActhddyHdmakY0T4nB/RG9zyOnKaXxNZRK+D3dIwu5Dtg== 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=lYXUYylE; 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 1DDD6606A332; Fri, 4 Dec 2026 11:30:04 +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=lYXUYylE Received: by smtp.kernel.org (Postfix) with ESMTPSA id 417321F000C2; Fri, 4 Dec 2026 11:30:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383804; bh=fXTo55oFQ1efrnhcMU9s6TLZh9FqhH8eCmFlVSjMezU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lYXUYylEvapwmEOqjBXMjjPlxqzqGuS3CK98WPbfkzWJHVyIesyptwzT//ahVq8qZ rE5ZCVh2BadBdBz2UI8MEyXj/ag3B0K+2IQJagJH2uPrNSvdJr/LX6y/KU15E8cxtO 3iCXiwHrkNvBIjEYIuY93hvwj+vfDV18AYBW2axg= 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.12 332/555] drm/amdgpu: Fix VCE buffer size check for DPB and input surface Date: Fri, 4 Dec 2026 19:06:15 +0900 Message-ID: <20261204100622.543333968@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@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-Transfer-Encoding: 8bit 6.12-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;