DragonFlyBSD Kernel Audit
DF-1750 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/dev/drm/amd/amdgpu/amdgpu_acpi.c b/sys/dev/drm/amd/amdgpu/amdgpu_acpi.c
--- a/sys/dev/drm/amd/amdgpu/amdgpu_acpi.c
+++ b/sys/dev/drm/amd/amdgpu/amdgpu_acpi.c
@@ -197,8 +197,8 @@
 	memset(&output, 0, sizeof(output));
 
 	size = *(u16 *) info->Buffer.Pointer;
-	if (size < 12) {
-		DRM_INFO("ATIF buffer is too small: %zu\n", size);
+	if (size < 12 || size > info->Buffer.Length) {
+		DRM_INFO("ATIF buffer bad size: %zu\n", size);
 		err = -EINVAL;
 		goto out;
 	}
@@ -274,7 +274,7 @@
 	}
 
 	size = *(u16 *) info->Buffer.Pointer;
-	if (size < 10) {
+	if (size < 10 || size > info->Buffer.Length) {
 		err = -EINVAL;
 		goto out;
 	}
@@ -334,7 +334,7 @@
 		return -EIO;
 
 	size = *(u16 *)info->Buffer.Pointer;
-	if (size < 0xd) {
+	if (size < 0xd || size > info->Buffer.Length) {
 		count = -EINVAL;
 		goto out;
 	}
@@ -531,8 +531,8 @@
 	memset(&output, 0, sizeof(output));
 
 	size = *(u16 *) info->Buffer.Pointer;
-	if (size < 8) {
-		DRM_INFO("ATCS buffer is too small: %zu\n", size);
+	if (size < 8 || size > info->Buffer.Length) {
+		DRM_INFO("ATCS buffer bad size: %zu\n", size);
 		err = -EINVAL;
 		goto out;
 	}