From: Nicholas Nethercote Date: Tue, 9 Nov 2004 16:45:33 +0000 (+0000) Subject: Converted __NR_{mount,getpid,getppid}. X-Git-Tag: svn/VALGRIND_3_0_0~1358 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c0a206e627c01719c56833aef907dc5a42ccbe8;p=thirdparty%2Fvalgrind.git Converted __NR_{mount,getpid,getppid}. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2954 --- diff --git a/coregrind/vg_syscalls.c b/coregrind/vg_syscalls.c index bd7888c24d..bab8b2c782 100644 --- a/coregrind/vg_syscalls.c +++ b/coregrind/vg_syscalls.c @@ -1162,15 +1162,19 @@ POST(ptrace) } } -PRE(mount) +PRE(sys_mount) { - // int mount(const char *source, const char *target, - // const char *filesystemtype, unsigned long mountflags, - // const void *data); - PRINT( "mount( %p, %p, %p, %p, %p )" ,arg1,arg2,arg3); - PRE_MEM_RASCIIZ( "mount(specialfile)", arg1); - PRE_MEM_RASCIIZ( "mount(dir)", arg2); - PRE_MEM_RASCIIZ( "mount(filesystemtype)", arg3); + // Nb: depending on 'flags', the 'type' and 'data' args may be ignored. + // We are conservative and check everything, except the memory pointed to + // by 'data'. + PRINT( "sys_mount( %p, %p, %p, %p, %p )" ,arg1,arg2,arg3); + PRE_REG_READ5(long, "mount", + char __user *, source, char __user *, target, + char __user *, type, unsigned long, flags, + void __user *, data); + PRE_MEM_RASCIIZ( "mount(source)", arg1); + PRE_MEM_RASCIIZ( "mount(target)", arg2); + PRE_MEM_RASCIIZ( "mount(type)", arg3); } PRE(umount) @@ -2265,10 +2269,10 @@ PRE(getgid32) PRINT("getgid32 ()"); } -PRE(getpid) +PRE(sys_getpid) { - /* pid_t getpid(void); */ - PRINT("getpid ()"); + PRINT("sys_getpid ()"); + PRE_REG_READ0(long, "getpid"); } PRE(getpgid) @@ -2283,10 +2287,10 @@ PRE(getpgrp) PRINT("getpgrp ()"); } -PRE(getppid) +PRE(sys_getppid) { - /* pid_t getppid(void); */ - PRINT("getppid ()"); + PRINT("sys_getppid ()"); + PRE_REG_READ0(long, "getppid"); } PRE(getresgid) @@ -5788,7 +5792,7 @@ static const struct sys_info special_sys[] = { static const struct sys_info sys_info[] = { SYSBA(ptrace, 0), - SYSB_(mount, MayBlock), + SYSX_(__NR_mount, sys_mount, MayBlock), SYSB_(umount, 0), SYSB_(setresgid, 0), @@ -5891,10 +5895,10 @@ static const struct sys_info sys_info[] = { SYSB_(getegid32, 0), SYSB_(getgid, 0), SYSB_(getgid32, 0), - SYSB_(getpid, 0), + SYSX_(__NR_getpid, sys_getpid, 0), SYSB_(getpgid, 0), SYSB_(getpgrp, 0), - SYSB_(getppid, 0), + SYSX_(__NR_getppid, sys_getppid, 0), SYSBA(getresgid, 0), SYSBA(getresgid32, 0), SYSBA(getresuid, 0), diff --git a/memcheck/tests/scalar.c b/memcheck/tests/scalar.c index 0a795e28a7..2344ea34cb 100644 --- a/memcheck/tests/scalar.c +++ b/memcheck/tests/scalar.c @@ -12,7 +12,7 @@ // meaningful with the syscalls. void GO(char* s) { - fprintf(stderr, "---------- %s ----------\n", s); + fprintf(stderr, "---------- %s\n", s); } int main(void) @@ -62,8 +62,14 @@ int main(void) // __NR_break 17 // __NR_oldstat 18 // __NR_lseek 19 - // __NR_getpid 20 + // __NR_getpid 20 --> sys_getpid() + GO("__NR_getpid, 0 errors"); + syscall(__NR_getpid); + // __NR_mount 21 + GO("__NR_mount, 4 scalar errors, 3 memory errors"); + syscall(__NR_mount, s0, s0, s0, i0, s0); + // __NR_umount 22 // __NR_setuid 23 // __NR_getuid 24 @@ -106,7 +112,11 @@ int main(void) // __NR_chroot 61 // __NR_ustat 62 // __NR_dup2 63 + // __NR_getppid 64 + GO("__NR_getppid, 0 errors"); + syscall(__NR_getppid); + // __NR_getpgrp 65 // __NR_setsid 66 // __NR_sigaction 67 diff --git a/memcheck/tests/scalar.stderr.exp b/memcheck/tests/scalar.stderr.exp index 8824d195fb..db4fd8f7fe 100644 --- a/memcheck/tests/scalar.stderr.exp +++ b/memcheck/tests/scalar.stderr.exp @@ -1,4 +1,4 @@ ----------- __NR_read, 1+3 scalar errors ---------- +---------- __NR_read, 1+3 scalar errors Syscall param (syscallno) contains uninitialised byte(s) at 0x........: syscall (in /...libc...) by 0x........: __libc_start_main (...libc...) @@ -18,7 +18,7 @@ Syscall param read(count) contains uninitialised byte(s) at 0x........: syscall (in /...libc...) by 0x........: __libc_start_main (...libc...) by 0x........: ... ----------- __NR_write, 3 scalar errors, 1 memory error ---------- +---------- __NR_write, 3 scalar errors, 1 memory error Syscall param write(fd) contains uninitialised byte(s) at 0x........: syscall (in /...libc...) @@ -40,7 +40,7 @@ Syscall param write(buf) points to unaddressable byte(s) by 0x........: __libc_start_main (...libc...) by 0x........: ... Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------- __NR_open(2), 2 scalar errors, 1 memory error ---------- +---------- __NR_open(2), 2 scalar errors, 1 memory error Syscall param open(filename) contains uninitialised byte(s) at 0x........: syscall (in /...libc...) @@ -57,13 +57,59 @@ Syscall param open(filename) points to unaddressable byte(s) by 0x........: __libc_start_main (...libc...) by 0x........: ... Address 0x........ is not stack'd, malloc'd or (recently) free'd ----------- __NR_open(3), 1 scalar error ---------- +---------- __NR_open(3), 1 scalar error Syscall param open(mode) contains uninitialised byte(s) at 0x........: syscall (in /...libc...) by 0x........: __libc_start_main (...libc...) by 0x........: ... ----------- __NR_exit, 1 scalar error ---------- +---------- __NR_getpid, 0 errors +---------- __NR_mount, 4 scalar errors, 3 memory errors + +Syscall param mount(source) contains uninitialised byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + +Syscall param mount(target) contains uninitialised byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + +Syscall param mount(type) contains uninitialised byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + +Syscall param mount(flags) contains uninitialised byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + +Syscall param mount(data) contains uninitialised byte(s) + at 0x........: syscall (in /...libc...) + by 0x........: __libc_start_main (...libc...) + by 0x........: ... + +Syscall param mount(source) 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 mount(target) 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 mount(type) 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 +---------- __NR_getppid, 0 errors +---------- __NR_exit, 1 scalar error Syscall param exit(error_code) contains uninitialised byte(s) at 0x........: syscall (in /...libc...)