diff options
author | jistone <jistone> | 2007-02-07 02:54:30 +0000 |
---|---|---|
committer | jistone <jistone> | 2007-02-07 02:54:30 +0000 |
commit | b8772cce090adb3d27cdd8b49d236662b526424e (patch) | |
tree | f216b71b2bea50d0bd95c9d22956a07e0b6fa49c /tapset/socket.stp | |
parent | 3b4136ca14c78881c50e8c36fa35fa574edaabb4 (diff) | |
download | systemtap-steved-b8772cce090adb3d27cdd8b49d236662b526424e.tar.gz systemtap-steved-b8772cce090adb3d27cdd8b49d236662b526424e.tar.xz systemtap-steved-b8772cce090adb3d27cdd8b49d236662b526424e.zip |
2007-02-06 Josh Stone <joshua.i.stone@intel.com>
* 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 (<many functions>): 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.
Diffstat (limited to 'tapset/socket.stp')
-rw-r--r-- | tapset/socket.stp | 163 |
1 files changed, 47 insertions, 116 deletions
diff --git a/tapset/socket.stp b/tapset/socket.stp index 451dd36e..58732185 100644 --- a/tapset/socket.stp +++ b/tapset/socket.stp @@ -513,17 +513,18 @@ function sock_flags_num2str:string (flags:long) #define SOCK_PASSSEC 4 /* introduced in 2.6.18 */ #endif char str[60]; + unsigned long flags = THIS->flags; str[0] = '\0'; - if (test_bit (SOCK_ASYNC_NOSPACE, &THIS->flags)) + if (test_bit (SOCK_ASYNC_NOSPACE, &flags)) strcat (str, "ASYNC_NOSPACE|"); - if (test_bit (SOCK_ASYNC_WAITDATA, &THIS->flags)) + if (test_bit (SOCK_ASYNC_WAITDATA, &flags)) strcat (str, "ASYNC_WAITDATA|"); - if (test_bit (SOCK_NOSPACE, &THIS->flags)) + if (test_bit (SOCK_NOSPACE, &flags)) strcat (str, "NOSPACE|"); - if (test_bit (SOCK_PASSCRED, &THIS->flags)) + if (test_bit (SOCK_PASSCRED, &flags)) strcat (str, "PASSCRED|"); - if (test_bit (SOCK_PASSSEC, &THIS->flags)) + if (test_bit (SOCK_PASSSEC, &flags)) strcat (str, "PASSSEC|"); if (str[0] != '\0') str[strlen(str)-1] = '\0'; strlcpy (THIS->__retvalue, str, MAXSTRINGLEN); @@ -938,147 +939,77 @@ function _success_check(ret:long) function _get_sock_addr:long (file:long) %{ - struct socket *sockp; - struct file *filep; - - filep = (struct file *) deref (sizeof(struct file *), &(THIS->file)); - if (filep == NULL) { + struct file *filep = (struct file *)(long)(THIS->file); + struct socket *sockp = filep? kread(&(filep->private_data)) : NULL; + if (sockp == NULL) THIS->__retvalue = -1; - goto end; - } - sockp = (struct socket *) deref (sizeof(filep->private_data), - &(filep->private_data)); - if (sockp == NULL) { - THIS->__retvalue = -1; - goto end; - } - THIS->__retvalue = (long) sockp; - - if (0) { -deref_fault: - CONTEXT->last_error = "pointer dereference fault"; - } -end: ; + else + THIS->__retvalue = (long) sockp; + CATCH_DEREF_FAULT(); %} function _get_sock_size:long (iov:long, nr_segs:long) %{ - struct iovec *iovp; - long size = 0; - int i; - - iovp = (struct iovec *) deref (sizeof(struct iov *), &(THIS->iov)); - if (iovp == NULL) { + struct iovec *iovp = (struct iovec *)(long)(THIS->iov); + if (iovp == NULL) THIS->__retvalue = -1; - goto end; - } - - for (i = 0 ; i < THIS->nr_segs ; i++) - size += iovp[i].iov_len; - - THIS->__retvalue = size; - - if (0) { -deref_fault: - CONTEXT->last_error = "pointer dereference fault"; + else { + int i; + THIS->__retvalue = 0; + for (i = 0 ; i < THIS->nr_segs ; i++) + THIS->__retvalue += kread(&(iovp[i].iov_len)); } -end: ; + CATCH_DEREF_FAULT(); %} function _sock_prot_num:long (sock:long) %{ - struct socket *sktp; - struct sock *skp; - - sktp = (struct socket *) deref (sizeof (struct socket *), &(THIS->sock)); - if (sktp == NULL) { - THIS->__retvalue = -1; - goto end; - } - skp = (struct sock *) deref (sizeof (sktp->sk), &(sktp->sk)); - if (skp == NULL) { + struct socket *sktp = (struct socket *)(long)(THIS->sock); + struct sock *skp = sktp? kread(&(sktp->sk)) : NULL; + if (skp == NULL) THIS->__retvalue = -1; - goto end; - } - THIS->__retvalue = (long) skp->sk_protocol; - - if (0) { -deref_fault: - CONTEXT->last_error = "pointer dereference fault"; - } -end: ; + else + THIS->__retvalue = kread(&(skp->sk_protocol)); + CATCH_DEREF_FAULT(); %} function _sock_fam_num:long (sock:long) %{ - struct socket *sockp; - struct proto_ops *ops; - - sockp = (struct socket *) deref (sizeof (struct socket *), &(THIS->sock)); - if (sockp == NULL) { + struct socket *sockp = (struct socket *)(long)(THIS->sock); + const struct proto_ops *ops = sockp? kread(&(sockp->ops)) : NULL; + if (ops == NULL) THIS->__retvalue = -1; - goto end; - } - ops = (struct proto_ops *) deref (sizeof (sockp->ops), &(sockp->ops)); - if (ops == NULL) { - THIS->__retvalue = -1; - goto end; - } - THIS->__retvalue = (long) ops->family; - if (0) { -deref_fault: - CONTEXT->last_error = "pointer dereference fault"; - } -end: ; + else + THIS->__retvalue = kread(&(ops->family)); + CATCH_DEREF_FAULT(); %} function _sock_state_num:long (sock:long) %{ - struct socket *sockp; - - sockp = (struct socket *) deref (sizeof (struct sock *), &(THIS->sock)); - if (sockp == NULL) { + struct socket *sockp = (struct socket *)(long)(THIS->sock); + if (sockp == NULL) THIS->__retvalue = -1; - goto end; - } - THIS->__retvalue = sockp->state; - if (0) { -deref_fault: - CONTEXT->last_error = "pointer dereference fault"; - } -end: ; + else + THIS->__retvalue = kread(&(sockp->state)); + CATCH_DEREF_FAULT(); %} function _sock_type_num:long (sock:long) %{ - struct socket *sockp; - - sockp = (struct socket *) deref (sizeof(struct socket *), &(THIS->sock)); - if (sockp == NULL) { + struct socket *sockp = (struct socket *)(long)(THIS->sock); + if (sockp == NULL) THIS->__retvalue = -1; - goto end; - } - THIS->__retvalue = (long) sockp->type; - if (0) { -deref_fault: - CONTEXT->last_error = "pointer dereference fault"; - } -end: ; + else + THIS->__retvalue = kread(&(sockp->type)); + CATCH_DEREF_FAULT(); %} function _sock_flags_num:long (sock:long) %{ - struct socket *sockp; - - sockp = (struct socket *) deref (sizeof(struct socket *), &(THIS->sock)); - if (sockp == NULL) { + struct socket *sockp = (struct socket *)(long)(THIS->sock); + if (sockp == NULL) THIS->__retvalue = -1; - goto end; - } - THIS->__retvalue = sockp->flags; - if (0) { -deref_fault: - CONTEXT->last_error = "pointer dereference fault"; - } -end: ; + else + THIS->__retvalue = kread(&(sockp->flags)); + CATCH_DEREF_FAULT(); %} |