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=1796389196; b=hTqbCVEtJCEqWYk20FELvFBtS8mER/SUxO4kG4A3FE20rz1CTUZQemyD6Gb3hLhurVok dHaMiiWe6lrCgp6CFEPFbjMfVf+b7J4B/9JQZ6mHE+/+3aQvFx/k59rnacO6g4NUnre3C 3a/oBmRZLaWJ3TT3wy6MYh+Xp+4JzwTJ07CpKZCTnVSAVDbaCVIezGcKTskA3mas+rS/K JTI18DNzo5dvZhMa3O7HlQ5EOBdSuhqX4PZ16nqkoRF41pPn00SaWLmUIM5tt2taMGatj gQBVD0L7Bv3u2J3TzvWGX1r5w7a0eHJCKlE3DmEW8AOUob70zzZCUpARlCI8dsC+eug== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796389196; 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=HI254Y7b+VQWGQQVotdLxusUk9/yBqNIyldp8DPTfes=; b=RPJYJ4RA2NxXjWyQN667X1zSmzZkmvUua9/iwN6UeIKJKItEv/y6NW1GYkh3OeDgGYF7 YsZuk8kV06JkhA7a8Av0fhwcY65w5WKiyTuRwXHNuRVr6aFHQvqqLGjbjkju9gMC9U2fw 4QHnAshr0GkOkFq2NpMeyS85Gb0TMNQDSpZyJO/2TwGeLrvdr+RJZIuzC6GdT3A+LfPbx tdKWHdFAV9PCUaZhjGpEgywwK/HatWp+6TifY+W1iG7jvV0dn5NWtqp3/ZQenFa1z6Vn9 ONlwvsYDkxsEXjOc0Q1RnaO+4H7DtRzZEFV3S7Sm3WCq+7tb9/b9FiZiJCmDw4ZYd/A== 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=ByWs8onR; 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 7D3BE606A322; Fri, 4 Dec 2026 12:59:56 +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=ByWs8onR Received: by smtp.kernel.org (Postfix) with ESMTPSA id E637F1F000C2; Fri, 4 Dec 2026 12:59:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796389196; bh=HI254Y7b+VQWGQQVotdLxusUk9/yBqNIyldp8DPTfes=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ByWs8onRG/r6JywVsfkdLoEjeLmn+LUHz5b8URvGFyV9kLJBu5fP2U9PYzTSrQXZf nJG9Kr/VWl4bpYa8G+g0fMV6ObO0E+4ZYQfLs23TDkl+Bh/vlXZIAdIdVC2vuSFsoO vNxGxnD9stVqzhY2BB3r4KV5KI4Un9jN69NKbcdY= 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.1 0901/1059] drm/amdgpu: Fix VCE buffer size check for DPB and input surface Date: Fri, 4 Dec 2026 19:07:12 +0900 Message-ID: <20261204100707.353537181@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@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.1-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 @@ -751,6 +751,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; @@ -857,19 +858,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; @@ -898,13 +899,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;