|
From: <sv...@va...> - 2016-10-17 16:10:16
|
Author: sewardj
Date: Mon Oct 17 17:10:10 2016
New Revision: 16049
Log:
Merge from trunk:
16025 Add a warning to the get/set_thread_area wrapper for bad info pointers.
Modified:
branches/VALGRIND_3_12_BRANCH/ (props changed)
branches/VALGRIND_3_12_BRANCH/coregrind/m_syswrap/syswrap-x86-linux.c
branches/VALGRIND_3_12_BRANCH/memcheck/tests/x86-linux/scalar.stderr.exp
Modified: branches/VALGRIND_3_12_BRANCH/coregrind/m_syswrap/syswrap-x86-linux.c
==============================================================================
--- branches/VALGRIND_3_12_BRANCH/coregrind/m_syswrap/syswrap-x86-linux.c (original)
+++ branches/VALGRIND_3_12_BRANCH/coregrind/m_syswrap/syswrap-x86-linux.c Mon Oct 17 17:10:10 2016
@@ -596,7 +596,9 @@
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 @@
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 @@
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;
Modified: branches/VALGRIND_3_12_BRANCH/memcheck/tests/x86-linux/scalar.stderr.exp
==============================================================================
--- branches/VALGRIND_3_12_BRANCH/memcheck/tests/x86-linux/scalar.stderr.exp (original)
+++ branches/VALGRIND_3_12_BRANCH/memcheck/tests/x86-linux/scalar.stderr.exp Mon Oct 17 17:10:10 2016
@@ -3380,6 +3380,7 @@
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 @@
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
-----------------------------------------------------
|