diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2015-07-28 05:50:42 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2015-07-28 05:50:42 +0000 |
commit | c67cae83f2d2195755c878f06167e62029d2a77f (patch) | |
tree | 833656cb8e5b61190028d305b8a5f6d8fbce5507 /sys/kern | |
parent | de3cec76aeca2ff758e9d4bfea9a37dd66130bb1 (diff) |
Add ktracing of structs iovec, msghdr, and cmsghdr for {,p}{read,write}v(),
sendmsg(), and recvmsg(). For cmsghdr, the len, level, and type are always
shown, and for SOL_SOCKET,SCM_RIGHTS the fd numbers being passed are shown.
ok millert@ deraadt@
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/sys_generic.c | 10 | ||||
-rw-r--r-- | sys/kern/uipc_syscalls.c | 26 |
2 files changed, 34 insertions, 2 deletions
diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c index b6752bb5c40..d1c89d52c98 100644 --- a/sys/kern/sys_generic.c +++ b/sys/kern/sys_generic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_generic.c,v 1.99 2015/07/19 02:35:35 deraadt Exp $ */ +/* $OpenBSD: sys_generic.c,v 1.100 2015/07/28 05:50:41 guenther Exp $ */ /* $NetBSD: sys_generic.c,v 1.24 1996/03/29 00:25:32 cgd Exp $ */ /* @@ -161,6 +161,10 @@ dofilereadv(struct proc *p, int fd, struct file *fp, const struct iovec *iovp, } if ((error = copyin(iovp, iov, iovlen))) goto done; +#ifdef KTRACE + if (KTRPOINT(p, KTR_STRUCT)) + ktriovec(p, iov, iovcnt); +#endif } else { iov = (struct iovec *)iovp; /* de-constify */ } @@ -309,6 +313,10 @@ dofilewritev(struct proc *p, int fd, struct file *fp, const struct iovec *iovp, } if ((error = copyin(iovp, iov, iovlen))) goto done; +#ifdef KTRACE + if (KTRPOINT(p, KTR_STRUCT)) + ktriovec(p, iov, iovcnt); +#endif } else { iov = (struct iovec *)iovp; /* de-constify */ } diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index 74ae41e2910..9b785a06559 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_syscalls.c,v 1.105 2015/07/27 04:01:51 guenther Exp $ */ +/* $OpenBSD: uipc_syscalls.c,v 1.106 2015/07/28 05:50:41 guenther Exp $ */ /* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */ /* @@ -494,6 +494,10 @@ sys_sendmsg(struct proc *p, void *v, register_t *retval) error = copyin(SCARG(uap, msg), &msg, sizeof (msg)); if (error) return (error); +#ifdef KTRACE + if (KTRPOINT(p, KTR_STRUCT)) + ktrmsghdr(p, &msg); +#endif if (tame_sendto_check(p, msg.msg_name)) return (tame_fail(p, EPERM, _TM_UNIX)); @@ -509,6 +513,10 @@ sys_sendmsg(struct proc *p, void *v, register_t *retval) (error = copyin(msg.msg_iov, iov, (unsigned)(msg.msg_iovlen * sizeof (struct iovec))))) goto done; +#ifdef KTRACE + if (msg.msg_iovlen && KTRPOINT(p, KTR_STRUCT)) + ktriovec(p, iov, msg.msg_iovlen); +#endif msg.msg_iov = iov; msg.msg_flags = 0; error = sendit(p, SCARG(uap, s), &msg, SCARG(uap, flags), retval); @@ -572,6 +580,11 @@ sendit(struct proc *p, int s, struct msghdr *mp, int flags, register_t *retsize) mp->msg_controllen, MT_CONTROL); if (error) goto bad; +#ifdef KTRACE + if (KTRPOINT(p, KTR_STRUCT) && mp->msg_controllen) + ktrcmsghdr(p, mtod(control, char *), + mp->msg_controllen); +#endif if (tame_cmsg_send(p, control, mp->msg_controllen)) { m_free(control); @@ -689,6 +702,13 @@ sys_recvmsg(struct proc *p, void *v, register_t *retval) msg.msg_iov = iov; if ((error = recvit(p, SCARG(uap, s), &msg, NULL, retval)) == 0) { msg.msg_iov = uiov; +#ifdef KTRACE + if (KTRPOINT(p, KTR_STRUCT)) { + ktrmsghdr(p, &msg); + if (msg.msg_iovlen) + ktriovec(p, iov, msg.msg_iovlen); + } +#endif error = copyout(&msg, SCARG(uap, msg), sizeof(msg)); } done: @@ -790,6 +810,10 @@ recvit(struct proc *p, int s, struct msghdr *mp, caddr_t namelenp, struct mbuf *m = control; caddr_t cp = mp->msg_control; +#ifdef KTRACE + if (KTRPOINT(p, KTR_STRUCT) && len) + ktrcmsghdr(p, mtod(control, char *), len); +#endif do { i = m->m_len; if (len < i) { |