|
From: <sv...@va...> - 2009-06-05 13:17:34
|
Author: sewardj
Date: 2009-06-05 14:17:31 +0100 (Fri, 05 Jun 2009)
New Revision: 10251
Log:
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.
Modified:
trunk/coregrind/m_syswrap/syswrap-x86-linux.c
Modified: trunk/coregrind/m_syswrap/syswrap-x86-linux.c
===================================================================
--- trunk/coregrind/m_syswrap/syswrap-x86-linux.c 2009-06-05 05:28:17 UTC (rev 10250)
+++ trunk/coregrind/m_syswrap/syswrap-x86-linux.c 2009-06-05 13:17:31 UTC (rev 10251)
@@ -647,8 +647,11 @@
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 @@
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 );
}
|