summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libc/sys/sysctl.219
-rw-r--r--sbin/sysctl/sysctl.c29
-rw-r--r--share/man/man4/witness.46
-rw-r--r--sys/kern/kern_sysctl.c6
-rw-r--r--sys/kern/subr_witness.c23
-rw-r--r--sys/sys/sysctl.h17
-rw-r--r--sys/sys/witness.h3
7 files changed, 89 insertions, 14 deletions
diff --git a/lib/libc/sys/sysctl.2 b/lib/libc/sys/sysctl.2
index 733bb8c6f0b..084009dee79 100644
--- a/lib/libc/sys/sysctl.2
+++ b/lib/libc/sys/sysctl.2
@@ -1,4 +1,4 @@
-.\" $OpenBSD: sysctl.2,v 1.20 2019/01/22 00:04:26 ajacoutot Exp $
+.\" $OpenBSD: sysctl.2,v 1.21 2019/01/29 14:07:15 visa Exp $
.\"
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
@@ -27,7 +27,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd $Mdocdate: January 22 2019 $
+.Dd $Mdocdate: January 29 2019 $
.Dt SYSCTL 2
.Os
.Sh NAME
@@ -489,7 +489,7 @@ information.
.It Dv KERN_TTYCOUNT Ta "integer" Ta "no"
.It Dv KERN_VERSION Ta "string" Ta "no"
.It Dv KERN_WATCHDOG Ta "node" Ta "not applicable"
-.It Dv KERN_WITNESSWATCH Ta "integer" Ta "yes"
+.It Dv KERN_WITNESS Ta "node" Ta "not applicable"
.It Dv KERN_WXABORT Ta "integer" Ta "yes"
.El
.Bl -tag -width "123456"
@@ -1102,7 +1102,17 @@ variable.
The period of the watchdog timer in seconds.
Set to 0 to disable the watchdog timer.
.El
-.It Dv KERN_WITNESSWATCH Pq Va kern.witnesswatch
+.It Dv KERN_WITNESS Pq Va kern.witness
+Control settings of
+.Xr witness 4 .
+.Bl -column "KERN_WITNESS_WATCH" "integer" "Changeable" -offset indent
+.It Sy "Third level name" Ta Sy "Type" Ta Sy "Changeable"
+.It Dv KERN_WITNESS_WATCH Ta "integer" Ta "yes"
+.El
+.Pp
+The variables are as follows:
+.Bl -tag -width "123456"
+.It Dv KERN_WITNESS_WATCH Pq Va kern.witness.watch
Control how
.Xr witness 4
behaves on error.
@@ -1124,6 +1134,7 @@ and a stack trace if possible.
.It 3
The same as 2, but also drop into the kernel debugger.
.El
+.El
.It Dv KERN_WXABORT Pq Va kern.wxabort
Generate an abort,
rather than returning an error,
diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c
index 8bd235d9226..cd2be30f80e 100644
--- a/sbin/sysctl/sysctl.c
+++ b/sbin/sysctl/sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysctl.c,v 1.239 2018/12/10 13:35:54 landry Exp $ */
+/* $OpenBSD: sysctl.c,v 1.240 2019/01/29 14:07:15 visa Exp $ */
/* $NetBSD: sysctl.c,v 1.9 1995/09/30 07:12:50 thorpej Exp $ */
/*
@@ -130,6 +130,7 @@ struct ctlname machdepname[] = CTL_MACHDEP_NAMES;
#endif
struct ctlname ddbname[] = CTL_DDB_NAMES;
struct ctlname audioname[] = CTL_KERN_AUDIO_NAMES;
+struct ctlname witnessname[] = CTL_KERN_WITNESS_NAMES;
char names[BUFSIZ];
int lastused;
@@ -214,6 +215,7 @@ void print_sensor(struct sensor *);
int sysctl_chipset(char *, char **, int *, int, int *);
#endif
int sysctl_audio(char *, char **, int *, int, int *);
+int sysctl_witness(char *, char **, int *, int, int *);
void vfsinit(void);
char *equ = "=";
@@ -502,6 +504,11 @@ parse(char *string, int flags)
if (len < 0)
return;
break;
+ case KERN_WITNESS:
+ len = sysctl_witness(string, &bufp, mib, flags, &type);
+ if (len < 0)
+ return;
+ break;
}
break;
@@ -1717,6 +1724,7 @@ struct list shmlist = { shmname, KERN_SHMINFO_MAXID };
struct list watchdoglist = { watchdogname, KERN_WATCHDOG_MAXID };
struct list tclist = { tcname, KERN_TIMECOUNTER_MAXID };
struct list audiolist = { audioname, KERN_AUDIO_MAXID };
+struct list witnesslist = { witnessname, KERN_WITNESS_MAXID };
/*
* handle vfs namei cache statistics
@@ -2720,6 +2728,25 @@ sysctl_audio(char *string, char **bufpp, int mib[], int flags, int *typep)
}
/*
+ * Handle witness support
+ */
+int
+sysctl_witness(char *string, char **bufpp, int mib[], int flags, int *typep)
+{
+ int indx;
+
+ if (*bufpp == NULL) {
+ listall(string, &witnesslist);
+ return (-1);
+ }
+ if ((indx = findname(string, "third", bufpp, &witnesslist)) == -1)
+ return (-1);
+ mib[2] = indx;
+ *typep = witnesslist.list[indx].ctl_type;
+ return (3);
+}
+
+/*
* Scan a list of names searching for a particular name.
*/
int
diff --git a/share/man/man4/witness.4 b/share/man/man4/witness.4
index 6869960cc55..bcdfe6699ee 100644
--- a/share/man/man4/witness.4
+++ b/share/man/man4/witness.4
@@ -1,4 +1,4 @@
-.\" $OpenBSD: witness.4,v 1.4 2018/05/16 14:58:48 visa Exp $
+.\" $OpenBSD: witness.4,v 1.5 2019/01/29 14:07:15 visa Exp $
.\"
.\" Copyright (c) 2001 John H. Baldwin <jhb@FreeBSD.org>
.\" All rights reserved.
@@ -26,7 +26,7 @@
.\"
.\" $FreeBSD: head/share/man/man4/witness.4 301719 2016-06-09 06:55:00Z trasz $
.\"
-.Dd $Mdocdate: May 16 2018 $
+.Dd $Mdocdate: January 29 2019 $
.Dt WITNESS 4
.Os
.Sh NAME
@@ -55,7 +55,7 @@ If any of these checks fail, then the kernel will panic.
The behaviour of
.Nm
is controlled by the
-.Va kern.witnesswatch
+.Va kern.witness.watch
.Xr sysctl 8
variable.
Valid values for it are:
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index 243f92657a9..93bbb5019b3 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sysctl.c,v 1.353 2019/01/19 01:53:44 cheloha Exp $ */
+/* $OpenBSD: kern_sysctl.c,v 1.354 2019/01/29 14:07:15 visa Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*-
@@ -311,6 +311,7 @@ kern_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
case KERN_TIMECOUNTER:
case KERN_CPTIME2:
case KERN_FILE:
+ case KERN_WITNESS:
case KERN_AUDIO:
case KERN_CPUSTATS:
break;
@@ -655,6 +656,9 @@ kern_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
#ifdef WITNESS
case KERN_WITNESSWATCH:
return witness_sysctl_watch(oldp, oldlenp, newp, newlen);
+ case KERN_WITNESS:
+ return witness_sysctl(name + 1, namelen - 1, oldp, oldlenp,
+ newp, newlen);
#endif
#if NAUDIO > 0
case KERN_AUDIO:
diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c
index d4b455eadd8..725a5cd0301 100644
--- a/sys/kern/subr_witness.c
+++ b/sys/kern/subr_witness.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_witness.c,v 1.26 2019/01/27 10:41:41 anton Exp $ */
+/* $OpenBSD: subr_witness.c,v 1.27 2019/01/29 14:07:15 visa Exp $ */
/*-
* Copyright (c) 2008 Isilon Systems, Inc.
@@ -2551,6 +2551,27 @@ witness_debugger(int dump)
}
int
+witness_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp,
+ void *newp, size_t newlen)
+{
+ int error;
+
+ if (namelen != 1)
+ return (ENOTDIR);
+
+ switch (name[0]) {
+ case KERN_WITNESS_WATCH:
+ error = witness_sysctl_watch(oldp, oldlenp, newp, newlen);
+ break;
+ default:
+ error = EOPNOTSUPP;
+ break;
+ }
+
+ return (error);
+}
+
+int
witness_sysctl_watch(void *oldp, size_t *oldlenp, void *newp, size_t newlen)
{
int error;
diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h
index 14df56d0eb6..2a8ff365a74 100644
--- a/sys/sys/sysctl.h
+++ b/sys/sys/sysctl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysctl.h,v 1.181 2018/11/19 16:12:06 tedu Exp $ */
+/* $OpenBSD: sysctl.h,v 1.182 2019/01/29 14:07:15 visa Exp $ */
/* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */
/*
@@ -160,7 +160,7 @@ struct ctlname {
#define KERN_TTYCOUNT 57 /* int: number of tty devices */
#define KERN_NUMVNODES 58 /* int: number of vnodes in use */
#define KERN_MBSTAT 59 /* struct: mbuf statistics */
-/* was KERN_USERASYMCRYPTO 60 */
+#define KERN_WITNESS 60 /* node: witness */
#define KERN_SEMINFO 61 /* struct: SysV struct seminfo */
#define KERN_SHMINFO 62 /* struct: SysV struct shminfo */
#define KERN_INTRCNT 63 /* node: interrupt counters */
@@ -249,7 +249,7 @@ struct ctlname {
{ "ttycount", CTLTYPE_INT }, \
{ "numvnodes", CTLTYPE_INT }, \
{ "mbstat", CTLTYPE_STRUCT }, \
- { "gap", 0 }, \
+ { "witness", CTLTYPE_NODE }, \
{ "seminfo", CTLTYPE_STRUCT }, \
{ "shminfo", CTLTYPE_STRUCT }, \
{ "intrcnt", CTLTYPE_NODE }, \
@@ -317,6 +317,17 @@ struct ctlname {
}
/*
+ * KERN_WITNESS
+ */
+#define KERN_WITNESS_WATCH 1 /* int: operating mode */
+#define KERN_WITNESS_MAXID 2
+
+#define CTL_KERN_WITNESS_NAMES { \
+ { 0, 0 }, \
+ { "watch", CTLTYPE_INT }, \
+}
+
+/*
* KERN_PROC subtype ops return arrays of relatively fixed size
* structures of process info. Use 8 byte alignment, and new
* elements should only be added to the end of this structure so
diff --git a/sys/sys/witness.h b/sys/sys/witness.h
index 8ef6aef68e0..312bec0d47d 100644
--- a/sys/sys/witness.h
+++ b/sys/sys/witness.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: witness.h,v 1.3 2018/06/08 15:38:15 guenther Exp $ */
+/* $OpenBSD: witness.h,v 1.4 2019/01/29 14:07:15 visa Exp $ */
/*-
* Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved.
@@ -89,6 +89,7 @@ void witness_norelease(struct lock_object *);
void witness_releaseok(struct lock_object *);
const char *witness_file(struct lock_object *);
void witness_thread_exit(struct proc *);
+int witness_sysctl(int *, u_int, void *, size_t *, void *, size_t);
int witness_sysctl_watch(void *, size_t *, void *, size_t);
#ifdef WITNESS