summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2003-09-23 20:26:19 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2003-09-23 20:26:19 +0000
commit338ac2ca1b01bfb19692a4b9cda5ec5b7c3665b3 (patch)
tree79c7e5f48011afdceae8f7d8cd53d107c60e197e /sys
parent33969b821fb937064b7306c224c4f5930425408c (diff)
Limit "proc: table is full" messages to once every 10 seconds which helps when there is a fork bomb going on. From NetBSD (jdolecek)
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_fork.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index abfa1106bd6..f137d22b431 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_fork.c,v 1.62 2003/07/02 00:07:42 avsm Exp $ */
+/* $OpenBSD: kern_fork.c,v 1.63 2003/09/23 20:26:18 millert Exp $ */
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/*
@@ -123,6 +123,9 @@ sys_rfork(struct proc *p, void *v, register_t *retval)
return (fork1(p, SIGCHLD, flags, NULL, 0, NULL, NULL, retval));
}
+/* print the 'table full' message once per 10 seconds */
+struct timeval fork_tfmrate = { 10, 0 };
+
int
fork1(struct proc *p1, int exitsig, int flags, void *stack, size_t stacksize,
void (*func)(void *), void *arg, register_t *retval)
@@ -144,7 +147,10 @@ fork1(struct proc *p1, int exitsig, int flags, void *stack, size_t stacksize,
*/
uid = p1->p_cred->p_ruid;
if ((nprocs >= maxproc - 5 && uid != 0) || nprocs >= maxproc) {
- tablefull("proc");
+ static struct timeval lasttfm;
+
+ if (ratecheck(&lasttfm, &fork_tfmrate))
+ tablefull("proc");
return (EAGAIN);
}
nprocs++;