summaryrefslogtreecommitdiff
path: root/sys/kern/kern_ktrace.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2015-10-25 20:39:55 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2015-10-25 20:39:55 +0000
commit4de863f9ffcc7109cab38b676da78eaccd6d443b (patch)
tree16b565fcdd0af584260232b6be4f56d23b42b8f4 /sys/kern/kern_ktrace.c
parentd0e9b5026b2d545908c11216c861f0d4202cfd24 (diff)
Fold "malloc" into "stdio" and -- recognizing that no program so far has
used less than "stdio" -- include all the "self" operations. Instead of different defines, use regular PLEDGE_* in the "p_pledgenote" variable (which indicates the operation subtype a system call is performing). Many checks before easier to understand. p_pledgenote can often be passed directly to ktrace, so that kdump says: 15565 test CALL pledge(0xa9a3f804c51,0) 15565 test STRU pledge request="stdio" 15565 test RET pledge 0 15565 test CALL open(0xa9a3f804c57,0x2<O_RDWR>) 15565 test NAMI "/tmp/testfile" 15565 test PLDG open, "wpath", errno 1 Operation not permitted with help from semarie, ok guenther
Diffstat (limited to 'sys/kern/kern_ktrace.c')
-rw-r--r--sys/kern/kern_ktrace.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c
index 5d34952665c..e1727956af9 100644
--- a/sys/kern/kern_ktrace.c
+++ b/sys/kern/kern_ktrace.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_ktrace.c,v 1.80 2015/10/09 01:10:27 deraadt Exp $ */
+/* $OpenBSD: kern_ktrace.c,v 1.81 2015/10/25 20:39:54 deraadt Exp $ */
/* $NetBSD: kern_ktrace.c,v 1.23 1996/02/09 18:59:36 christos Exp $ */
/*
@@ -44,6 +44,7 @@
#include <sys/malloc.h>
#include <sys/syslog.h>
#include <sys/sysctl.h>
+#include <sys/pledge.h>
#include <sys/mount.h>
#include <sys/syscall.h>
@@ -398,6 +399,22 @@ ktrexec(struct proc *p, int type, const char *data, ssize_t len)
atomic_clearbits_int(&p->p_flag, P_INKTR);
}
+void
+ktrpledge(struct proc *p, int error, int code, int syscall)
+{
+ struct ktr_header kth;
+ struct ktr_pledge kp;
+
+ atomic_setbits_int(&p->p_flag, P_INKTR);
+ ktrinitheader(&kth, p, KTR_PLEDGE);
+ kp.error = error;
+ kp.code = code;
+ kp.syscall = syscall;
+
+ ktrwrite(p, &kth, &kp, sizeof(kp));
+ atomic_clearbits_int(&p->p_flag, P_INKTR);
+}
+
/* Interface and common routines */
/*
@@ -429,7 +446,7 @@ sys_ktrace(struct proc *p, void *v, register_t *retval)
* an operation which requires a file argument.
*/
cred = p->p_ucred;
- p->p_pledgenote = TMN_CPATH;
+ p->p_pledgenote = PLEDGE_CPATH;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, fname),
p);
if ((error = vn_open(&nd, FREAD|FWRITE|O_NOFOLLOW, 0)) != 0)