summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/amd64/amd64/machdep.c13
-rw-r--r--sys/arch/i386/i386/machdep.c13
-rw-r--r--sys/arch/loongson/loongson/machdep.c14
3 files changed, 34 insertions, 6 deletions
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c
index 653d636df9f..6651213a0b7 100644
--- a/sys/arch/amd64/amd64/machdep.c
+++ b/sys/arch/amd64/amd64/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.224 2017/03/02 10:38:09 natano Exp $ */
+/* $OpenBSD: machdep.c,v 1.225 2017/03/07 11:49:42 natano Exp $ */
/* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */
/*-
@@ -447,6 +447,7 @@ cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
extern int amd64_has_xcrypt;
dev_t consdev;
dev_t dev;
+ int val, error;
switch (name[0]) {
case CPU_CONSDEV:
@@ -496,7 +497,15 @@ cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
return (sysctl_rdint(oldp, oldlenp, newp, amd64_has_xcrypt));
case CPU_LIDSUSPEND:
case CPU_LIDACTION:
- return (sysctl_int(oldp, oldlenp, newp, newlen, &lid_action));
+ val = lid_action;
+ error = sysctl_int(oldp, oldlenp, newp, newlen, &val);
+ if (!error) {
+ if (val < 0 || val > 2)
+ error = EINVAL;
+ else
+ lid_action = val;
+ }
+ return (error);
default:
return (EOPNOTSUPP);
}
diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c
index bc9e3a05601..d1863c92fe4 100644
--- a/sys/arch/i386/i386/machdep.c
+++ b/sys/arch/i386/i386/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.596 2017/03/02 10:38:10 natano Exp $ */
+/* $OpenBSD: machdep.c,v 1.597 2017/03/07 11:49:42 natano Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
@@ -3530,6 +3530,7 @@ cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
size_t newlen, struct proc *p)
{
dev_t dev;
+ int val, error;
switch (name[0]) {
case CPU_CONSDEV:
@@ -3596,7 +3597,15 @@ cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
return (sysctl_rdint(oldp, oldlenp, newp, i386_has_xcrypt));
case CPU_LIDSUSPEND:
case CPU_LIDACTION:
- return (sysctl_int(oldp, oldlenp, newp, newlen, &lid_action));
+ val = lid_action;
+ error = sysctl_int(oldp, oldlenp, newp, newlen, &val);
+ if (!error) {
+ if (val < 0 || val > 2)
+ error = EINVAL;
+ else
+ lid_action = val;
+ }
+ return (error);
default:
return (EOPNOTSUPP);
}
diff --git a/sys/arch/loongson/loongson/machdep.c b/sys/arch/loongson/loongson/machdep.c
index 73e74b515a4..5d373139e9c 100644
--- a/sys/arch/loongson/loongson/machdep.c
+++ b/sys/arch/loongson/loongson/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.73 2017/03/02 10:38:10 natano Exp $ */
+/* $OpenBSD: machdep.c,v 1.74 2017/03/07 11:49:42 natano Exp $ */
/*
* Copyright (c) 2009, 2010, 2014 Miodrag Vallat.
@@ -1019,6 +1019,8 @@ int
cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
size_t newlen, struct proc *p)
{
+ int val, error;
+
/* All sysctl names at this level are terminal. */
if (namelen != 1)
return ENOTDIR; /* Overloaded */
@@ -1026,7 +1028,15 @@ cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
switch (name[0]) {
case CPU_LIDSUSPEND:
case CPU_LIDACTION:
- return sysctl_int(oldp, oldlenp, newp, newlen, &lid_action);
+ val = lid_action;
+ error = sysctl_int(oldp, oldlenp, newp, newlen, &val);
+ if (!error) {
+ if (val < 0 || val > 2)
+ error = EINVAL;
+ else
+ lid_action = val;
+ }
+ return error;
default:
return EOPNOTSUPP;
}