diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2015-12-15 20:28:03 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2016-06-25 01:43:01 +0300 |
commit | cb34fffe07e13fc5ccbcc5e9fb7f951eb7d5c2b8 (patch) | |
tree | 584f2d700889e27b30429c26d5e5d37973849c8b /winsup/cygwin/cygtls.cc | |
parent | da5b48ef3c39ea68d41a43cfc4379124b67c0812 (diff) |
Remove CYGWIN=detect_bloda option
Diffstat (limited to 'winsup/cygwin/cygtls.cc')
-rw-r--r-- | winsup/cygwin/cygtls.cc | 70 |
1 files changed, 1 insertions, 69 deletions
diff --git a/winsup/cygwin/cygtls.cc b/winsup/cygwin/cygtls.cc index 6e9764d0f..1a2213d1f 100644 --- a/winsup/cygwin/cygtls.cc +++ b/winsup/cygwin/cygtls.cc @@ -27,70 +27,6 @@ _cygtls::call (DWORD (*func) (void *, void *), void *arg) _my_tls.call2 (func, arg, buf); } -static int -dll_cmp (const void *a, const void *b) -{ - return wcscasecmp ((const wchar_t *) a, *(const wchar_t **) b); -} - -/* Keep sorted! - This is a list of well-known core system DLLs which contain code - started in its own thread by the system. Kernel32.dll, for instance, - contains the thread called on every Ctrl-C keypress in a console window. - The DLLs in this list are not recognized as BLODAs. */ -const wchar_t *well_known_dlls[] = -{ - L"advapi32.dll", - L"kernel32.dll", - L"kernelbase.dll", - L"mswsock.dll", - L"ntdll.dll", - L"ole32.dll", - L"shlwapi.dll", - L"wbemprox.dll", - L"ws2_32.dll", -}; - -/* Optional BLODA detection. The idea is that the function address is supposed - to be within Cygwin itself. This is also true for pthreads, since pthreads - are always calling pthread::thread_init_wrapper() in thread.cc. Therefore, - every function call to a function outside of the Cygwin DLL is potentially - a thread injected into the Cygwin process by some BLODA. - - But that's too simple. Assuming the application itself calls CreateThread, - then this is a bad idea, but not really invalid. So we shouldn't print a - BLODA message if the address is within the loaded image of the application. - Also, ntdll.dll starts threads into the application which */ -static void -bloda_detect (DWORD (*func) (void *, void *)) -{ - PIMAGE_DOS_HEADER img_start = (PIMAGE_DOS_HEADER) - GetModuleHandle (NULL); - PIMAGE_NT_HEADERS32 ntheader = (PIMAGE_NT_HEADERS32) - ((PBYTE) img_start + img_start->e_lfanew); - void *img_end = (void *) ((PBYTE) img_start - + ntheader->OptionalHeader.SizeOfImage); - if (((void *) func < (void *) cygwin_hmodule - || (void *) func > (void *) cygheap) - && ((void *) func < (void *) img_start || (void *) func >= img_end)) - { - MEMORY_BASIC_INFORMATION mbi; - wchar_t modname[PATH_MAX]; - - VirtualQuery ((PVOID) func, &mbi, sizeof mbi); - GetModuleFileNameW ((HMODULE) mbi.AllocationBase, modname, - PATH_MAX); - /* Fetch basename and check against list of above system DLLs. */ - const wchar_t *modbasename = wcsrchr (modname, L'\\') + 1; - if (!bsearch (modbasename, well_known_dlls, - sizeof well_known_dlls / sizeof well_known_dlls[0], - sizeof well_known_dlls[0], dll_cmp)) - small_printf ("\n\nPotential BLODA detected! Thread function " - "called outside of Cygwin DLL:\n %W\n\n", - modname); - } -} - void _cygtls::call2 (DWORD (*func) (void *, void *), void *arg, void *buf) { @@ -99,11 +35,7 @@ _cygtls::call2 (DWORD (*func) (void *, void *), void *arg, void *buf) sense to call init_thread or perform BLODA detection. pthread_wrapper eventually calls init_thread by itself. */ if ((void *) func != (void *) pthread_wrapper) - { - init_thread (buf, func); - if (detect_bloda) - bloda_detect (func); - } + init_thread (buf, func); DWORD res = func (arg, buf); remove (INFINITE); |