Make sure syscall arguments properly aligned in ktrace records.

Make syscall return value a register_t.

Based on a patch from Hidetoshi Shimokawa.
Mostly reviewed by:	Hidetoshi Shimokawa and Bruce Evans.
This commit is contained in:
Dmitrij Tejblum 1999-06-16 18:37:01 +00:00
parent 233d9cfce2
commit 71ddfdbbd5
2 changed files with 18 additions and 11 deletions

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)kern_ktrace.c 8.2 (Berkeley) 9/23/93
* $Id: kern_ktrace.c,v 1.25 1998/12/10 01:47:41 rvb Exp $
* $Id: kern_ktrace.c,v 1.26 1999/04/28 11:36:55 phk Exp $
*/
#include "opt_ktrace.h"
@ -49,6 +49,8 @@
#include <sys/malloc.h>
#include <sys/syslog.h>
#include <stddef.h>
static MALLOC_DEFINE(M_KTRACE, "KTRACE", "KTRACE");
#ifdef KTRACE
@ -78,20 +80,23 @@ ktrgetheader(type)
void
ktrsyscall(vp, code, narg, args)
struct vnode *vp;
int code, narg, args[];
int code, narg;
register_t args[];
{
struct ktr_header *kth;
struct ktr_syscall *ktp;
register int len = sizeof(struct ktr_syscall) + (narg * sizeof(int));
register int len = offsetof(struct ktr_syscall, ktr_args) +
(narg * sizeof(register_t));
struct proc *p = curproc; /* XXX */
int *argp, i;
register_t *argp;
int i;
p->p_traceflag |= KTRFAC_ACTIVE;
kth = ktrgetheader(KTR_SYSCALL);
MALLOC(ktp, struct ktr_syscall *, len, M_KTRACE, M_WAITOK);
ktp->ktr_code = code;
ktp->ktr_narg = narg;
argp = (int *)((char *)ktp + sizeof(struct ktr_syscall));
argp = &ktp->ktr_args[0];
for (i = 0; i < narg; i++)
*argp++ = args[i];
kth->ktr_buf = (caddr_t)ktp;
@ -105,7 +110,8 @@ ktrsyscall(vp, code, narg, args)
void
ktrsysret(vp, code, error, retval)
struct vnode *vp;
int code, error, retval;
int code, error;
register_t retval;
{
struct ktr_header *kth;
struct ktr_sysret ktp;

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)ktrace.h 8.1 (Berkeley) 6/2/93
* $Id: ktrace.h,v 1.12 1997/02/22 09:45:26 peter Exp $
* $Id: ktrace.h,v 1.13 1999/05/13 09:09:37 bde Exp $
*/
#ifndef _SYS_KTRACE_H_
@ -79,8 +79,9 @@ struct ktr_syscall {
short ktr_code; /* syscall number */
short ktr_narg; /* number of arguments */
/*
* followed by ktr_narg ints
* followed by ktr_narg register_t
*/
register_t ktr_args[1];
};
/*
@ -91,7 +92,7 @@ struct ktr_sysret {
short ktr_code;
short ktr_eosys;
int ktr_error;
int ktr_retval;
register_t ktr_retval;
};
/*
@ -160,8 +161,8 @@ void ktrnamei __P((struct vnode *,char *));
void ktrcsw __P((struct vnode *,int,int));
void ktrpsig __P((struct vnode *,int, sig_t, int, int));
void ktrgenio __P((struct vnode *,int, enum uio_rw,struct iovec *,int,int));
void ktrsyscall __P((struct vnode *, int, int narg, int args[]));
void ktrsysret __P((struct vnode *, int, int, int));
void ktrsyscall __P((struct vnode *, int, int narg, register_t args[]));
void ktrsysret __P((struct vnode *, int, int, register_t));
#else /* KERNEL */