summaryrefslogtreecommitdiffstats
path: root/lib/libutil
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/libutil
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/libutil')
-rw-r--r--lib/libutil/login_class.31
-rw-r--r--lib/libutil/login_class.c1
2 files changed, 2 insertions, 0 deletions
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