diff options
author | Stuart Henderson <sthen@cvs.openbsd.org> | 2009-06-24 14:28:20 +0000 |
---|---|---|
committer | Stuart Henderson <sthen@cvs.openbsd.org> | 2009-06-24 14:28:20 +0000 |
commit | 8d5f78e967ffc3a4109902a3a2fd94a1a074ad12 (patch) | |
tree | 218777fc05db3266cd97b06c4d4ed1004f98a488 | |
parent | a0bff0c81c8d4320fe88f90c2932aac9e22f895a (diff) |
Lower stack size before mlockall(). With login.conf defaults for i386,
this avoids wiring (8MB-256KB). From AerieBSD.
ok deraadt@
-rw-r--r-- | usr.sbin/watchdogd/watchdogd.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/usr.sbin/watchdogd/watchdogd.c b/usr.sbin/watchdogd/watchdogd.c index 48457ce0d01..d7905679163 100644 --- a/usr.sbin/watchdogd/watchdogd.c +++ b/usr.sbin/watchdogd/watchdogd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: watchdogd.c,v 1.12 2008/05/12 19:15:02 pyr Exp $ */ +/* $OpenBSD: watchdogd.c,v 1.13 2009/06/24 14:28:19 sthen Exp $ */ /* * Copyright (c) 2005 Marc Balmer <mbalmer@openbsd.org> @@ -52,6 +52,7 @@ sighdlr(int signum) int main(int argc, char *argv[]) { + struct rlimit rlim; const char *errstr; size_t len; u_int interval = 0, period = 30, nperiod; @@ -140,6 +141,14 @@ main(int argc, char *argv[]) goto restore; } + /* + * mlockall() below will wire the whole stack up to the limit + * thus we have to reduce stack size to avoid resource abuse + */ + rlim.rlim_cur = 256 * 1024; + rlim.rlim_max = 256 * 1024; + (void)setrlimit(RLIMIT_STACK, &rlim); + (void)mlockall(MCL_CURRENT | MCL_FUTURE); setpriority(PRIO_PROCESS, getpid(), -5); |