DragonFlyBSD Kernel Audit
DF-2819 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/vfs/tmpfs/tmpfs_vfsops.c b/sys/vfs/tmpfs/tmpfs_vfsops.c
index 1111111..2222222 100644
--- a/sys/vfs/tmpfs/tmpfs_vfsops.c
+++ b/sys/vfs/tmpfs/tmpfs_vfsops.c
@@ -203,8 +203,9 @@
 	kmalloc_create(&tmp->tm_name_zone, "tmpfs name zone");
 
+	/* The kmalloc_obj allocator accounts cache-line-aligned object
+	 * sizes (ks_objsize = __VM_CACHELINE_ALIGN(sizeof)); derive the
+	 * zone limit from the same aligned size or the zone will refuse
+	 * allocations at ~85% of tm_nodes_max (DF-2819). */
 	kmalloc_obj_raise_limit(tmp->tm_node_zone,
-				sizeof(struct tmpfs_node) * tmp->tm_nodes_max);
+				__VM_CACHELINE_ALIGN(sizeof(struct tmpfs_node)) *
+				tmp->tm_nodes_max);
 
 	tmp->tm_ino = TMPFS_ROOTINO;