DragonFlyBSD Kernel Audit
DF-1625 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/dev/drm/amd/amdgpu/amdgpu_vce.c b/sys/dev/drm/amd/amdgpu/amdgpu_vce.c
--- a/sys/dev/drm/amd/amdgpu/amdgpu_vce.c
+++ b/sys/dev/drm/amd/amdgpu/amdgpu_vce.c
@@ -820,9 +820,18 @@
 				goto out;
 			}
 
-			*size = amdgpu_get_ib_value(p, ib_idx, idx + 8) *
-				amdgpu_get_ib_value(p, ib_idx, idx + 10) *
-				8 * 3 / 2;
+			{
+				uint64_t tmp;
+				tmp = (uint64_t)amdgpu_get_ib_value(p, ib_idx, idx + 8) *
+				    amdgpu_get_ib_value(p, ib_idx, idx + 10) *
+				    8 * 3 / 2;
+				if (tmp > UINT_MAX) {
+					DRM_ERROR("VCE image size overflow!\n");
+					r = -EINVAL;
+					goto out;
+				}
+				*size = tmp;
+			}
 			break;
 
 		case 0x04000001: /* config extension */