Add a resource limit for the total number of kqueues available to the
authorkib <kib@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Mon, 21 Oct 2013 16:46:12 +0000 (16:46 +0000)
committerkib <kib@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Mon, 21 Oct 2013 16:46:12 +0000 (16:46 +0000)
commited27cdee59fe922e786f0410996ed1570c03fcd9
tree04786befd82e74b0298aa6139cca4192ba215854
parentef7772dd9bb8e5cb77040aea14c1b81924652c4b
Add a resource limit for the total number of kqueues available to the
user.  Kqueue now saves the ucred of the allocating thread, to
correctly decrement the counter on close.

Under some specific and not real-world use scenario for kqueue, it is
possible for the kqueues to consume memory proportional to the square
of the number of the filedescriptors available to the process.  Limit
allows administrator to prevent the abuse.

This is kernel-mode side of the change, with the user-mode enabling
commit following.

Reported and tested by: pho
Discussed with: jmg
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks

git-svn-id: svn://svn.freebsd.org/base/head@256850 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
bin/sh/miscbltin.c
etc/login.conf
lib/libc/sys/getrlimit.2
lib/libutil/login_class.3
lib/libutil/login_class.c
usr.bin/limits/limits.c
usr.bin/procstat/procstat_rlimit.c