Remove CYGWIN=detect_bloda option
This commit is contained in:
@@ -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);
|
||||
|
@@ -110,7 +110,6 @@ static struct parse_thing
|
||||
} values[2];
|
||||
} known[] NO_COPY =
|
||||
{
|
||||
{"detect_bloda", {&detect_bloda}, setbool, NULL, {{false}, {true}}},
|
||||
{"dosfilewarning", {&dos_file_warning}, setbool, NULL, {{false}, {true}}},
|
||||
{"error_start", {func: error_start_init}, isfunc, NULL, {{0}, {0}}},
|
||||
{"export", {&export_settings}, setbool, NULL, {{false}, {true}}},
|
||||
|
@@ -65,7 +65,6 @@ int NO_COPY dynamically_loaded;
|
||||
|
||||
/* Some CYGWIN environment variable variables. */
|
||||
bool allow_glob = true;
|
||||
bool detect_bloda;
|
||||
bool dos_file_warning;
|
||||
bool ignore_case_with_glob;
|
||||
bool pipe_byte;
|
||||
|
@@ -560,18 +560,6 @@ fdsock (cygheap_fdmanip& fd, const device *dev, SOCKET soc)
|
||||
debug_printf ("WSAIoctl: %u", WSAGetLastError ());
|
||||
else if (base_soc != soc)
|
||||
{
|
||||
/* LSPs are often BLODAs as well. So we print an info about
|
||||
detecting an LSP if BLODA detection is desired. */
|
||||
if (detect_bloda)
|
||||
{
|
||||
WSAPROTOCOL_INFO prot;
|
||||
|
||||
memset (&prot, 0, sizeof prot);
|
||||
::getsockopt (soc, SOL_SOCKET, SO_PROTOCOL_INFO, (char *) &prot,
|
||||
(size = sizeof prot, &size));
|
||||
small_printf ("\n\nPotential BLODA detected! Layered Socket "
|
||||
"Service Provider:\n %s\n\n", prot.szProtocol);
|
||||
}
|
||||
if (GetHandleInformation ((HANDLE) base_soc, &flags)
|
||||
&& (flags & HANDLE_FLAG_INHERIT))
|
||||
{
|
||||
|
Reference in New Issue
Block a user