⬢ DragonFlyBSD Kernel Audit
DF-4889 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/raid/iir/iir_pci.c
+++ b/sys/dev/raid/iir/iir_pci.c
@@ -190,6 +190,18 @@ iir_pci_attach(device_t dev)
         error = ENOMEM;
         goto err;
     }
+    /*
+     * The MPR register layout (i960 regs 0x0000-0x0fff, interface and
+     * command area 0x1000-0x3fff) requires at least GDT_PCINEW_SZ bytes
+     * of DPMEM.  A short BAR would make every fixed-offset access below
+     * run past the mapped resource.
+     */
+    if (rman_get_size(io) < GDT_PCINEW_SZ) {
+        device_printf(dev, "DPMEM too small: %ju bytes\n",
+                      (uintmax_t)rman_get_size(io));
+        error = ENXIO;
+        goto err;
+    }
 
     /* get IRQ */
     rid = 0;