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=1796380701; b=c9iAHFQcnzqieqqjXjBwfKD5kXmVHtAMLZ03mWmcf7m7ixTUNnkeG7iGIlZsZLmYU6wD /ZmNQoYmjiRWA392teKSIoYpaHeWgw1ZBjhZ2nsBzOfu3hNDnCAcCLHiO+ZKaozBo8mgN OVwFWli3vEkr4eUAes3DJpkyQ38qT58VbssmvjCNhKWzDSR91voLaOb9BbrO6+mimqmTN HZSXXG6GCAoSFuYZhpaALqMbMMEcXZqQakuVOOYNv5FsboYJA09r0qGFfJPeYpfdX2HXS fbzfua16gzsblcyJy7EZch5h62+dR1C0DYG6M8dOGbCdDKn+rk7J3itF1vuf10ndWtA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380701; 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=ksHitVakkWcFlhywTHacg7M0cySD7h6msDVxqsIPnvM=; b=Xp59xUY6ASnQIzAo71+oOjISyMI1oRGHyyC9BYt+MqN8bjF3ao8k9gnvNagrxuIF7X/2 BNWpK8v7SSS/+Vpq7+XZ60zKqeDlCAS1xF7Suo62eRV8d04umfumP6fdtiPM+UmweKJYG 2qsnIest37Hqdyj23qssbpsQ1xM4EoLosGOwmv2gtt2Pjgb65px+76FwrbGTuWRHGoDIL QEAbJJnBtEfHp9XX9aS1vBcdNDCaXXoFxBBn90Y/iIrNg7q8eOOA377kBKfoE9nipLxtK Occy+2327wlwoi9eUd53lYQeI8+6MTOwXgqUGccq5Nmt2QFQlqAA/ae27hR8Pd8Js0Q== 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=BMtZptwr; 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 5B6BA606A322; Fri, 4 Dec 2026 10:38:21 +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=BMtZptwr Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5A611F000CE; Fri, 4 Dec 2026 10:38:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380701; bh=ksHitVakkWcFlhywTHacg7M0cySD7h6msDVxqsIPnvM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BMtZptwryxhiiQshbo+5y96o1n1lgF+MiRipdv3423YgwAj+hvIft33SgdjHYS1si hGBLlGBLfKdrdXbeERv0PPkAQcgogx7SKL04oEOJe5azZo7FS9ULmEj3yUBxmgzxOx rt+RfPw7zQmzQgbf9mUEQG6VkhwHN3w7oxpUvlyo= 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 7.3 386/742] drm/amdgpu: Fix VCE buffer size check for DPB and input surface Date: Fri, 4 Dec 2026 19:04:10 +0900 Message-ID: <20261204100645.338661564@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: 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 7.3-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 @@ -775,6 +775,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; @@ -880,19 +881,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; @@ -921,13 +922,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;