summaryrefslogtreecommitdiff
path: root/sys/kern/kern_sysctl.c
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2003-10-24 19:05:22 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2003-10-24 19:05:22 +0000
commitea53828bc84e5f0d4bf9cfe653c2b459bb34b8d4 (patch)
treebe27b6c0ba44e1490184923e87f7b46b2db94abe /sys/kern/kern_sysctl.c
parent76f7958a85554bcc6e4205a751a426c7d745c591 (diff)
refactor stackgap sysctl. prompted by a bug report from Michael Coulter.
ok deraadt@ markus@
Diffstat (limited to 'sys/kern/kern_sysctl.c')
-rw-r--r--sys/kern/kern_sysctl.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index 4a4a6a3128a..0dee4aaf506 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sysctl.c,v 1.89 2003/08/23 20:02:59 tedu Exp $ */
+/* $OpenBSD: kern_sysctl.c,v 1.90 2003/10/24 19:05:21 tedu Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*-
@@ -244,7 +244,7 @@ kern_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
size_t newlen;
struct proc *p;
{
- int error, level, inthostid, oldsgap;
+ int error, level, inthostid, stackgap;
extern int somaxconn, sominconn;
extern int usermount, nosuidcoredump;
extern long cp_time[CPUSTATES];
@@ -439,19 +439,18 @@ kern_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
case KERN_POOL:
return (sysctl_dopool(name + 1, namelen - 1, oldp, oldlenp));
case KERN_STACKGAPRANDOM:
- oldsgap = stackgap_random;
-
- error = sysctl_int(oldp, oldlenp, newp, newlen, &stackgap_random);
+ stackgap = stackgap_random;
+ error = sysctl_int(oldp, oldlenp, newp, newlen, &stackgap);
+ if (error)
+ return (error);
/*
* Safety harness.
*/
- if ((stackgap_random < ALIGNBYTES && stackgap_random != 0) ||
- !powerof2(stackgap_random) ||
- stackgap_random > PAGE_SIZE * 2) {
- stackgap_random = oldsgap;
+ if ((stackgap < ALIGNBYTES && stackgap != 0) ||
+ !powerof2(stackgap))
return (EINVAL);
- }
- return (error);
+ stackgap_random = stackgap;
+ return (0);
#if defined(SYSVMSG) || defined(SYSVSEM) || defined(SYSVSHM)
case KERN_SYSVIPC_INFO:
return (sysctl_sysvipc(name + 1, namelen - 1, oldp, oldlenp));