]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add a warning to the get/set_thread_area wrapper for bad info pointers.
authorMark Wielaard <mark@klomp.org>
Wed, 5 Oct 2016 19:51:53 +0000 (19:51 +0000)
committerMark Wielaard <mark@klomp.org>
Wed, 5 Oct 2016 19:51:53 +0000 (19:51 +0000)
Also adjust the scalar.stderr.exp to catch the new warnings.

Patch by Julian Seward <jseward@acm.org>

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16025

coregrind/m_syswrap/syswrap-x86-linux.c
memcheck/tests/x86-linux/scalar.stderr.exp

index 62d886a7fc026d76bc9b33b8bace3adf4edb88c7..5bdf4c7d4b5160002075c8bb5d7de6e4939efc9c 100644 (file)
@@ -596,7 +596,9 @@ SysRes write_ldt ( ThreadId tid, void* ptr, UInt bytecount, Int oldmode )
 static SysRes sys_modify_ldt ( ThreadId tid,
                                Int func, void* ptr, UInt bytecount )
 {
-   SysRes ret;
+   /* Set return value to something "safe".  I think this will never
+      actually be returned, though. */
+   SysRes ret = VG_(mk_SysRes_Error)( VKI_ENOSYS );
 
    if (func != 0 && func != 1 && func != 2 && func != 0x11) {
       ret = VG_(mk_SysRes_Error)( VKI_ENOSYS );
@@ -634,8 +636,10 @@ static SysRes sys_set_thread_area ( ThreadId tid, vki_modify_ldt_t* info )
    vg_assert(8 == sizeof(VexGuestX86SegDescr));
    vg_assert(sizeof(HWord) == sizeof(VexGuestX86SegDescr*));
 
-   if (info == NULL || ! ML_(safe_to_deref)(info, sizeof(vki_modify_ldt_t)))
+   if (info == NULL || ! ML_(safe_to_deref)(info, sizeof(vki_modify_ldt_t))) {
+      VG_(umsg)("Warning: bad u_info address %p in set_thread_area\n", info);
       return VG_(mk_SysRes_Error)( VKI_EFAULT );
+   }
 
    gdt = (VexGuestX86SegDescr*)VG_(threads)[tid].arch.vex.guest_GDT;
 
@@ -686,8 +690,10 @@ static SysRes sys_get_thread_area ( ThreadId tid, vki_modify_ldt_t* info )
    vg_assert(sizeof(HWord) == sizeof(VexGuestX86SegDescr*));
    vg_assert(8 == sizeof(VexGuestX86SegDescr));
 
-   if (info == NULL || ! ML_(safe_to_deref)(info, sizeof(vki_modify_ldt_t)))
+   if (info == NULL || ! ML_(safe_to_deref)(info, sizeof(vki_modify_ldt_t))) {
+      VG_(umsg)("Warning: bad u_info address %p in get_thread_area\n", info);
       return VG_(mk_SysRes_Error)( VKI_EFAULT );
+   }
 
    idx = info->entry_number;
 
index 30cfd1ce274a89d58db02e3c0db9364dd0089690..d1af3136c32fdd52daaaddd7cd3d553d05b2a75b 100644 (file)
@@ -3380,6 +3380,7 @@ Syscall param set_thread_area(u_info) points to unaddressable byte(s)
    by 0x........: main (scalar.c:1084)
  Address 0x........ is not stack'd, malloc'd or (recently) free'd
 
+Warning: bad u_info address 0x........ in set_thread_area
 -----------------------------------------------------
 244:__NR_get_thread_area 1s 1m
 -----------------------------------------------------
@@ -3392,6 +3393,7 @@ Syscall param get_thread_area(u_info) points to unaddressable byte(s)
    by 0x........: main (scalar.c:1088)
  Address 0x........ is not stack'd, malloc'd or (recently) free'd
 
+Warning: bad u_info address 0x........ in get_thread_area
 -----------------------------------------------------
 245:       __NR_io_setup 2s 1m
 -----------------------------------------------------