summaryrefslogtreecommitdiffstats
path: root/usr.bin/limits
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 /usr.bin/limits
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 'usr.bin/limits')
-rw-r--r--usr.bin/limits/limits.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/usr.bin/limits/limits.c b/usr.bin/limits/limits.c
index 3c5fd6d..8316743 100644
--- a/usr.bin/limits/limits.c
+++ b/usr.bin/limits/limits.c
@@ -89,7 +89,8 @@ static struct {
{ " sbsize%-4s %8s", " bytes\n", 1 },
{ " vmemoryuse%-4s %8s", " kB\n", 1024 },
{ " pseudo-terminals%-4s %8s", "\n", 1 },
- { " swapuse%-4s %8s", " kB\n", 1024 }
+ { " swapuse%-4s %8s", " kB\n", 1024 },
+ { " kqueues%-4s %8s", "\n", 1 },
}
},
{ "sh", "unlimited", "", " -H", " -S", "",
@@ -106,7 +107,8 @@ static struct {
{ "ulimit%s -b %s", ";\n", 1 },
{ "ulimit%s -v %s", ";\n", 1024 },
{ "ulimit%s -p %s", ";\n", 1 },
- { "ulimit%s -w %s", ";\n", 1024 }
+ { "ulimit%s -w %s", ";\n", 1024 },
+ { "ulimit%s -k %s", ";\n", 1 },
}
},
{ "csh", "unlimited", "", " -h", "", NULL,
@@ -123,7 +125,8 @@ static struct {
{ "limit%s sbsize %s", ";\n", 1 },
{ "limit%s vmemoryuse %s", ";\n", 1024 },
{ "limit%s pseudoterminals %s", ";\n", 1 },
- { "limit%s swapuse %s", ";\n", 1024 }
+ { "limit%s swapuse %s", ";\n", 1024 },
+ { "limit%s kqueues %s", ";\n", 1 },
}
},
{ "bash|bash2", "unlimited", "", " -H", " -S", "",
@@ -157,7 +160,8 @@ static struct {
{ "limit%s sbsize %s", ";\n", 1 },
{ "limit%s vmemoryuse %s", ";\n", 1024 },
{ "limit%s pseudoterminals %s", ";\n", 1 },
- { "limit%s swapuse %s", ";\n", 1024 }
+ { "limit%s swapuse %s", ";\n", 1024 },
+ { "limit%s kqueues %s", ";\n", 1 },
}
},
{ "ksh|pdksh", "unlimited", "", " -H", " -S", "",
@@ -232,7 +236,8 @@ static struct {
{ "sbsize", login_getcapsize },
{ "vmemoryuse", login_getcapsize },
{ "pseudoterminals",login_getcapnum },
- { "swapuse", login_getcapsize }
+ { "swapuse", login_getcapsize },
+ { "kqueues", login_getcapnum },
};
/*
@@ -647,6 +652,7 @@ resource_num(int which, int ch, const char *str)
case RLIMIT_NPROC:
case RLIMIT_NOFILE:
case RLIMIT_NPTS:
+ case RLIMIT_KQUEUES:
res = strtoq(s, &e, 0);
s = e;
break;
OpenPOWER on IntegriCloud