Index: squashfs-tools-4.7.5/squashfs-tools/mksquashfs.c
===================================================================
--- squashfs-tools-4.7.5.orig/squashfs-tools/mksquashfs.c
+++ squashfs-tools-4.7.5/squashfs-tools/mksquashfs.c
@@ -5440,6 +5440,16 @@ static void initialise_threads(int readq
 	if(pthread_sigmask(SIG_BLOCK, &sigmask, &old_mask) != 0)
 		BAD_ERROR("Failed to set signal mask in initialise_threads\n");
 
+	/* Every frag_thrd will:
+	 * * occupy a slot in the process table (_SC_CHILD_MAX), and will
+	 * * allocate SQUASHFS_FILE_MAX_SIZE (currently 1MiB), which is
+	 *   accounted towards the per-process datasize limit, and will
+	 * * open 1 file descriptor (_SC_OPEN_MAX).
+	 * Before we hit any of those limits on big irons, limit
+	 * ourselves to an impressive but sane arbitrary maximum.
+	 */
+	if (processors > 64) processors = 64;
+
 	if(multiply_overflow(processors, 3) ||
 			multiply_overflow(processors * 3, sizeof(pthread_t)))
 		BAD_ERROR("Processors too large\n");
