DragonFlyBSD Kernel Audit
DF-1328 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/dev/raid/mpr/mpr_user.c b/sys/dev/raid/mpr/mpr_user.c
--- a/sys/dev/raid/mpr/mpr_user.c
+++ b/sys/dev/raid/mpr/mpr_user.c
@@ -2075,8 +2075,11 @@
 	size = data->Size;
 	if ((size >= sizeof(sc->recorded_events)) && (status == 0)) {
 		mpr_unlock(sc);
+		/* DF-1328: copyout exactly the recorded_events array, never
+		 * the user-supplied `size`, which had no upper bound and read
+		 * past the array into the rest of the softc / adjacent heap. */
 		if (copyout((void *)sc->recorded_events,
-		    PTRIN(data->PtrEvents), size) != 0)
+		    PTRIN(data->PtrEvents), sizeof(sc->recorded_events)) != 0)
 			status = EFAULT;
 		mpr_lock(sc);
 	} else {