From b8772cce090adb3d27cdd8b49d236662b526424e Mon Sep 17 00:00:00 2001 From: jistone Date: Wed, 7 Feb 2007 02:54:30 +0000 Subject: 2007-02-06 Josh Stone * aux_syscalls.stp, inet_sock.stp, ioblock.stp, ioscheduler.stp, nfs.stp, nfs_proc.stp, nfsd.stp, rpc.stp, scsi.stp, signal.stp, socket.stp, task.stp, tcp.stp, vfs.stp: Protect pointer dereferences with kread wherever possible. Some places still have hazards, as marked with FIXMEs. * errno.stp (returnstr): Don't use return in tapset C functions. * aux_syscalls.stp (__uget_timex_m): Ditto. * nfsd.stp (__get_fh): Ditto. * nfs.stp, vfs.stp (): Ditto. * string.stp (substr): Ditto. Also make sure start index is valid. * syscalls.stp (syscall.execve): Change __string to kernel_string. LKET/ * nfs.stp, nfs_proc.stp, nfsd.stp, process.stp, tskdispatch.stp: Protect pointer dereferences with kread wherever possible. Some places still have hazards, as marked with FIXMEs. * aio.stp (log_io_getevents): Don't use return in tapset C functions. * timestamp.stp (set_timing_method): Ditto. * utils.stp (filter_by_pid): Ditto. --- tapset/nfsd.stp | 57 +++++++++++++++++---------------------------------------- 1 file changed, 17 insertions(+), 40 deletions(-) (limited to 'tapset/nfsd.stp') diff --git a/tapset/nfsd.stp b/tapset/nfsd.stp index 8d8a09a0..49f04f51 100644 --- a/tapset/nfsd.stp +++ b/tapset/nfsd.stp @@ -6,26 +6,6 @@ #include %} -%{ -/*Get file handle from struct svc_fh */ -char * fh_fmt(struct svc_fh * fhp) -{ - struct knfsd_fh *fh = &fhp->fh_handle; - - static char buf[80]; - sprintf(buf, "%d: %08x %08x %08x %08x %08x %08x", - fh->fh_size, - fh->fh_base.fh_pad[0], - fh->fh_base.fh_pad[1], - fh->fh_base.fh_pad[2], - fh->fh_base.fh_pad[3], - fh->fh_base.fh_pad[4], - fh->fh_base.fh_pad[5]); - return buf; -} - -%} - /* *1 : nfsd.proc2.lookup *2 : nfsd.proc3.lookup @@ -61,7 +41,6 @@ function __get_fh:long(argp:long,index:long) %{ /* pure */ struct nfsd_renameargs *argpren = NULL; struct nfsd3_renameargs *argpren3 = NULL; struct svc_fh * fhp = NULL; - char * buf; switch(index) { @@ -112,32 +91,30 @@ function __get_fh:long(argp:long,index:long) %{ /* pure */ break; } - if(fhp == NULL) - { - _stp_printf("the fhp is NULL"); - return; - } - else - { - /* buf = fh_fmt(fhp); - strlcpy (THIS->__retvalue,buf,80);*/ - THIS->__retvalue = (long)fhp; - } + THIS->__retvalue = (long)fhp; %} -/*Get file handler from struct svc_fh , it will call -fh_fmt function*/ +/*Get file handler from struct svc_fh */ function __svc_fh:string(fh :long) %{ /* pure */ - struct svc_fh * fhp = (struct svc_fh *) (THIS->fh); - char * buf ; - - buf = fh_fmt(fhp); - strlcpy (THIS->__retvalue,buf,80); + struct svc_fh * fhp = (struct svc_fh *) (long)(THIS->fh); + struct knfsd_fh *fh = &fhp->fh_handle; + + snprintf(THIS->__retvalue, MAXSTRINGLEN, + "%d: %08x %08x %08x %08x %08x %08x", + kread(&(fh->fh_size)), + kread(&(fh->fh_base.fh_pad[0])), + kread(&(fh->fh_base.fh_pad[1])), + kread(&(fh->fh_base.fh_pad[2])), + kread(&(fh->fh_base.fh_pad[3])), + kread(&(fh->fh_base.fh_pad[4])), + kread(&(fh->fh_base.fh_pad[5]))) + CATCH_DEREF_FAULT(); %} function p_long:long(cnt:long) %{ /* pure */ unsigned long * count = (unsigned long *)((long)THIS->cnt); - THIS->__retvalue = *count; + THIS->__retvalue = kread(count); + CATCH_DEREF_FAULT(); %} /* *probe nfsd.dispatch -- cgit