* autoload.cc (GetSystemDEPPolicy): Define.

(GetProcessDEPPolicy): Ditto.
	(SetProcessDEPPolicy): Ditto.
	* dcrt0.cc (disable_dep): New static function.
	(dll_crt0_0): Call disable_dep on platforms requiring it.  Add longish
	comment to explain the circumstances.
	* wincap.h (wincaps::ts_has_dep_problem): New element.
	* wincap.cc: Implement above element throughout.
	(wincapc::init): Set ts_has_dep_problem to true on 2008 Terminal
	Servers.
	* winsup.h (WINVER): Set to 0x0601.
This commit is contained in:
Corinna Vinschen 2008-11-12 11:04:27 +00:00
parent bef8896587
commit babd4a9c62
6 changed files with 84 additions and 3 deletions

View File

@ -1,3 +1,17 @@
2008-11-11 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (GetSystemDEPPolicy): Define.
(GetProcessDEPPolicy): Ditto.
(SetProcessDEPPolicy): Ditto.
* dcrt0.cc (disable_dep): New static function.
(dll_crt0_0): Call disable_dep on platforms requiring it. Add longish
comment to explain the circumstances.
* wincap.h (wincaps::ts_has_dep_problem): New element.
* wincap.cc: Implement above element throughout.
(wincapc::init): Set ts_has_dep_problem to true on 2008 Terminal
Servers.
* winsup.h (WINVER): Set to 0x0601.
2008-11-11 Corinna Vinschen <corinna@vinschen.de>
* mount.cc (mount_info::cygdrive_win32_path): Always upper case

View File

@ -413,6 +413,9 @@ LoadDLLfuncEx (FindVolumeClose, 4, kernel32, 1)
LoadDLLfuncEx (GetConsoleWindow, 0, kernel32, 1)
LoadDLLfuncEx (GetSystemWindowsDirectoryW, 8, kernel32, 1)
LoadDLLfuncEx (GetVolumeNameForVolumeMountPointA, 12, kernel32, 1)
LoadDLLfuncEx (GetSystemDEPPolicy, 0, kernel32, 1)
LoadDLLfuncEx (GetProcessDEPPolicy, 12, kernel32, 1)
LoadDLLfuncEx (SetProcessDEPPolicy, 4, kernel32, 1)
LoadDLLfunc (SHGetDesktopFolder, 4, shell32)

View File

@ -686,6 +686,31 @@ child_info_spawn::handle_spawn ()
fixup_lockf_after_exec ();
}
static DEP_SYSTEM_POLICY_TYPE dep_system_policy = (DEP_SYSTEM_POLICY_TYPE) -1;
static void
disable_dep ()
{
DWORD ppolicy;
BOOL perm;
if (dep_system_policy < 0)
{
dep_system_policy = GetSystemDEPPolicy ();
debug_printf ("DEP System Policy: %d", (int) dep_system_policy);
}
if (dep_system_policy < OptIn)
return;
if (!GetProcessDEPPolicy (hMainProc, &ppolicy, &perm))
{
debug_printf ("GetProcessDEPPolicy: %E");
return;
}
debug_printf ("DEP Process Policy: %d (permanent = %d)", ppolicy, perm);
if (ppolicy > 0 && !perm && !SetProcessDEPPolicy (0))
debug_printf ("SetProcessDEPPolicy: %E");
}
void __stdcall
dll_crt0_0 ()
{
@ -750,6 +775,27 @@ dll_crt0_0 ()
events_init ();
tty_list::init_session ();
/* FIXME: This is hopefully a temporary hack, at least until the support
case at Microsoft has been closed one way or the other.
The disable_dep function disables DEP for all Cygwin processes if
the process runs on a Windows Server 2008 with Terminal Services
installed. This combination (TS+DEP) breaks *some* Cygwin
applications. The Terminal Service specific DLL tsappcmp.dll
changes the page protection of some pages in the application's text
segment from PAGE_EXECUTE_WRITECOPY to PAGE_WRITECOPY for no
apparent reason. This occurs before any Cygwin or applicaton code
had a chance to run. MS has no explanation for this so far, but is
rather busy trying to avoid giving support for this problem (as of
2008-11-11).
Unfortunately disabling DEP seems to have a not negligible
performance hit. In the long run, either MS has to fix their
problem, or we have to find a better workaround, if any exists.
Idle idea: Adding EXECUTE protection to all text segment pages? */
if (wincap.ts_has_dep_problem ())
disable_dep ();
debug_printf ("finished dll_crt0_0 initialization");
}

View File

@ -50,6 +50,7 @@ wincaps wincap_unknown __attribute__((section (".cygwin_dll_common"), shared)) =
supports_all_posix_ai_flags:false,
has_restricted_stack_args:false,
has_transactions:false,
ts_has_dep_problem:false,
};
wincaps wincap_nt4 __attribute__((section (".cygwin_dll_common"), shared)) = {
@ -82,6 +83,7 @@ wincaps wincap_nt4 __attribute__((section (".cygwin_dll_common"), shared)) = {
supports_all_posix_ai_flags:false,
has_restricted_stack_args:false,
has_transactions:false,
ts_has_dep_problem:false,
};
wincaps wincap_nt4sp4 __attribute__((section (".cygwin_dll_common"), shared)) = {
@ -114,6 +116,7 @@ wincaps wincap_nt4sp4 __attribute__((section (".cygwin_dll_common"), shared)) =
supports_all_posix_ai_flags:false,
has_restricted_stack_args:false,
has_transactions:false,
ts_has_dep_problem:false,
};
wincaps wincap_2000 __attribute__((section (".cygwin_dll_common"), shared)) = {
@ -146,6 +149,7 @@ wincaps wincap_2000 __attribute__((section (".cygwin_dll_common"), shared)) = {
supports_all_posix_ai_flags:false,
has_restricted_stack_args:false,
has_transactions:false,
ts_has_dep_problem:false,
};
wincaps wincap_2000sp4 __attribute__((section (".cygwin_dll_common"), shared)) = {
@ -178,6 +182,7 @@ wincaps wincap_2000sp4 __attribute__((section (".cygwin_dll_common"), shared)) =
supports_all_posix_ai_flags:false,
has_restricted_stack_args:false,
has_transactions:false,
ts_has_dep_problem:false,
};
wincaps wincap_xp __attribute__((section (".cygwin_dll_common"), shared)) = {
@ -210,6 +215,7 @@ wincaps wincap_xp __attribute__((section (".cygwin_dll_common"), shared)) = {
supports_all_posix_ai_flags:false,
has_restricted_stack_args:false,
has_transactions:false,
ts_has_dep_problem:false,
};
wincaps wincap_xpsp1 __attribute__((section (".cygwin_dll_common"), shared)) = {
@ -242,6 +248,7 @@ wincaps wincap_xpsp1 __attribute__((section (".cygwin_dll_common"), shared)) = {
supports_all_posix_ai_flags:false,
has_restricted_stack_args:false,
has_transactions:false,
ts_has_dep_problem:false,
};
wincaps wincap_xpsp2 __attribute__((section (".cygwin_dll_common"), shared)) = {
@ -274,6 +281,7 @@ wincaps wincap_xpsp2 __attribute__((section (".cygwin_dll_common"), shared)) = {
supports_all_posix_ai_flags:false,
has_restricted_stack_args:false,
has_transactions:false,
ts_has_dep_problem:false,
};
wincaps wincap_2003 __attribute__((section (".cygwin_dll_common"), shared)) = {
@ -306,6 +314,7 @@ wincaps wincap_2003 __attribute__((section (".cygwin_dll_common"), shared)) = {
supports_all_posix_ai_flags:false,
has_restricted_stack_args:true,
has_transactions:false,
ts_has_dep_problem:false,
};
wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = {
@ -338,6 +347,7 @@ wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = {
supports_all_posix_ai_flags:true,
has_restricted_stack_args:false,
has_transactions:true,
ts_has_dep_problem:false,
};
wincapc wincap __attribute__((section (".cygwin_dll_common"), shared));
@ -419,8 +429,14 @@ wincapc::init ()
}
if (has_osversioninfoex && version.wProductType != VER_NT_WORKSTATION)
((wincaps *)caps)->is_server = true;
{
((wincaps *)caps)->is_server = true;
if (version.dwMajorVersion >= 6
&& (version.wSuiteMask
& (VER_SUITE_TERMINAL | VER_SUITE_SINGLEUSERTS))
== VER_SUITE_TERMINAL)
((wincaps *)caps)->ts_has_dep_problem = true;
}
if (NT_SUCCESS (NtQueryInformationProcess (GetCurrentProcess (),
ProcessWow64Information,
&wow64, sizeof wow64, NULL))

View File

@ -42,6 +42,7 @@ struct wincaps
unsigned supports_all_posix_ai_flags : 1;
unsigned has_restricted_stack_args : 1;
unsigned has_transactions : 1;
unsigned ts_has_dep_problem : 1;
};
class wincapc
@ -90,6 +91,7 @@ public:
bool IMPLEMENT (supports_all_posix_ai_flags)
bool IMPLEMENT (has_restricted_stack_args)
bool IMPLEMENT (has_transactions)
bool IMPLEMENT (ts_has_dep_problem)
#undef IMPLEMENT
};

View File

@ -26,7 +26,7 @@ details. */
#define EXPORT_ALIAS(sym,symalias) extern "C" __typeof (sym) symalias __attribute__ ((alias(#sym)));
#define WINVER 0x0600
#define WINVER 0x0601
#define _NO_W32_PSEUDO_MODIFIERS
#include <sys/types.h>