summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2013-10-21 16:46:12 +0000
committerkib <kib@FreeBSD.org>2013-10-21 16:46:12 +0000
commit734382a525a0efc40130c452c5a765dc2249ad55 (patch)
tree04786befd82e74b0298aa6139cca4192ba215854 /lib
parent80e669df9e8ddb312b35886be11c306ee738b4f1 (diff)
downloadFreeBSD-src-734382a525a0efc40130c452c5a765dc2249ad55.zip
FreeBSD-src-734382a525a0efc40130c452c5a765dc2249ad55.tar.gz
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
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/sys/getrlimit.22
-rw-r--r--lib/libutil/login_class.31
-rw-r--r--lib/libutil/login_class.c1
3 files changed, 4 insertions, 0 deletions
diff --git a/lib/libc/sys/getrlimit.2 b/lib/libc/sys/getrlimit.2
index 35198bc..1f84bfb 100644
--- a/lib/libc/sys/getrlimit.2
+++ b/lib/libc/sys/getrlimit.2
@@ -108,6 +108,8 @@ Please see
for a complete description of this sysctl.
.It Dv RLIMIT_NPTS
The maximum number of pseudo-terminals created by this user id.
+.It Dv RLIMIT_KQUEUES
+The maximum number of kqueues created by this user id.
.El
.Pp
A resource limit is specified as a soft limit and a hard limit.
diff --git a/lib/libutil/login_class.3 b/lib/libutil/login_class.3
index 62a65f2..75f3614 100644
--- a/lib/libutil/login_class.3
+++ b/lib/libutil/login_class.3
@@ -118,6 +118,7 @@ sbsize RLIMIT_SBSIZE
vmemoryuse RLIMIT_VMEM
pseudoterminals RLIMIT_NPTS
swapuse RLIMIT_SWAP
+kqueues RLIMIT_KQUEUES
.Ed
.It LOGIN_SETPRIORITY
Set the scheduling priority for the current process based on the
diff --git a/lib/libutil/login_class.c b/lib/libutil/login_class.c
index 263044f..39cce12 100644
--- a/lib/libutil/login_class.c
+++ b/lib/libutil/login_class.c
@@ -66,6 +66,7 @@ static struct login_res {
{ "vmemoryuse", login_getcapsize, RLIMIT_VMEM },
{ "pseudoterminals", login_getcapnum, RLIMIT_NPTS },
{ "swapuse", login_getcapsize, RLIMIT_SWAP },
+ { "kqueues", login_getcapsize, RLIMIT_KQUEUES },
{ NULL, 0, 0 }
};
OpenPOWER on IntegriCloud