From: Nicholas N. <nj...@ca...> - 2004-11-12 17:07:31
|
CVS commit by nethercote: Converted a whole bunch of syscalls. M +73 -71 coregrind/vg_syscalls.c 1.183 M +48 -4 memcheck/tests/scalar.c 1.14 M +2 -1 memcheck/tests/scalar.h 1.2 M +182 -0 memcheck/tests/scalar.stderr.exp 1.13 --- valgrind/coregrind/vg_syscalls.c #1.182:1.183 @@ -1120,9 +1120,11 @@ PREx(sys_ni_syscall, Special) } -PRE(ptrace) +// XXX: I think this is x86/linux-specific +// XXX: Why is the memory pointed to by arg3 never checked? +PREx(sys_ptrace, 0) { - /* long ptrace (enum __ptrace_request request, pid_t pid, - void *addr, void *data); */ - PRINT("ptrace ( %d, %d, %p, %p )", arg1,arg2,arg3,arg4); + PRINT("sys_ptrace ( %d, %d, %p, %p )", arg1,arg2,arg3,arg4); + PRE_REG_READ4(int, "ptrace", + long, request, long, pid, long, addr, long, data); switch (arg1) { case 12: /* PTRACE_GETREGS */ @@ -1159,5 +1161,6 @@ PRE(ptrace) } -POST(ptrace) +// XXX: I think this is x86/linux-specific +POST(sys_ptrace) { switch (arg1) { @@ -1541,8 +1544,8 @@ PRE(mremap) } -PRE(nice) +PREx(sys_nice, 0) { - /* int nice(int inc); */ - PRINT("nice ( %d )", arg1); + PRINT("sys_nice ( %d )", arg1); + PRE_REG_READ1(long, "nice", int, inc); } @@ -1923,15 +1926,15 @@ PREx(sys_execve, Special) } -PRE(access) +PREx(sys_access, 0) { - /* int access(const char *pathname, int mode); */ - PRINT("access ( %p(%s), %d )", arg1,arg1,arg2); + PRINT("sys_access ( %p(%s), %d )", arg1,arg1,arg2); + PRE_REG_READ2(long, "access", const char *, pathname, int, mode); PRE_MEM_RASCIIZ( "access(pathname)", arg1 ); } -PRE(alarm) +PREx(sys_alarm, NBRunInLWP) { - /* unsigned int alarm(unsigned int seconds); */ - PRINT("alarm ( %d )", arg1); + PRINT("sys_alarm ( %d )", arg1); + PRE_REG_READ1(unsigned long, "alarm", unsigned int, seconds); } @@ -2016,18 +2019,17 @@ POST(sys_close) } -PRE(dup) +PREx(sys_dup, 0) { - /* int dup(int oldfd); */ - PRINT("dup ( %d )", arg1); + PRINT("sys_dup ( %d )", arg1); + PRE_REG_READ1(long, "dup", unsigned int, oldfd); } -POST(dup) +POST(sys_dup) { - PRINT("%d\n", res); if (!fd_allowed(res, "dup", tid, True)) { VG_(close)(res); set_result( -VKI_EMFILE ); } else { - if(VG_(clo_track_fds)) + if (VG_(clo_track_fds)) record_fd_open(tid, res, VG_(resolve_filename)(res)); } @@ -3915,27 +3917,27 @@ POST(ioctl) } -PRE(kill) +PREx(sys_kill, 0) { /* int kill(pid_t pid, int sig); */ - PRINT("kill ( %d, %d )", arg1,arg2); + PRINT("sys_kill ( %d, %d )", arg1,arg2); + PRE_REG_READ2(long, "kill", int, pid, int, sig); if (arg2 == VKI_SIGVGINT || arg2 == VKI_SIGVGKILL) set_result( -VKI_EINVAL ); } -POST(kill) +POST(sys_kill) { /* If this was a self-kill then wait for a signal to be delivered to any thread before claiming the kill is done. */ - if (res >= 0 && /* if it was successful */ - arg2 != 0 && /* if a real signal */ - !VG_(is_sig_ign)(arg2) && /* that isn't ignored and */ - !VG_(sigismember)(&tst->eff_sig_mask, arg2) && /* we're not blocking it */ - (arg1 == VG_(getpid)() || /* directed at us or */ - arg1 == -1 || /* directed at everyone or */ - arg1 == 0 || /* directed at whole group or */ - -arg1 == VG_(getpgrp)())) { /* directed at our group... */ + if (res >= 0 && // if it was successful and + arg2 != 0 && // if a real signal and + !VG_(is_sig_ign)(arg2) && // that isn't ignored and + !VG_(sigismember)(&tst->eff_sig_mask, arg2) && // we're not blocking it + (arg1 == VG_(getpid)() || // directed at us or + arg1 == -1 || // directed at everyone or + arg1 == 0 || // directed at whole group or + -arg1 == VG_(getpgrp)())) { // directed at our group... /* ...then wait for that signal to be delivered to someone - (might be us, might be someone else who doesn't have it - blocked) */ + (might be us, might be someone else who doesn't have it blocked) */ VG_(proxy_waitsig)(); } @@ -4002,8 +4004,8 @@ POST(lstat64) } -PRE(mkdir) +PREx(sys_mkdir, MayBlock) { - /* int mkdir(const char *pathname, mode_t mode); */ - PRINT("mkdir ( %p, %d )", arg1,arg2); + PRINT("sys_mkdir ( %p, %d )", arg1,arg2); + PRE_REG_READ2(long, "mkdir", const char *, pathname, int, mode); PRE_MEM_RASCIIZ( "mkdir(pathname)", arg1 ); } @@ -4238,16 +4240,17 @@ POST(sys_creat) record_fd_open(tid, res, VG_(arena_strdup)(VG_AR_CORE, (Char*)arg1)); } - PRINT("%d\n",res); } -PRE(pipe) +// XXX: sort of x86-specific +PREx(sys_pipe, 0) { - /* int pipe(int filedes[2]); */ - PRINT("pipe ( %p )", arg1); - PRE_MEM_WRITE( "pipe(filedes)", arg1, 2*sizeof(int) ); + PRINT("sys_pipe ( %p )", arg1); + PRE_REG_READ1(int, "pipe", unsigned long *, filedes); + PRE_MEM_WRITE( "pipe(filedes)", arg1, 2*sizeof(long) ); } -POST(pipe) +POST(sys_pipe) { + // XXX: use of Int here -- 32-bit-specific? Int *p = (Int *)arg1; @@ -4393,16 +4396,16 @@ POST(readv) } -PRE(rename) +PREx(sys_rename, 0) { - /* int rename(const char *oldpath, const char *newpath); */ - PRINT("rename ( %p, %p )", arg1, arg2 ); + PRINT("sys_rename ( %p, %p )", arg1, arg2 ); + PRE_REG_READ2(long, "rename", const char *, oldpath, const char *, newpath); PRE_MEM_RASCIIZ( "rename(oldpath)", arg1 ); PRE_MEM_RASCIIZ( "rename(newpath)", arg2 ); } -PRE(rmdir) +PREx(sys_rmdir, MayBlock) { - /* int rmdir(const char *pathname); */ - PRINT("rmdir ( %p )", arg1); + PRINT("sys_rmdir ( %p )", arg1); + PRE_REG_READ1(long, "rmdir", const char *, pathname); PRE_MEM_RASCIIZ( "rmdir(pathname)", arg1 ); } @@ -5113,8 +5116,8 @@ POST(sys_newuname) } -PRE(utime) +PREx(sys_utime, MayBlock) { - /* int utime(const char *filename, struct utimbuf *buf); */ - PRINT("utime ( %p, %p )", arg1,arg2); + PRINT("sys_utime ( %p, %p )", arg1,arg2); + PRE_REG_READ2(long, "utime", char *, filename, struct utimbuf *, buf); PRE_MEM_RASCIIZ( "utime(filename)", arg1 ); if (arg2 != (UWord)NULL) @@ -5571,5 +5574,4 @@ POST(mq_open) record_fd_open(tid, res, VG_(arena_strdup)(VG_AR_CORE, (Char*)arg1)); } - PRINT("%d\n",res); } @@ -5850,29 +5852,29 @@ static const struct sys_info sys_info[] SYSX_(__NR_getuid, sys_getuid16), // 24 ## P - // stime 25 sys_stime * - SYSBA(ptrace, 0), // 26 sys_ptrace () - SYSB_(alarm, NBRunInLWP), // 27 sys_alarm * + // (__NR_stime, sys_stime), // 25 * (SVr4,SVID,X/OPEN) + SYSXY(__NR_ptrace, sys_ptrace), // 26 (x86?) (L?) + SYSX_(__NR_alarm, sys_alarm), // 27 * P // (__NR_oldfstat, sys_fstat), // 28 * L -- obsolete SYSX_(__NR_pause, sys_pause), // 29 * P - SYSB_(utime, MayBlock), // 30 sys_utime * + SYSX_(__NR_utime, sys_utime), // 30 * P SYSX_(__NR_stty, sys_ni_syscall), // 31 * P -- unimplemented SYSX_(__NR_gtty, sys_ni_syscall), // 32 * P -- unimplemented - SYSB_(access, 0), // 33 sys_access * - SYSB_(nice, 0), // 34 sys_nice * - SYSX_(__NR_ftime, sys_ni_syscall), // 35 * P -- unimplemented + SYSX_(__NR_access, sys_access), // 33 * P + SYSX_(__NR_nice, sys_nice), // 34 * (almost P) - SYSX_(__NR_sync, sys_sync), // 36 * - SYSBA(kill, 0), // 37 sys_kill * - SYSB_(rename, 0), // 38 sys_rename * - SYSB_(mkdir, MayBlock), // 39 sys_mkdir * + SYSX_(__NR_ftime, sys_ni_syscall), // 35 * P -- unimplemented + SYSX_(__NR_sync, sys_sync), // 36 * (almost P) + SYSXY(__NR_kill, sys_kill), // 37 * P + SYSX_(__NR_rename, sys_rename), // 38 * P + SYSX_(__NR_mkdir, sys_mkdir), // 39 * P - SYSB_(rmdir, MayBlock), // 40 sys_rmdir * - SYSBA(dup, 0), // 41 sys_dup * - SYSBA(pipe, 0), // 42 sys_pipe + SYSX_(__NR_rmdir, sys_rmdir), // 40 * P + SYSXY(__NR_dup, sys_dup), // 41 * P + SYSXY(__NR_pipe, sys_pipe), // 42 (x86) P SYSBA(times, 0), // 43 sys_times * SYSX_(__NR_prof, sys_ni_syscall), // 44 * P -- unimplemented - SYSB_(brk, Special), // 45 sys_brk * + SYSB_(brk, Special), // 45 sys_brk * SYSB_(setgid, 0), // 46 sys_setgid16 ## SYSX_(__NR_getgid, sys_getgid16), // 47 ## P --- valgrind/memcheck/tests/scalar.c #1.13:1.14 @@ -77,4 +77,5 @@ int main(void) // __NR_lchown 16 + // (Not yet handled by Valgrind) // __NR_break 17 --> sys_ni_syscall() @@ -83,4 +84,5 @@ int main(void) // __NR_oldstat 18 + // (obsolete, not handled by Valgrind) // __NR_lseek 19 --> sys_lseek() @@ -109,12 +111,24 @@ int main(void) // __NR_stime 25 - // __NR_ptrace 26 - // __NR_alarm 27 + // (Not yet handled by Valgrind) + + // __NR_ptrace 26 --> arch/sys_ptrace() + // XXX: memory pointed to be arg3 is never checked... + GO(__NR_ptrace, "4s 2m"); + SY(__NR_ptrace, i0+PTRACE_GETREGS, i0, s0, s0); + + // __NR_alarm 27 --> sys_alarm() + GO(__NR_alarm, "1s 0m"); + SY(__NR_alarm, i0); + // __NR_oldfstat 28 + // (obsolete, not handled by Valgrind) // __NR_pause 29 --> sys_pause() // XXX: will have to be tested separately - // __NR_utime 30 + // __NR_utime 30 --> sys_utime() + GO(__NR_utime, "2s 2m"); + SY(__NR_utime, s0, s0+1); // __NR_stty 31 --> sys_ni_syscall() @@ -126,7 +140,11 @@ int main(void) SY(__NR_gtty); - // __NR_access 33 + // __NR_access 33 --> sys_access() + GO(__NR_access, "2s 1m"); + SY(__NR_access, s0, i0); // __NR_nice 34 + GO(__NR_nice, "1s 0m"); + SY(__NR_nice, i0); // __NR_ftime 35 --> sys_ni_syscall() @@ -139,9 +157,27 @@ int main(void) // __NR_kill 37 + GO(__NR_kill, "2s 0m"); + SY(__NR_kill, i0, i0); + // __NR_rename 38 + GO(__NR_rename, "2s 2m"); + SY(__NR_rename, s0, s0); + // __NR_mkdir 39 + GO(__NR_mkdir, "2s 1m"); + SY(__NR_mkdir, s0, i0); + // __NR_rmdir 40 + GO(__NR_rmdir, "1s 1m"); + SY(__NR_rmdir, s0); + // __NR_dup 41 + GO(__NR_dup, "1s 0m"); + SY(__NR_dup, i0); + // __NR_pipe 42 + GO(__NR_pipe, "1s 1m"); + SY(__NR_pipe, s0); + // __NR_times 43 @@ -193,4 +229,6 @@ int main(void) // __NR_oldolduname 59 + // (obsolete, not handled by Valgrind) + // __NR_umask 60 // __NR_chroot 61 @@ -227,5 +265,8 @@ int main(void) // __NR_select 82 // __NR_symlink 83 + // __NR_oldlstat 84 + // (obsolete, not handled by Valgrind) + // __NR_readlink 85 // __NR_uselib 86 @@ -252,5 +293,8 @@ int main(void) // __NR_lstat 107 // __NR_fstat 108 + // __NR_olduname 109 + // (obsolete, not handled by Valgrind) + // __NR_iopl 110 --- valgrind/memcheck/tests/scalar.h #1.1:1.2 @@ -4,6 +4,7 @@ #include <stdlib.h> #include <unistd.h> -#include <sys/stat.h> #include <sys/syscall.h> +#include <sys/stat.h> +#include <sys/ptrace.h> #include <sys/types.h> --- valgrind/memcheck/tests/scalar.stderr.exp #1.12:1.13 @@ -363,4 +363,66 @@ ----------------------------------------------------- ----------------------------------------------------- + 26: __NR_ptrace 4s 2m +----------------------------------------------------- + +Syscall param ptrace(request) contains uninitialised byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + +Syscall param ptrace(pid) contains uninitialised byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + +Syscall param ptrace(addr) contains uninitialised byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + +Syscall param ptrace(data) contains uninitialised byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + +Syscall param ptrace(getregs) points to unaddressable byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + Address 0x........ is not stack'd, malloc'd or (recently) free'd +----------------------------------------------------- + 27: __NR_alarm 1s 0m +----------------------------------------------------- + +Syscall param alarm(seconds) contains uninitialised byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... +----------------------------------------------------- + 30: __NR_utime 2s 2m +----------------------------------------------------- + +Syscall param utime(filename) contains uninitialised byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + +Syscall param utime(buf) contains uninitialised byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + +Syscall param utime(filename) points to unaddressable byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + Address 0x........ is not stack'd, malloc'd or (recently) free'd + +Syscall param utime(buf) points to unaddressable byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + Address 0x........ is not stack'd, malloc'd or (recently) free'd +----------------------------------------------------- 31: __NR_stty 0e ----------------------------------------------------- @@ -369,4 +431,31 @@ ----------------------------------------------------- ----------------------------------------------------- + 33: __NR_access 2s 1m +----------------------------------------------------- + +Syscall param access(pathname) contains uninitialised byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + +Syscall param access(mode) contains uninitialised byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + +Syscall param access(pathname) points to unaddressable byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + Address 0x........ is not stack'd, malloc'd or (recently) free'd +----------------------------------------------------- + 34: __NR_nice 1s 0m +----------------------------------------------------- + +Syscall param nice(inc) contains uninitialised byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... +----------------------------------------------------- 35: __NR_ftime 0e ----------------------------------------------------- @@ -375,4 +464,97 @@ ----------------------------------------------------- ----------------------------------------------------- + 37: __NR_kill 2s 0m +----------------------------------------------------- + +Syscall param kill(pid) contains uninitialised byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + +Syscall param kill(sig) contains uninitialised byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... +----------------------------------------------------- + 38: __NR_rename 2s 2m +----------------------------------------------------- + +Syscall param rename(oldpath) contains uninitialised byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + +Syscall param rename(newpath) contains uninitialised byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + +Syscall param rename(oldpath) points to unaddressable byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + Address 0x........ is not stack'd, malloc'd or (recently) free'd + +Syscall param rename(newpath) points to unaddressable byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + Address 0x........ is not stack'd, malloc'd or (recently) free'd +----------------------------------------------------- + 39: __NR_mkdir 2s 1m +----------------------------------------------------- + +Syscall param mkdir(pathname) contains uninitialised byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + +Syscall param mkdir(mode) contains uninitialised byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + +Syscall param mkdir(pathname) points to unaddressable byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + Address 0x........ is not stack'd, malloc'd or (recently) free'd +----------------------------------------------------- + 40: __NR_rmdir 1s 1m +----------------------------------------------------- + +Syscall param rmdir(pathname) contains uninitialised byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + +Syscall param rmdir(pathname) points to unaddressable byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + Address 0x........ is not stack'd, malloc'd or (recently) free'd +----------------------------------------------------- + 41: __NR_dup 1s 0m +----------------------------------------------------- + +Syscall param dup(oldfd) contains uninitialised byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... +----------------------------------------------------- + 42: __NR_pipe 1s 1m +----------------------------------------------------- + +Syscall param pipe(filedes) contains uninitialised byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + +Syscall param pipe(filedes) points to unaddressable byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + Address 0x........ is not stack'd, malloc'd or (recently) free'd +----------------------------------------------------- 44: __NR_prof 0e ----------------------------------------------------- |