From c4c1558bbb72f56307d70661ac125544f1b88ffd Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 20 May 2008 00:12:25 +0200 Subject: PR6524: ctime() on bad values hangs system. --- tapset/ChangeLog | 5 +++++ tapset/ctime.stp | 39 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) (limited to 'tapset') diff --git a/tapset/ChangeLog b/tapset/ChangeLog index 70d75b83..62084ad3 100644 --- a/tapset/ChangeLog +++ b/tapset/ChangeLog @@ -1,3 +1,8 @@ +2008-05-19 Mark Wielaard + + PR6524 + * ctime.stp: Don't try to convert values that won't fit in 32bits. + 2008-05-08 Ananth N Mavinakayanahalli PR 5231 diff --git a/tapset/ctime.stp b/tapset/ctime.stp index cd8e5026..96af4d47 100644 --- a/tapset/ctime.stp +++ b/tapset/ctime.stp @@ -4,7 +4,23 @@ * Takes an argument of seconds since the epoch as returned by * gettimeofday_s(). Returns a string of the form * - * "Wed Jun 30 21:49:008 1993" + * "Wed Jun 30 21:49:08 1993" + * + * The string will always be exactly 24 characters. If the time would + * be unreasonable far in the past (before what can be represented + * with a 32 bit offset in seconds from the epoch) the returned string + * will be "a long, long time ago...". If the time would be + * unreasonable far in the future the returned string will be "far far + * in the future..." (both these strings are also 24 characters wide). + * + * Note that the epoch (zero) corresponds to + * + * "Thu Jan 1 00:00:00 1970" + * + * The earliest full date given by ctime, corresponding to epochsecs + * -2147483648 is "Fri Dec 13 20:45:52 1901". The latest full date + * given by ctime, corresponding to epachsecs 2147483647 is + * "Tue Jan 19 03:14:07 2038". * * The abbreviations for the days of the week are ‘Sun’, ‘Mon’, ‘Tue’, * ‘Wed’, ‘Thu’, ‘Fri’, and ‘Sat’. The abbreviations for the months @@ -21,7 +37,7 @@ * tzcode maintained by Arthur David Olson. In newlib, asctime_r.c * doesn't have any author/copyright information. * - * Changes copyright (C) 2006 Red Hat Inc. + * Changes copyright (C) 2006, 2008 Red Hat Inc. */ function ctime:string(epochsecs:long) @@ -70,6 +86,25 @@ function ctime:string(epochsecs:long) int tm_year; /* year */ int tm_wday; /* day of the week */ + // Check that the numer of seconds is "reasonable". + // Otherwise (especially on 64bit machines) we will be spending + // way too much time calculating the correct year, month and + // day. Also we would like the returned string to always be 24 chars. + // So cap to what can be represented normally on a 32bit machine. + int64_t MAX_POS_SECS = 2147483647LL; + int64_t MIN_NEG_SECS = -2147483648LL; + + if (THIS->epochsecs > MAX_POS_SECS) + { + strlcpy(THIS->__retvalue, "far far in the future...", MAXSTRINGLEN); + return; + } + if (THIS->epochsecs < MIN_NEG_SECS) + { + strlcpy(THIS->__retvalue, "a long, long time ago...", MAXSTRINGLEN); + return; + } + lcltime = THIS->epochsecs; days = ((long)lcltime) / SECSPERDAY; -- cgit From fc5a2d42b6cc46a9d4f7f3919ddc74ce70ad2a66 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 20 May 2008 21:58:04 +0200 Subject: PR5001: Remove _stp_ctime and always use ctime. --- tapset/ChangeLog | 15 ++++++- tapset/aux_syscalls.stp | 112 ++++++++++++++++++++++++------------------------ tapset/syscalls2.stp | 12 ++++-- 3 files changed, 78 insertions(+), 61 deletions(-) (limited to 'tapset') diff --git a/tapset/ChangeLog b/tapset/ChangeLog index 62084ad3..a0f14ded 100644 --- a/tapset/ChangeLog +++ b/tapset/ChangeLog @@ -1,6 +1,19 @@ +2008-05-20 Mark Wielaard + + PR 5001 + * aux_syscalls.stp (_stp_ctime): Removed. + (_struct_utimbuf_u): Removed. + (_struct_compat_utimbuf_u): Removed. + (_struct_utimbuf_actime): New function. + (_struct_utimbuf_modtime): New function. + (_struct_compat_utimbuf_actime): New function. + (_struct_compat_utimbuf_modtime): New function. + * syscalls2.stp (syscall.utime): Use new functions and ctime. + (syscall.compat_utime): Likewise. + 2008-05-19 Mark Wielaard - PR6524 + PR 6524 * ctime.stp: Don't try to convert values that won't fit in 32bits. 2008-05-08 Ananth N Mavinakayanahalli diff --git a/tapset/aux_syscalls.stp b/tapset/aux_syscalls.stp index da72a7ff..ec7fdcb0 100644 --- a/tapset/aux_syscalls.stp +++ b/tapset/aux_syscalls.stp @@ -60,77 +60,77 @@ function _struct_timezone_u:string(uaddr:long) %} %{ -static const int days_in_month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; -static void _stp_ctime(time_t t, char *buf, int buflen) -{ - int mon=1, day, hour, min, sec, num, d, year = 1970; - - sec = t % 60; - min = t/60 % 60; - hour = t/(60*60) % 24; - day = t/(24*60*60); - - while(1) { - d = (!(year % 4) && ((year % 100) || !(year % 400))) ? 366 : 365; - if (day >= d) - day -= d; - else - break; - year++; - } - while (mon < 12) { - num = days_in_month[mon-1]; - if (mon == 2 && d == 366) - num++; - if (day >= num) - day -= num; - else - break; - mon++; - } - - snprintf(buf, buflen, "%4d/%02d/%02d-%02d:%02d:%02d", year, mon, day+1, hour, min, sec); - buf[buflen-1] = 0; -} + // Needed for the following four functions + // _struct_utimbuf_actime, _struct_utimbuf_modtime, + // _struct_compat_utimbuf_actime, _struct_compat_utimbuf_modtime + #include %} -function _struct_utimbuf_u:string(uaddr:long) +// Returns the value of the actime field of a utimbuf in user space +// at the given address, or zero on when userspace data is not accessible. +function _struct_utimbuf_actime:long(uaddr:long) %{ /* pure */ - #include struct utimbuf ubuf; - static char abuf[24], mbuf[24]; char *ptr = (char *)(unsigned long)THIS->uaddr; if (ptr == NULL) - strlcpy (THIS->__retvalue, "NULL", MAXSTRINGLEN); - else { - if(_stp_copy_from_user((char*)&ubuf,ptr,sizeof(ubuf)) == 0) { - _stp_ctime(ubuf.actime, abuf, 24); - _stp_ctime(ubuf.modtime, mbuf, 24); - snprintf(THIS->__retvalue, MAXSTRINGLEN, "[%s, %s]", abuf, mbuf); - } else - strlcpy (THIS->__retvalue, "UNKNOWN", MAXSTRINGLEN); - } + THIS->__retvalue = 0; + else + if(_stp_copy_from_user((char*)&ubuf,ptr,sizeof(ubuf)) == 0) + THIS->__retvalue = ubuf.actime; + else + THIS->__retvalue = 0; %} -function _struct_compat_utimbuf_u:string(uaddr:long) +// Returns the value of the modtime field of a utimbuf in user space +// at the given address, or zero on when userspace data is not accessible. +function _struct_utimbuf_modtime:long(uaddr:long) +%{ /* pure */ + struct utimbuf ubuf; + char *ptr = (char *)(unsigned long)THIS->uaddr; + + if (ptr == NULL) + THIS->__retvalue = 0; + else + if(_stp_copy_from_user((char*)&ubuf,ptr,sizeof(ubuf)) == 0) + THIS->__retvalue = ubuf.modtime; + else + THIS->__retvalue = 0; +%} + +// Returns the value of the actime field of a compat_utimbuf in user space +// at the given address, or zero on when userspace data is not accessible. +function _struct_compat_utimbuf_actime:long(uaddr:long) %{ /* pure */ #ifdef CONFIG_COMPAT - #include struct compat_utimbuf ubuf; - static char abuf[24], mbuf[24]; char *ptr = (char *)(unsigned long)THIS->uaddr; if (ptr == NULL) - strlcpy (THIS->__retvalue, "NULL", MAXSTRINGLEN); - else { - if(_stp_copy_from_user((char*)&ubuf,ptr,sizeof(ubuf)) == 0) { - _stp_ctime(ubuf.actime, abuf, 24); - _stp_ctime(ubuf.modtime, mbuf, 24); - snprintf(THIS->__retvalue, MAXSTRINGLEN, "[%s, %s]", abuf, mbuf); - } else - strlcpy (THIS->__retvalue, "UNKNOWN", MAXSTRINGLEN); - } + THIS->__retvalue = 0; + else + if(_stp_copy_from_user((char*)&ubuf,ptr,sizeof(ubuf)) == 0) + THIS->__retvalue = ubuf.actime; + else + THIS->__retvalue = 0; +#endif +%} + +// Returns the value of the modtime field of a compat_utimbuf in user space +// at the given address, or zero on when userspace data is not accessible. +function _struct_compat_utimbuf_modtime:long(uaddr:long) +%{ /* pure */ +#ifdef CONFIG_COMPAT + struct compat_utimbuf ubuf; + char *ptr = (char *)(unsigned long)THIS->uaddr; + + if (ptr == NULL) + THIS->__retvalue = 0; + else + if(_stp_copy_from_user((char*)&ubuf,ptr,sizeof(ubuf)) == 0) + THIS->__retvalue = ubuf.modtime; + else + THIS->__retvalue = 0; #endif %} diff --git a/tapset/syscalls2.stp b/tapset/syscalls2.stp index 558e89bb..31e1830d 100644 --- a/tapset/syscalls2.stp +++ b/tapset/syscalls2.stp @@ -2900,8 +2900,10 @@ probe syscall.utime = kernel.function("sys_utime") ? { filename_uaddr = $filename filename = user_string($filename) buf_uaddr = $times - buf_str = _struct_utimbuf_u($times) - argstr = sprintf("%s, %s", user_string_quoted($filename), buf_str) + actime = _struct_utimbuf_actime(buf_uaddr) + modtime = _struct_utimbuf_modtime(buf_uaddr) + argstr = sprintf("%s, [%s, %s]", user_string_quoted($filename), + ctime(actime), ctime(modtime)) } probe syscall.utime.return = kernel.function("sys_utime").return ? { name = "utime" @@ -2914,8 +2916,10 @@ probe syscall.compat_utime = kernel.function("compat_sys_utime") ? { filename_uaddr = $filename filename = user_string($filename) buf_uaddr = $t - buf_str = _struct_compat_utimbuf_u($t) - argstr = sprintf("%s, %s", user_string_quoted($filename), _struct_compat_utimbuf_u($t)) + actime = _struct_compat_utimbuf_actime(buf_uaddr) + modtime = _struct_compat_utimbuf_modtime(buf_uaddr) + argstr = sprintf("%s, [%s, %s]", user_string_quoted($filename), + ctime(actime), ctime(modtime)) } probe syscall.compat_utime.return = kernel.function("compat_sys_utime").return ? { name = "utime" -- cgit From cf96be783e89607e1b8b755bbd08ba41b564c4fc Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Tue, 20 May 2008 18:33:38 -0400 Subject: PR6538: tapset changes --- tapset/ChangeLog | 8 ++++++++ tapset/signal.stp | 4 ++-- tapset/syscalls2.stp | 2 +- tapset/vfs.stp | 14 ++++---------- tapset/x86_64/syscalls.stp | 2 +- 5 files changed, 16 insertions(+), 14 deletions(-) (limited to 'tapset') diff --git a/tapset/ChangeLog b/tapset/ChangeLog index a0f14ded..3afc7aa3 100644 --- a/tapset/ChangeLog +++ b/tapset/ChangeLog @@ -1,3 +1,11 @@ +2008-05-20 Frank Ch. Eigler + + PR 6538 + * signal.stp (_signal.send.part[23]): Initialize dummy sinfo. + * syscalls2.stp (syscall.compat_sys_semtimedop): Fix sops_uaddr. + * vfs.stp (__find_bdevname): Rewrite. + * x86_64/syscalls.stp (syscall.pipe32): Fix argstr. + 2008-05-20 Mark Wielaard PR 5001 diff --git a/tapset/signal.stp b/tapset/signal.stp index ec947eb7..72ba9520 100644 --- a/tapset/signal.stp +++ b/tapset/signal.stp @@ -63,7 +63,7 @@ probe _signal.send.part2 = kernel.function("send_group_sigqueue") { name = "send_group_sigqueue" task = $p - # sinfo = $q->info + sinfo = 0 # $q->info shared = 1 send2queue = 1 } @@ -72,7 +72,7 @@ probe _signal.send.part3 = kernel.function("send_sigqueue") { name = "send_sigqueue" task = $p - # sinfo = $q->info + sinfo = 0 # $q->info shared = 0 send2queue = 1 } diff --git a/tapset/syscalls2.stp b/tapset/syscalls2.stp index 31e1830d..344396f4 100644 --- a/tapset/syscalls2.stp +++ b/tapset/syscalls2.stp @@ -1364,7 +1364,7 @@ probe syscall.semtimedop.return = kernel.function("sys_semtimedop").return ? { probe syscall.compat_sys_semtimedop = kernel.function("compat_sys_semtimedop") ? { name = "compat_sys_semtimedop" semid = $semid - sops_uaddr = tsems + sops_uaddr = $tsems nsops = $nsops timeout_uaddr = $timeout argstr = sprintf("%d, %p, %d, %s", $semid, $tsems, $nsops, diff --git a/tapset/vfs.stp b/tapset/vfs.stp index 75b1b279..6073dffc 100644 --- a/tapset/vfs.stp +++ b/tapset/vfs.stp @@ -33,16 +33,10 @@ function __bdevname:string (bdev:long) %{ /* pure */ global __devnames function __find_bdevname:string(dev:long, bdev:long) { -# return "" - - __devname = __devnames[dev] - - if (__devname != null) - return __devname - - __devname = __devnames[dev] = __bdevname(bdev) - - return __devname + if (dev in __devnames) + return __devnames[dev] + else + return __devnames[dev] = __bdevname(bdev) } function ppos_pos:long (ppos:long) %{ /* pure */ diff --git a/tapset/x86_64/syscalls.stp b/tapset/x86_64/syscalls.stp index 418aaf23..c9ab617f 100644 --- a/tapset/x86_64/syscalls.stp +++ b/tapset/x86_64/syscalls.stp @@ -131,7 +131,7 @@ probe syscall.vm86_warning.return = kernel.function("sys32_vm86_warning").return # probe syscall.pipe32 = kernel.function("sys32_pipe") { name = "pipe" - argstr = sprintf("%p", fd) + argstr = sprintf("%p", $fd) } probe syscall.pipe32.return = kernel.function("sys32_pipe").return { name = "pipe" -- cgit From e483d9dfa614ee17b488df7224ee22a0f7dc9386 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Wed, 21 May 2008 16:12:17 +0200 Subject: Use pointer_arg to fetch arguments for syscall.utime and compat_utime. --- tapset/ChangeLog | 5 +++++ tapset/syscalls2.stp | 16 ++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'tapset') diff --git a/tapset/ChangeLog b/tapset/ChangeLog index a0f14ded..2c4ba4da 100644 --- a/tapset/ChangeLog +++ b/tapset/ChangeLog @@ -1,3 +1,8 @@ +2008-05-21 Mark Wielaard + + * syscalls2.stp (syscall.utime): Use pointer_arg to fetch arguments. + (syscall.compat_utime): Likewise. + 2008-05-20 Mark Wielaard PR 5001 diff --git a/tapset/syscalls2.stp b/tapset/syscalls2.stp index 31e1830d..81d5f973 100644 --- a/tapset/syscalls2.stp +++ b/tapset/syscalls2.stp @@ -2897,12 +2897,12 @@ probe syscall.ustat.return = # long sys_utime(char __user * filename, struct utimbuf __user * times) probe syscall.utime = kernel.function("sys_utime") ? { name = "utime" - filename_uaddr = $filename - filename = user_string($filename) - buf_uaddr = $times + filename_uaddr = pointer_arg(1) + filename = user_string_quoted(filename_uaddr) + buf_uaddr = pointer_arg(2) actime = _struct_utimbuf_actime(buf_uaddr) modtime = _struct_utimbuf_modtime(buf_uaddr) - argstr = sprintf("%s, [%s, %s]", user_string_quoted($filename), + argstr = sprintf("%s, [%s, %s]", filename, ctime(actime), ctime(modtime)) } probe syscall.utime.return = kernel.function("sys_utime").return ? { @@ -2913,12 +2913,12 @@ probe syscall.utime.return = kernel.function("sys_utime").return ? { # long compat_sys_utime(char __user *filename, struct compat_utimbuf __user *t) probe syscall.compat_utime = kernel.function("compat_sys_utime") ? { name = "utime" - filename_uaddr = $filename - filename = user_string($filename) - buf_uaddr = $t + filename_uaddr = pointer_arg(1) + filename = user_string_quoted(filename_uaddr) + buf_uaddr = pointer_arg(2) actime = _struct_compat_utimbuf_actime(buf_uaddr) modtime = _struct_compat_utimbuf_modtime(buf_uaddr) - argstr = sprintf("%s, [%s, %s]", user_string_quoted($filename), + argstr = sprintf("%s, [%s, %s]", filename, ctime(actime), ctime(modtime)) } probe syscall.compat_utime.return = kernel.function("compat_sys_utime").return ? { -- cgit From 4bdb135a1d011fa8510462e33e09e11316cba9f0 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Wed, 21 May 2008 12:15:02 -0400 Subject: PR6538: more tapset fixes --- tapset/ChangeLog | 5 +++++ tapset/nfs.stp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'tapset') diff --git a/tapset/ChangeLog b/tapset/ChangeLog index 75baad0a..4b37471c 100644 --- a/tapset/ChangeLog +++ b/tapset/ChangeLog @@ -1,3 +1,8 @@ +2008-05-21 Frank Ch. Eigler + + PR 6538 + * nfs.stp (nfs.aop.readpage): Fix rsize. + 2008-05-20 Frank Ch. Eigler PR 6538 diff --git a/tapset/nfs.stp b/tapset/nfs.stp index 87a2f4cc..ba6bde5f 100644 --- a/tapset/nfs.stp +++ b/tapset/nfs.stp @@ -890,7 +890,7 @@ probe nfs.aop.readpage = kernel.function ("nfs_readpage") ?, rsize = __nfs_server_rsize(__inode) name = "nfs.aop.readpage" - argstr = sprintf("%d,%d" , page_index,r_size) + argstr = sprintf("%d,%d" , page_index,rsize) size = 1 units = "pages" -- cgit