|
From: Nicholas N. <nj...@ca...> - 2004-11-15 16:40:44
|
CVS commit by nethercote:
Converted modify_ldt() and init_module(); the old code for init_module() was
seemingly totally wrong, as the man page doesn't reflect the real kernel code.
M +14 -11 coregrind/vg_syscalls.c 1.207
M +0 -17 include/x86-linux/vki_arch.h 1.6
M +4 -4 memcheck/tests/scalar.c 1.40
M +54 -0 memcheck/tests/scalar.stderr.exp 1.33
--- valgrind/coregrind/vg_syscalls.c #1.206:1.207
@@ -1227,15 +1227,17 @@ PREx(sys_umount, 0)
}
-PRE(modify_ldt)
+PREx(sys_modify_ldt, Special)
{
PRINT("modify_ldt ( %d, %p, %d )", arg1,arg2,arg3);
+ PRE_REG_READ3(int, "modify_ldt", int, func, void *, ptr,
+ unsigned long, bytecount);
+
if (arg1 == 0) {
/* read the LDT into ptr */
- PRE_MEM_WRITE( "modify_ldt(ptr)(func=0)", arg2, arg3 );
+ PRE_MEM_WRITE( "modify_ldt(ptr)", arg2, arg3 );
}
if (arg1 == 1 || arg1 == 0x11) {
/* write the LDT with the entry pointed at by ptr */
- PRE_MEM_READ( "modify_ldt(ptr)(func=1 or 0x11)", arg2,
- sizeof(vki_modify_ldt_t) );
+ PRE_MEM_READ( "modify_ldt(ptr)", arg2, sizeof(vki_modify_ldt_t) );
}
/* "do" the syscall ourselves; the kernel never sees it */
@@ -1876,10 +1878,11 @@ PREx(sys_flock, MayBlock)
}
-PRE(init_module)
+PREx(sys_init_module, MayBlock)
{
- /* int init_module(const char *name, struct module *image); */
- PRINT("init_module ( %p, %p )", arg1, arg2 );
- PRE_MEM_RASCIIZ( "init_module(name)", arg1 );
- PRE_MEM_READ( "init_module(image)", arg2, VKI_SIZEOF_STRUCT_MODULE );
+ PRINT("sys_init_module ( %p, %llu, %p )", arg1, (ULong)arg2, arg3 );
+ PRE_REG_READ3(long, "init_module",
+ void *, umod, unsigned long, len, const char *, uargs);
+ PRE_MEM_READ( "init_module(umod)", arg1, arg2 );
+ PRE_MEM_RASCIIZ( "init_module(uargs)", arg3 );
}
@@ -6483,5 +6486,5 @@ static const struct sys_info sys_info[]
// (__NR_setdomainname, sys_setdomainname),// 121 * (non-P?)
SYSXY(__NR_uname, sys_newuname), // 122 * P
- SYSB_(__NR_modify_ldt, sys_modify_ldt, Special), // 123 (x86,amd64) L
+ SYSX_(__NR_modify_ldt, sys_modify_ldt), // 123 (x86,amd64) L
SYSXY(__NR_adjtimex, sys_adjtimex), // 124 * L
@@ -6490,5 +6493,5 @@ static const struct sys_info sys_info[]
// Nb: create_module() was removed 2.4-->2.6
SYSX_(__NR_create_module, sys_ni_syscall), // 127 * P -- unimplemented
- SYSB_(__NR_init_module, sys_init_module, MayBlock), // 128 *
+ SYSX_(__NR_init_module, sys_init_module), // 128 * L?
// (__NR_delete_module, sys_delete_module),// 129 () (L?)
--- valgrind/include/x86-linux/vki_arch.h #1.5:1.6
@@ -729,21 +729,4 @@ struct vki_shminfo64 {
//----------------------------------------------------------------------
-// From linux-2.6.8.1/include/linux/module.h
-//----------------------------------------------------------------------
-
-// [[This VKI_SIZEOF_* value is arch-specific, because it depends on the
-// word size. The values are really guesses, but they are only needed for
-// init_module() which is very rare]]
-
-#if defined(KERNEL_2_2) || defined(KERNEL_2_4)
-// [[This is actually an over-estimate; only 60 bytes are mandated.]]
-# define VKI_SIZEOF_STRUCT_MODULE 96
-#else
-// [[This is a conservative guesstimate; it can be longer, depending on
-// certain #ifdefs. Close enough.]]
-# define VKI_SIZEOF_STRUCT_MODULE 160
-#endif
-
-//----------------------------------------------------------------------
// And that's it!
//----------------------------------------------------------------------
--- valgrind/memcheck/tests/scalar.c #1.39:1.40
@@ -529,6 +529,6 @@ int main(void)
// __NR_modify_ldt 123
- //GO(__NR_modify_ldt, ".s .m");
- //SY(__NR_modify_ldt);
+ GO(__NR_modify_ldt, "3s 1m");
+ SY(__NR_modify_ldt, x0, x0, x0+1);
// __NR_adjtimex 124
@@ -550,6 +550,6 @@ int main(void)
// __NR_init_module 128
- //GO(__NR_init_module, ".s .m");
- //SY(__NR_init_module);
+ GO(__NR_init_module, "3s 2m");
+ SY(__NR_init_module, x0, x0+1, x0);
// __NR_delete_module 129
--- valgrind/memcheck/tests/scalar.stderr.exp #1.32:1.33
@@ -1560,4 +1560,28 @@
Address 0x........ is not stack'd, malloc'd or (recently) free'd
-----------------------------------------------------
+123: __NR_modify_ldt 3s 1m
+-----------------------------------------------------
+
+Syscall param modify_ldt(func) contains uninitialised byte(s)
+ at 0x........: syscall (in /...libc...)
+ by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
+
+Syscall param modify_ldt(ptr) contains uninitialised byte(s)
+ at 0x........: syscall (in /...libc...)
+ by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
+
+Syscall param modify_ldt(bytecount) contains uninitialised byte(s)
+ at 0x........: syscall (in /...libc...)
+ by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
+
+Syscall param modify_ldt(ptr) 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
+-----------------------------------------------------
125: __NR_mprotect 3s 0m
-----------------------------------------------------
@@ -1581,4 +1605,34 @@
-----------------------------------------------------
-----------------------------------------------------
+128: __NR_init_module 3s 2m
+-----------------------------------------------------
+
+Syscall param init_module(umod) contains uninitialised byte(s)
+ at 0x........: syscall (in /...libc...)
+ by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
+
+Syscall param init_module(len) contains uninitialised byte(s)
+ at 0x........: syscall (in /...libc...)
+ by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
+
+Syscall param init_module(uargs) contains uninitialised byte(s)
+ at 0x........: syscall (in /...libc...)
+ by 0x........: __libc_start_main (...libc...)
+ by 0x........: ...
+
+Syscall param init_module(umod) 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 init_module(uargs) 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
+-----------------------------------------------------
129: __NR_delete_module n/a
-----------------------------------------------------
|