⬢ DragonFlyBSD Kernel Audit
DF-3114 / fix.diff
← back to finding ↓ download raw
--- a/sys/vfs/hammer/hammer_ioctl.c
+++ b/sys/vfs/hammer/hammer_ioctl.c
@@ -296,6 +296,12 @@
 	if (hist->head.flags & HAMMER_IOC_HISTORY_ATKEY) {
 		if (hist->key > hist->nxt_key)
 			return(EINVAL);
+		/*
+		 * Reject the boundary: the REGFILE scan below increments
+		 * key_beg.key and would overflow int64 at HAMMER_MAX_KEY.
+		 */
+		if (hist->key >= HAMMER_MAX_KEY)
+			return(EINVAL);
 	}
 
 	hist->obj_id = ip->obj_id;
@@ -383,6 +389,15 @@
 					      HAMMER_LOCALIZE_INODE;
 	}
 
+	/*
+	 * Honor any validation error from the ATKEY switch() above
+	 * (e.g. unsupported object type) instead of overwriting it.
+	 */
+	if (error) {
+		hammer_done_cursor(&cursor);
+		return(error);
+	}
+
 	error = hammer_btree_first(&cursor);
 	while (error == 0) {
 		elm = &cursor.node->ondisk->elms[cursor.index];