DragonFlyBSD Kernel Audit
DF-0910 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/vfs/hammer/hammer_prune.c b/sys/vfs/hammer/hammer_prune.c
--- a/sys/vfs/hammer/hammer_prune.c
+++ b/sys/vfs/hammer/hammer_prune.c
@@ -103,6 +103,22 @@
 	copy_elms = kmalloc(elm_array_size, M_TEMP, M_WAITOK);
 	if ((error = copyin(user_elms, copy_elms, elm_array_size)) != 0)
 		goto failed;
+	/*
+	 * mod_tid is the divisor used by prune_should_delete() at the
+	 * comparison (create_tid-beg_tid)/mod_tid == (delete_tid-beg_tid)/mod_tid
+	 * (hammer_prune.c:305-306).  A zero mod_tid drives an integer
+	 * divide-by-zero (#DE) kernel panic, so reject it here.
+	 */
+	{
+		int i;
+
+		for (i = 0; i < prune->nelms; ++i) {
+			if (copy_elms[i].mod_tid == 0) {
+				error = EINVAL;
+				goto failed;
+			}
+		}
+	}
 	prune->elms = copy_elms;
 
 	seq = trans->hmp->flusher.done;