aboutsummaryrefslogtreecommitdiff
path: root/coregrind
diff options
context:
space:
mode:
authorsewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9>2009-06-05 13:17:31 +0000
committersewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9>2009-06-05 13:17:31 +0000
commit3e606a4234c4c70868d69c00f70c572dc32fdcc9 (patch)
treeeab11cb26cafdb9d1225d3b074f93ac1ff1bc2dd /coregrind
parentf31cce91afd36ed9dd38606707a6867c9a3aa1cc (diff)
downloadvalgrind-3e606a4234c4c70868d69c00f70c572dc32fdcc9.tar.gz
x86-linux: sys_set_thread_area: don't allocate GDT entry number zero,
and reject attempts to use it. This is because the hardware does not allow entry zero to be used, and apparently doing so confuses some code (perhaps Windows apps running on Wine). Derived from a patch by John Reiser. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10251 a5019735-40e9-0310-863c-91ae7b9d1cf9
Diffstat (limited to 'coregrind')
-rw-r--r--coregrind/m_syswrap/syswrap-x86-linux.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c
index e16b84488..af3a61f95 100644
--- a/coregrind/m_syswrap/syswrap-x86-linux.c
+++ b/coregrind/m_syswrap/syswrap-x86-linux.c
@@ -647,8 +647,11 @@ static SysRes sys_set_thread_area ( ThreadId tid, vki_modify_ldt_t* info )
idx = info->entry_number;
if (idx == -1) {
- /* Find and use the first free entry. */
- for (idx = 0; idx < VEX_GUEST_X86_GDT_NENT; idx++) {
+ /* Find and use the first free entry. Don't allocate entry
+ zero, because the hardware will never do that, and apparently
+ doing so confuses some code (perhaps stuff running on
+ Wine). */
+ for (idx = 1; idx < VEX_GUEST_X86_GDT_NENT; idx++) {
if (gdt[idx].LdtEnt.Words.word1 == 0
&& gdt[idx].LdtEnt.Words.word2 == 0)
break;
@@ -656,7 +659,8 @@ static SysRes sys_set_thread_area ( ThreadId tid, vki_modify_ldt_t* info )
if (idx == VEX_GUEST_X86_GDT_NENT)
return VG_(mk_SysRes_Error)( VKI_ESRCH );
- } else if (idx < 0 || idx >= VEX_GUEST_X86_GDT_NENT) {
+ } else if (idx < 0 || idx == 0 || idx >= VEX_GUEST_X86_GDT_NENT) {
+ /* Similarly, reject attempts to use GDT[0]. */
return VG_(mk_SysRes_Error)( VKI_EINVAL );
}