DF-4404 / fix.diff
--- a/sys/dev/drm/amd/amdgpu/amdgpu_uvd.c +++ b/sys/dev/drm/amd/amdgpu/amdgpu_uvd.c @@ -528,6 +528,17 @@ unsigned image_size, tmp, min_dpb_size, num_dpb_buffer; unsigned min_ctx_size = ~0; + /* Reject invalid dimensions: prevents both the divide-by-zero on + * fs_in_mb (DF-1595) and the u32 overflow of image_size / + * min_dpb_size / min_ctx_size for large width*height (DF-4404), + * which otherwise bypasses the DPB/ctx buffer size validation. + * Mirrors upstream Linux 05e1387d151f + 3e41d26c70b0. */ + if (width < 16 || height < 16 || width > 4096 || height > 4096) { + DRM_ERROR("Invalid UVD decoding dimensions (%d x %d)!\n", + width, height); + return -EINVAL; + } + image_size = width * height; image_size += image_size / 2; image_size = ALIGN(image_size, 1024); |