diff options
author | Marco Pfatschbacher <mpf@cvs.openbsd.org> | 2008-11-08 01:14:52 +0000 |
---|---|---|
committer | Marco Pfatschbacher <mpf@cvs.openbsd.org> | 2008-11-08 01:14:52 +0000 |
commit | 1954ec9789789aeb22301860434c3fa740766a60 (patch) | |
tree | ade826b2468ffc2d3d7bdb12fb28a7f895fd2105 /sys/ddb | |
parent | 110070b785df9e67a94b00788cfd4c22e202ada0 (diff) |
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')
-rw-r--r-- | sys/ddb/db_usrreq.c | 16 | ||||
-rw-r--r-- | sys/ddb/db_var.h | 6 |
2 files changed, 19 insertions, 3 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); } diff --git a/sys/ddb/db_var.h b/sys/ddb/db_var.h index 01ee75e0388..c4a555df117 100644 --- a/sys/ddb/db_var.h +++ b/sys/ddb/db_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: db_var.h,v 1.9 2006/07/06 18:14:48 miod Exp $ */ +/* $OpenBSD: db_var.h,v 1.10 2008/11/08 01:14:51 mpf Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff. All rights reserved. @@ -42,7 +42,8 @@ #define DBCTL_PANIC 5 #define DBCTL_CONSOLE 6 #define DBCTL_LOG 7 -#define DBCTL_MAXID 8 +#define DBCTL_TRIGGER 8 +#define DBCTL_MAXID 9 #define CTL_DDB_NAMES { \ { NULL, 0 }, \ @@ -53,6 +54,7 @@ { "panic", CTLTYPE_INT }, \ { "console", CTLTYPE_INT }, \ { "log", CTLTYPE_INT }, \ + { "trigger", CTLTYPE_INT }, \ } #ifdef _KERNEL |