diff options
author | 2008-11-08 01:14:51 +0000 | |
---|---|---|
committer | 2008-11-08 01:14:51 +0000 | |
commit | ad129c4224055d094566c168187241a332be374d (patch) | |
tree | e4d6d0b779870a7e1e321b4ffcfea16cdedc2537 /sys/ddb/db_usrreq.c | |
parent | Take into account that our ether_input() already strips the (diff) | |
download | wireguard-openbsd-ad129c4224055d094566c168187241a332be374d.tar.xz wireguard-openbsd-ad129c4224055d094566c168187241a332be374d.zip |
Add a new sysctl ``ddb.trigger''
Writing to it, will bring the system into the kernel debugger.
ddb.console=1 is required and the sysctl command has to be executed
from the actual console tty.
If the securelevel is < 1, the tty check is ignored.
Feedback and OK ckuethe@, deraadt@.
Diffstat (limited to 'sys/ddb/db_usrreq.c')
-rw-r--r-- | sys/ddb/db_usrreq.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/sys/ddb/db_usrreq.c b/sys/ddb/db_usrreq.c index a84a7895113..f62908fcc65 100644 --- a/sys/ddb/db_usrreq.c +++ b/sys/ddb/db_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_usrreq.c,v 1.12 2006/03/15 21:49:40 miod Exp $ */ +/* $OpenBSD: db_usrreq.c,v 1.13 2008/11/08 01:14:51 mpf Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff. All rights reserved. @@ -28,8 +28,10 @@ #include <sys/types.h> #include <sys/kernel.h> #include <sys/proc.h> +#include <sys/tty.h> #include <uvm/uvm_extern.h> #include <sys/sysctl.h> +#include <dev/cons.h> #include <ddb/db_var.h> @@ -87,6 +89,18 @@ ddb_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, break; case DBCTL_LOG: return (sysctl_int(oldp, oldlenp, newp, newlen, &db_log)); + case DBCTL_TRIGGER: + if (newp && db_console) { + struct proc *p = curproc; + if (securelevel < 1 || + (p->p_flag & P_CONTROLT && cn_tab && + cn_tab->cn_dev == p->p_session->s_ttyp->t_dev)) { + Debugger(); + newp = NULL; + } else + return (EOPNOTSUPP); + } + return (sysctl_rdint(oldp, oldlenp, newp, 0)); default: return (EOPNOTSUPP); } |