summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpluknet <pluknet@FreeBSD.org>2011-02-24 09:22:56 +0000
committerpluknet <pluknet@FreeBSD.org>2011-02-24 09:22:56 +0000
commit3061aea0d28ba07288dbcf07855fb6560587e53d (patch)
tree0d4aa83738a0ccb309e6c0a886f926e5ed06854c
parent7e21857a467b489be83f79ca1e430863445d8863 (diff)
downloadFreeBSD-src-3061aea0d28ba07288dbcf07855fb6560587e53d.zip
FreeBSD-src-3061aea0d28ba07288dbcf07855fb6560587e53d.tar.gz
Remove sysctl vm.max_proc_mmap used to protect from KVA space exhaustion.
As it was pointed out by Alan Cox, that no longer serves its purpose with the modern UMA allocator compared to the old one used in 4.x days. The removal of sysctl eliminates max_proc_mmap type overflow leading to the broken mmap(2) seen with large amount of physical memory on arches with factually unbound KVA space (such as amd64). It was found that slightly less than 256GB of physmem was enough to trigger the overflow. Reviewed by: alc, kib Approved by: avg (mentor) MFC after: 2 months
-rw-r--r--lib/libc/sys/mmap.23
-rw-r--r--sys/vm/vm_mmap.c39
2 files changed, 0 insertions, 42 deletions
diff --git a/lib/libc/sys/mmap.2 b/lib/libc/sys/mmap.2
index 0b1f35f..5e0c226 100644
--- a/lib/libc/sys/mmap.2
+++ b/lib/libc/sys/mmap.2
@@ -346,9 +346,6 @@ was specified and the
argument was not available.
.Dv MAP_ANON
was specified and insufficient memory was available.
-The system has reached the per-process mmap limit specified in the
-.Va vm.max_proc_mmap
-sysctl.
.El
.Sh SEE ALSO
.Xr madvise 2 ,
diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c
index a73e03a..f2b317e 100644
--- a/sys/vm/vm_mmap.c
+++ b/sys/vm/vm_mmap.c
@@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
-#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/sysproto.h>
@@ -66,7 +65,6 @@ __FBSDID("$FreeBSD$");
#include <sys/stat.h>
#include <sys/sysent.h>
#include <sys/vmmeter.h>
-#include <sys/sysctl.h>
#include <security/mac/mac_framework.h>
@@ -80,7 +78,6 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_pageout.h>
#include <vm/vm_extern.h>
#include <vm/vm_page.h>
-#include <vm/vm_kern.h>
#ifdef HWPMC_HOOKS
#include <sys/pmckern.h>
@@ -92,30 +89,6 @@ struct sbrk_args {
};
#endif
-static int max_proc_mmap;
-SYSCTL_INT(_vm, OID_AUTO, max_proc_mmap, CTLFLAG_RW, &max_proc_mmap, 0,
- "Maximum number of memory-mapped files per process");
-
-/*
- * Set the maximum number of vm_map_entry structures per process. Roughly
- * speaking vm_map_entry structures are tiny, so allowing them to eat 1/100
- * of our KVM malloc space still results in generous limits. We want a
- * default that is good enough to prevent the kernel running out of resources
- * if attacked from compromised user account but generous enough such that
- * multi-threaded processes are not unduly inconvenienced.
- */
-static void vmmapentry_rsrc_init(void *);
-SYSINIT(vmmersrc, SI_SUB_KVM_RSRC, SI_ORDER_FIRST, vmmapentry_rsrc_init,
- NULL);
-
-static void
-vmmapentry_rsrc_init(dummy)
- void *dummy;
-{
- max_proc_mmap = vm_kmem_size / sizeof(struct vm_map_entry);
- max_proc_mmap /= 100;
-}
-
static int vm_mmap_vnode(struct thread *, vm_size_t, vm_prot_t, vm_prot_t *,
int *, struct vnode *, vm_ooffset_t *, vm_object_t *);
static int vm_mmap_cdev(struct thread *, vm_size_t, vm_prot_t, vm_prot_t *,
@@ -377,18 +350,6 @@ mmap(td, uap)
handle_type = OBJT_VNODE;
}
map:
-
- /*
- * Do not allow more then a certain number of vm_map_entry structures
- * per process. Scale with the number of rforks sharing the map
- * to make the limit reasonable for threads.
- */
- if (max_proc_mmap &&
- vms->vm_map.nentries >= max_proc_mmap * vms->vm_refcnt) {
- error = ENOMEM;
- goto done;
- }
-
td->td_fpop = fp;
error = vm_mmap(&vms->vm_map, &addr, size, prot, maxprot,
flags, handle_type, handle, pos);
OpenPOWER on IntegriCloud