DragonFlyBSD Kernel Audit
DF-1721 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/dev/drm/amd/amdgpu/amdgpu_gem.c b/sys/dev/drm/amd/amdgpu/amdgpu_gem.c
--- a/sys/dev/drm/amd/amdgpu/amdgpu_gem.c
+++ b/sys/dev/drm/amd/amdgpu/amdgpu_gem.c
@@ -245,8 +245,11 @@
 		}
 		flags |= AMDGPU_GEM_CREATE_NO_CPU_ACCESS;
 		/* GDS allocations must be DW aligned */
-		if (args->in.domains & AMDGPU_GEM_DOMAIN_GDS)
+		if (args->in.domains & AMDGPU_GEM_DOMAIN_GDS) {
+			if (size > UINT64_MAX - 3)
+				return -EINVAL;
 			size = ALIGN(size, 4);
+		}
 	}
 
 	if (flags & AMDGPU_GEM_CREATE_VM_ALWAYS_VALID) {