summaryrefslogtreecommitdiffstats
path: root/bin
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 /bin
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 'bin')
-rw-r--r--bin/sh/miscbltin.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/bin/sh/miscbltin.c b/bin/sh/miscbltin.c
index 2ecd4f2..27fa53d 100644
--- a/bin/sh/miscbltin.c
+++ b/bin/sh/miscbltin.c
@@ -405,6 +405,9 @@ static const struct limits limits[] = {
#ifdef RLIMIT_NPTS
{ "pseudo-terminals", (char *)0, RLIMIT_NPTS, 1, 'p' },
#endif
+#ifdef RLIMIT_KQUEUES
+ { "kqueues", (char *)0, RLIMIT_KQUEUES, 1, 'k' },
+#endif
{ (char *) 0, (char *)0, 0, 0, '\0' }
};
@@ -421,7 +424,7 @@ ulimitcmd(int argc __unused, char **argv __unused)
struct rlimit limit;
what = 'f';
- while ((optc = nextopt("HSatfdsmcnuvlbpw")) != '\0')
+ while ((optc = nextopt("HSatfdsmcnuvlbpwk")) != '\0')
switch (optc) {
case 'H':
how = HARD;
OpenPOWER on IntegriCloud