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=1796386505; b=hvc2PrFCTk1OIp3+iNm5zfMyli9dWbzrOhcmlrVGCq8YAM4LzLMosZ8Ns6YYTY0iek4C /ADtMH2ABz8zW9VER3kY9I23f7ZYZYzyNDOw4Fh00sua5SBWOjPifS3TfWgvpQgygJgjn b7Mh0LY04TCz07FZ8vEfJT0RthC8+J+SSqizFZ1W0kMSIZEvtGrlCDlVPgyw3/s7Exekq JEK7E4QouW9JLf8Bt1/1iaY4QQEsYkYJnbJGNgaMYPAmKKIu/KS9xohsI4Oxx5phyYkHQ /UYhI4yaY3RMPEZv5Xn+j1kNsaMXXM5gxf/srlgg2cANA4WZuIrA+M4lQztgCuDUPHw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386505; 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=l3gBxzC4E2V11vwi8rYDTjAEU3XusNJppYtDDQKVhVI=; b=gK5YX0ov6AJc2wXnQwl6OHplHAuHC43KF+MXJzzGQqJDKwHWbk2CrvRxZUXoV0tJ1B+Z BEfQIOHX4rMng6SeF0RT1mg76BHIv8oax7IksaOub/diSFldGORNh1vcwVJamIfvxufjk 04r3cJ3O6PmvicCJRLJk4pUfXKSOoZkJpB+4Fe4gDnICLr84B9o/ulPDMAKHtj8HewK9I EaGykzsMgxuwZH5bFWC1q7N1WBpo9dCIBjTPqHP4WNwYQRuBOwrE97ZZS4uihYyAHNMpR EBJUJns80vsPjoV48ULOfIjc5zEgylUmGs1KkdOgCCeDKOa+sEhXf+g3z/t8RPx0FIw== 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="BOPG/7KC"; 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 CB8AC606A334; Fri, 4 Dec 2026 12:15:05 +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=BOPG/7KC Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42F351F000C2; Fri, 4 Dec 2026 12:15:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796386505; bh=l3gBxzC4E2V11vwi8rYDTjAEU3XusNJppYtDDQKVhVI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BOPG/7KCcQ/QxFRA8YAqo8+Zs4adqYm8ZCogaaCRotddF0WZ53uOOJI2kH8TD7Tl2 FzoLaJQOow9XyJMGlmblD5Rdyzf+NZEYwh4uyy6TAwy6mBHfSV4GTS8RfBpfJ7IwrM b1PSt+GXfJfvD4CFbnvznxou2Ck5fkIZJZtMLLdk= 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.6 0992/1167] drm/amdgpu: Fix VCE buffer size check for DPB and input surface Date: Fri, 4 Dec 2026 19:06:59 +0900 Message-ID: <20261204100728.042016715@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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.6-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 @@ -746,6 +746,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; @@ -852,19 +853,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; @@ -893,13 +894,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;