PERFORCE change 102357 for review

Chris Jones cdjones at FreeBSD.org
Tue Jul 25 09:17:58 UTC 2006


http://perforce.freebsd.org/chv.cgi?CH=102357

Change 102357 by cdjones at cdjones-impulse on 2006/07/25 09:16:55

	Check memory usage when loading ELF binary under jails.

Affected files ...

.. //depot/projects/soc2006/cdjones_jail/src/sys/kern/imgact_elf.c#5 edit

Differences ...

==== //depot/projects/soc2006/cdjones_jail/src/sys/kern/imgact_elf.c#5 (text+ko) ====

@@ -58,6 +58,7 @@
 #include <sys/sysctl.h>
 #include <sys/sysent.h>
 #include <sys/vnode.h>
+#include <sys/jail.h>
 
 #include <vm/vm.h>
 #include <vm/vm_kern.h>
@@ -761,7 +762,10 @@
 	PROC_LOCK(imgp->proc);
 	if (data_size > lim_cur(imgp->proc, RLIMIT_DATA) ||
 	    text_size > maxtsiz ||
-	    total_size > lim_cur(imgp->proc, RLIMIT_VMEM)) {
+	    total_size > lim_cur(imgp->proc, RLIMIT_VMEM) ||
+	    (jailed(imgp->proc->p_ucred) && 
+	     total_size > (prison_memory_limit(imgp->proc->p_ucred) 
+			   - prison_memory(imgp->proc->p_ucred)))) {
 		PROC_UNLOCK(imgp->proc);
 		return (ENOMEM);
 	}


More information about the p4-projects mailing list