Skip to contentSkip to conversation

drm/amdgpu: Reject UVD message with invalid number of h265 refs

PATCH In review David Rosca 2 participants 2 messages Aug 11

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: Reject UVD message with invalid number of h265 refs

Same change as for h264, avoids overflow later when calculating min dpb size.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +3 -0
index e2d0f23d48aa..228a405a94c4 100644
@@ -749,6 +749,9 @@ static int amdgpu_uvd_cs_msg_decode(struct amdgpu_device *adev, uint32_t *msg,
 		image_size = ALIGN(image_size, 256);
 
 		num_dpb_buffer = (le32_to_cpu(msg[59]) & 0xff) + 2;
+		if (num_dpb_buffer > 17)
+			return -EINVAL;
+
 		min_dpb_size = image_size * num_dpb_buffer;
 		min_ctx_size = ((width + 255) / 16) * ((height + 255) / 16)
 					   * 16 * num_dpb_buffer + 52 * 1024;
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw

AMD General

Quoted 34 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of David Rosca
Sent: Tuesday, August 11, 2026 5:07 AM
To: [email protected]
Cc: Rosca, David <[email protected]>
Subject: [PATCH] drm/amdgpu: Reject UVD message with invalid number of h265 refs

Same change as for h264, avoids overflow later when calculating min dpb size.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +3 -0
index e2d0f23d48aa..228a405a94c4 100644
@@ -749,6 +749,9 @@ static int amdgpu_uvd_cs_msg_decode(struct
 amdgpu_device *adev, uint32_t *msg,
              image_size = ALIGN(image_size, 256);
 
              num_dpb_buffer = (le32_to_cpu(msg[59]) & 0xff) + 2;
+             if (num_dpb_buffer > 17)
+                     return -EINVAL;
+
              min_dpb_size = image_size * num_dpb_buffer;
              min_ctx_size = ((width + 255) / 16) * ((height + 255) / 16)

* 16 * num_dpb_buffer + 52 * 1024;
--
2.43.0