summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorPhilip Guenthe <guenther@cvs.openbsd.org>2012-03-19 09:05:40 +0000
committerPhilip Guenthe <guenther@cvs.openbsd.org>2012-03-19 09:05:40 +0000
commitf2014dc397c2f285566b439a8a6148a14b6a3ef9 (patch)
treed229ef04133f3436b2ffe28e924b82b41d63c7e6 /sys
parent4b4ca199b889eb9f83636a4440711c3e46fc2e8b (diff)
Add tracing and dumping of "pointer to struct" syscall arguments for
structs timespec, timeval, sigaction, and rlimit. ok otto@ jsing@
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_event.c7
-rw-r--r--sys/kern/kern_ktrace.c5
-rw-r--r--sys/kern/kern_resource.c18
-rw-r--r--sys/kern/kern_sig.c21
-rw-r--r--sys/kern/kern_synch.c6
-rw-r--r--sys/kern/kern_time.c44
-rw-r--r--sys/kern/sys_generic.c6
-rw-r--r--sys/kern/vfs_syscalls.c11
-rw-r--r--sys/sys/ktrace.h15
9 files changed, 119 insertions, 14 deletions
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c
index 37753d694b9..619f4706cf8 100644
--- a/sys/kern/kern_event.c
+++ b/sys/kern/kern_event.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_event.c,v 1.43 2012/03/10 05:54:28 guenther Exp $ */
+/* $OpenBSD: kern_event.c,v 1.44 2012/03/19 09:05:39 guenther Exp $ */
/*-
* Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org>
@@ -41,6 +41,7 @@
#include <sys/queue.h>
#include <sys/event.h>
#include <sys/eventvar.h>
+#include <sys/ktrace.h>
#include <sys/pool.h>
#include <sys/protosw.h>
#include <sys/socket.h>
@@ -470,6 +471,10 @@ sys_kevent(struct proc *p, void *v, register_t *retval)
error = copyin(SCARG(uap, timeout), &ts, sizeof(ts));
if (error)
goto done;
+#ifdef KTRACE
+ if (KTRPOINT(p, KTR_STRUCT))
+ ktrreltimespec(p, &ts);
+#endif
SCARG(uap, timeout) = &ts;
}
diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c
index 6811cfb48a0..cc69df31a6a 100644
--- a/sys/kern/kern_ktrace.c
+++ b/sys/kern/kern_ktrace.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_ktrace.c,v 1.56 2011/12/14 07:32:16 guenther Exp $ */
+/* $OpenBSD: kern_ktrace.c,v 1.57 2012/03/19 09:05:39 guenther Exp $ */
/* $NetBSD: kern_ktrace.c,v 1.23 1996/02/09 18:59:36 christos Exp $ */
/*
@@ -316,6 +316,9 @@ ktrstruct(struct proc *p, const char *name, const void *data, size_t datalen)
void *buf;
size_t buflen;
+#ifdef MULTIPROCESSOR
+ KASSERT(__mp_lock_held(&kernel_lock) > 0);
+#endif
atomic_setbits_int(&p->p_flag, P_INKTR);
ktrinitheader(&kth, p, KTR_STRUCT);
diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c
index 15d66f5555b..ce3dfea9fdf 100644
--- a/sys/kern/kern_resource.c
+++ b/sys/kern/kern_resource.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_resource.c,v 1.37 2011/03/07 07:07:13 guenther Exp $ */
+/* $OpenBSD: kern_resource.c,v 1.38 2012/03/19 09:05:39 guenther Exp $ */
/* $NetBSD: kern_resource.c,v 1.38 1996/10/23 07:19:38 matthias Exp $ */
/*-
@@ -44,6 +44,7 @@
#include <sys/resourcevar.h>
#include <sys/pool.h>
#include <sys/proc.h>
+#include <sys/ktrace.h>
#include <sys/sched.h>
#include <sys/mount.h>
@@ -218,6 +219,10 @@ sys_setrlimit(struct proc *p, void *v, register_t *retval)
sizeof (struct rlimit));
if (error)
return (error);
+#ifdef KTRACE
+ if (KTRPOINT(p, KTR_STRUCT))
+ ktrrlimit(p, &alim);
+#endif
return (dosetrlimit(p, SCARG(uap, which), &alim));
}
@@ -315,11 +320,18 @@ sys_getrlimit(struct proc *p, void *v, register_t *retval)
syscallarg(int) which;
syscallarg(struct rlimit *) rlp;
} */ *uap = v;
+ struct rlimit *alimp;
+ int error;
if (SCARG(uap, which) < 0 || SCARG(uap, which) >= RLIM_NLIMITS)
return (EINVAL);
- return (copyout((caddr_t)&p->p_rlimit[SCARG(uap, which)],
- (caddr_t)SCARG(uap, rlp), sizeof (struct rlimit)));
+ alimp = &p->p_rlimit[SCARG(uap, which)];
+ error = copyout(alimp, SCARG(uap, rlp), sizeof(struct rlimit));
+#ifdef KTRACE
+ if (error == 0 && KTRPOINT(p, KTR_STRUCT))
+ ktrrlimit(p, alimp);
+#endif
+ return (error);
}
/*
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index b3a92976985..5171bd7323e 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sig.c,v 1.136 2012/03/10 06:27:21 guenther Exp $ */
+/* $OpenBSD: kern_sig.c,v 1.137 2012/03/19 09:05:39 guenther Exp $ */
/* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */
/*
@@ -223,6 +223,9 @@ sys_sigaction(struct proc *p, void *v, register_t *retval)
syscallarg(struct sigaction *) osa;
} */ *uap = v;
struct sigaction vec;
+#ifdef KTRACE
+ struct sigaction ovec;
+#endif
struct sigaction *sa;
const struct sigaction *nsa;
struct sigaction *osa;
@@ -263,13 +266,25 @@ sys_sigaction(struct proc *p, void *v, register_t *retval)
error = copyout(sa, osa, sizeof (vec));
if (error)
return (error);
+#ifdef KTRACE
+ if (KTRPOINT(p, KTR_STRUCT))
+ ovec = vec;
+#endif
}
if (nsa) {
error = copyin(nsa, sa, sizeof (vec));
if (error)
return (error);
+#ifdef KTRACE
+ if (KTRPOINT(p, KTR_STRUCT))
+ ktrsigaction(p, sa);
+#endif
setsigvec(p, signum, sa);
}
+#ifdef KTRACE
+ if (osa && KTRPOINT(p, KTR_STRUCT))
+ ktrsigaction(p, &ovec);
+#endif
return (0);
}
@@ -1557,6 +1572,10 @@ sys___thrsigdivert(struct proc *p, void *v, register_t *retval)
struct timespec ts;
if ((error = copyin(SCARG(uap, timeout), &ts, sizeof(ts))) != 0)
return (error);
+#ifdef KTRACE
+ if (KTRPOINT(p, KTR_STRUCT))
+ ktrreltimespec(p, &ts);
+#endif
to_ticks = (long long)hz * ts.tv_sec +
ts.tv_nsec / (tick * 1000);
if (to_ticks > INT_MAX)
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c
index 6b7f80ab747..031a46dfaee 100644
--- a/sys/kern/kern_synch.c
+++ b/sys/kern/kern_synch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_synch.c,v 1.99 2012/01/17 02:34:18 guenther Exp $ */
+/* $OpenBSD: kern_synch.c,v 1.100 2012/03/19 09:05:39 guenther Exp $ */
/* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */
/*
@@ -435,6 +435,10 @@ sys___thrsleep(struct proc *p, void *v, register_t *retval)
*retval = error;
return (0);
}
+#ifdef KTRACE
+ if (KTRPOINT(p, KTR_STRUCT))
+ ktrabstimespec(p, &ats);
+#endif
if (timespeccmp(&ats, &now, <)) {
/* already passed: still do the unlock */
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 3d2d36f4af9..180e76178fb 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_time.c,v 1.72 2012/03/10 05:54:28 guenther Exp $ */
+/* $OpenBSD: kern_time.c,v 1.73 2012/03/19 09:05:39 guenther Exp $ */
/* $NetBSD: kern_time.c,v 1.20 1996/02/18 11:57:06 fvdl Exp $ */
/*
@@ -37,6 +37,7 @@
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/proc.h>
+#include <sys/ktrace.h>
#include <sys/vnode.h>
#include <sys/signalvar.h>
#ifdef __HAVE_TIMECOUNTER
@@ -219,7 +220,15 @@ sys_clock_gettime(struct proc *p, void *v, register_t *retval)
if ((error = clock_gettime(p, SCARG(uap, clock_id), &ats)) != 0)
return (error);
- return copyout(&ats, SCARG(uap, tp), sizeof(ats));
+ error = copyout(&ats, SCARG(uap, tp), sizeof(ats));
+#ifdef KTRACE
+ if (error == 0 && KTRPOINT(p, KTR_STRUCT)) {
+ KERNEL_LOCK();
+ ktrabstimespec(p, &ats);
+ KERNEL_UNLOCK();
+ }
+#endif
+ return (error);
}
/* ARGSUSED */
@@ -275,8 +284,16 @@ sys_clock_getres(struct proc *p, void *v, register_t *retval)
return (EINVAL);
}
- if (SCARG(uap, tp))
+ if (SCARG(uap, tp)) {
error = copyout(&ts, SCARG(uap, tp), sizeof (ts));
+#ifdef KTRACE
+ if (error == 0 && KTRPOINT(p, KTR_STRUCT)) {
+ KERNEL_LOCK();
+ ktrreltimespec(p, &ts);
+ KERNEL_UNLOCK();
+ }
+#endif
+ }
return error;
}
@@ -300,6 +317,13 @@ sys_nanosleep(struct proc *p, void *v, register_t *retval)
error = copyin(SCARG(uap, rqtp), &rqt, sizeof(struct timespec));
if (error)
return (error);
+#ifdef KTRACE
+ if (KTRPOINT(p, KTR_STRUCT)) {
+ KERNEL_LOCK();
+ ktrreltimespec(p, &rqt);
+ KERNEL_UNLOCK();
+ }
+#endif
TIMESPEC_TO_TIMEVAL(&tv, &rqt);
if (itimerfix(&tv))
@@ -327,6 +351,13 @@ sys_nanosleep(struct proc *p, void *v, register_t *retval)
error1 = copyout(&rmt, rmtp, sizeof(rmt));
if (error1 != 0)
error = error1;
+#ifdef KTRACE
+ if (error1 == 0 && KTRPOINT(p, KTR_STRUCT)) {
+ KERNEL_LOCK();
+ ktrreltimespec(p, &rmt);
+ KERNEL_UNLOCK();
+ }
+#endif
}
return error;
@@ -352,6 +383,13 @@ sys_gettimeofday(struct proc *p, void *v, register_t *retval)
microtime(&atv);
if ((error = copyout(&atv, tp, sizeof (atv))))
return (error);
+#ifdef KTRACE
+ if (KTRPOINT(p, KTR_STRUCT)) {
+ KERNEL_LOCK();
+ ktrabstimeval(p, &atv);
+ KERNEL_UNLOCK();
+ }
+#endif
}
if (tzp)
error = copyout(&tz, tzp, sizeof (tz));
diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c
index 4fbc127dae0..1c20b4b93f9 100644
--- a/sys/kern/sys_generic.c
+++ b/sys/kern/sys_generic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_generic.c,v 1.74 2012/02/15 04:26:27 guenther Exp $ */
+/* $OpenBSD: sys_generic.c,v 1.75 2012/03/19 09:05:39 guenther Exp $ */
/* $NetBSD: sys_generic.c,v 1.24 1996/03/29 00:25:32 cgd Exp $ */
/*
@@ -579,6 +579,10 @@ sys_select(struct proc *p, void *v, register_t *retval)
error = copyin(SCARG(uap, tv), &atv, sizeof (atv));
if (error)
goto done;
+#ifdef KTRACE
+ if (KTRPOINT(p, KTR_STRUCT))
+ ktrreltimeval(p, &atv);
+#endif
if (itimerfix(&atv)) {
error = EINVAL;
goto done;
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 594916e142d..ef16e737321 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_syscalls.c,v 1.180 2011/11/06 15:09:02 guenther Exp $ */
+/* $OpenBSD: vfs_syscalls.c,v 1.181 2012/03/19 09:05:39 guenther Exp $ */
/* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */
/*
@@ -2287,6 +2287,15 @@ dovutimens(struct proc *p, struct vnode *vp, struct timespec ts[2],
struct timespec now;
int error;
+#ifdef KTRACE
+ /* if they're both UTIME_NOW, then don't report either */
+ if ((ts[0].tv_nsec != UTIME_NOW || ts[1].tv_nsec != UTIME_NOW) &&
+ KTRPOINT(p, KTR_STRUCT)) {
+ ktrabstimespec(p, &ts[0]);
+ ktrabstimespec(p, &ts[1]);
+ }
+#endif
+
VATTR_NULL(&vattr);
if (ts[0].tv_nsec == UTIME_NOW || ts[1].tv_nsec == UTIME_NOW) {
if (ts[0].tv_nsec == UTIME_NOW && ts[1].tv_nsec == UTIME_NOW)
diff --git a/sys/sys/ktrace.h b/sys/sys/ktrace.h
index 40420511159..b30a93a1677 100644
--- a/sys/sys/ktrace.h
+++ b/sys/sys/ktrace.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ktrace.h,v 1.12 2011/12/14 07:32:16 guenther Exp $ */
+/* $OpenBSD: ktrace.h,v 1.13 2012/03/19 09:05:39 guenther Exp $ */
/* $NetBSD: ktrace.h,v 1.12 1996/02/04 02:12:29 christos Exp $ */
/*
@@ -190,6 +190,17 @@ void ktrstruct(struct proc *, const char *, const void *, size_t);
ktrstruct((p), "sockaddr", (s), (l))
#define ktrstat(p, s) \
ktrstruct((p), "stat", (s), sizeof(struct stat))
-
+#define ktrabstimespec(p, s) \
+ ktrstruct((p), "abstimespec", (s), sizeof(struct timespec))
+#define ktrreltimespec(p, s) \
+ ktrstruct((p), "reltimespec", (s), sizeof(struct timespec))
+#define ktrabstimeval(p, s) \
+ ktrstruct((p), "abstimeval", (s), sizeof(struct timeval))
+#define ktrreltimeval(p, s) \
+ ktrstruct((p), "reltimeval", (s), sizeof(struct timeval))
+#define ktrsigaction(p, s) \
+ ktrstruct((p), "sigaction", (s), sizeof(struct sigaction))
+#define ktrrlimit(p, s) \
+ ktrstruct((p), "rlimit", (s), sizeof(struct rlimit))
#endif /* !_KERNEL */