kernel - Add per-user file descriptor limit
authorMatthew Dillon <dillon@apollo.backplane.com>
Tue, 10 Aug 2010 23:27:27 +0000 (16:27 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Tue, 10 Aug 2010 23:27:27 +0000 (16:27 -0700)
commitd37c8f7fecbdf4f76bd481048935533b58b88baa
tree5911d8e722e14ca02c94539c37a8c9aadbb2d7f0
parent99acf5583a06c73dd13be3ac29f06a1ad8bd73ae
kernel - Add per-user file descriptor limit

* Add kern.maxfilesperuser and kern.minfilesperproc to complement the
  kern.maxfilesperproc which already exists.  Print a warning on the
  console if a user hits the limit (rate limited).

* Track per-user files via the uidinfo structure.  Each file pointer counts
  as one file.  dup()'d and fork()'d file descriptors do not count.

* Adjust the default user limits to approximately 1/4 the system maximums
  instead of 9/10 the system maximums.  This reduces the maximum descriptors
  per process and the maximum processes per uid.  They can be raised again
  via sysctl.

* Set minfilesperproc to 8 by default.  This is a safety which guarantees
  that a process can always have at least that many open descriptors
  without tripping over kern.maxfilesperuser.

Reported-by: swildner
sys/kern/kern_descrip.c
sys/kern/kern_resource.c
sys/kern/subr_param.c
sys/sys/file.h
sys/sys/resourcevar.h