-
Notifications
You must be signed in to change notification settings - Fork 570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dbghelp!MiniDumpWriteDump exits silently when called from client #1292
Comments
From [email protected] on October 23, 2013 11:44:03 I split out some other issues hit after fixing this bug into their own issues. This is a good stress test of some missing pieces in our private library isolation and redirection:
|
From [email protected] on October 23, 2013 11:44:13 ** DONE (issue #235) now MiniDumpWriteDump executes, but returns failure b/c we don't redirect LdrGetProcedureAddress
GetLastError() is: works natively. *** DONE even on app using user32, still get 0x80004001: tracking it down This guy returns 0x80004001, and MiniDumpWriteDump, who called 0:000> U 63e1a971 Continuing in to callees: dbghelp!GenGetProcessInfo+0x43: dbghelp!NtWin32LiveSystemProvider::StartProcessEnum+0x13: Here is where the 0x80004001 is set: 0:000> U 63e21ed5 ecx is passed through from GenGetProcessInfo, who gets it from its 1st ultimately coming from here: is it dbghelp!GenAllocateProcessObject who sets it up? ebp+10 is 3rd param, which is esp+28 in caller: at that point, esp is -0x24 from after the sub of 0x44 at entry it's zeroed here: then written here: 0:000> dd esi So it's a C++ object instance, and the field at +0x30 stores: 0:000> U poi(esi+30) Object is allocated in dbghelp!NewNtWin32LiveSystemProvider That field is filled in here: 0:000> U esi 0:000> dd edi+10 75bf0000 75d00000 kernel32 (pdb symbols) c:\src\symbols\wkernel32.pdb\139CA12C1AB645F6A7F2DD1A098696692\wkernel32.pdb 0:000> U poi(dbghelp!_imp__GetProcAddress) *** DONE (issue #235) now, what goes wrong w/ that custom GetProcAddress? => have to intercept LdrGetProcedureAddress It is passing private kernel32 base. Xref issue #450 where I encountered this dbghelp!ResolveThunk and concluded I Here it ends up at priv kernel32 GetProcAddressStub.
0:000> U 002a1e33 It passes 0 for ordinal at least: |
From [email protected] on October 23, 2013 11:44:44 ** DONE (issue #235) have to intercept LdrLoadDll to catch kernelbase calling its own LoadLibraryExW
Still working on the client in issue #1292 , we now hit an ASSERT 0:000> kn ChildEBP RetAddr00 1a9ed6a4 636adf4e ntdll!ZwRaiseHardError+0x12 intercept_load_dll: kernel32.dll 0:000> U 022a66b5 -5 LoadLibraryExW: file handle arg must be NULL, so it's just the flags, and Yet here it's kernelbase code calling its own routine, so import 0:000> U 002c66b5 -5 So we need a hook. Xref hooks needed for other cases: issue #450. Although this is a simple replacement: so we just need a jmp to our Or, can we just redirect LdrLoadDll? How much work is kernelbase doing? |
From [email protected] on October 23, 2013 11:46:17 After:
|
From [email protected] on October 23, 2013 11:59:28 The remaining issues, none of which are likely to be solvable easily, are:
|
From [email protected] on October 23, 2013 12:44:23 This issue was closed by revision r2336 . Status: Fixed |
From [email protected] on October 24, 2013 07:30:11 I split the app state vs priv state as its own issue #1301 |
From [email protected] on October 22, 2013 16:50:30
A client that finds dbghelp!MiniDumpWriteDump like this:
And invokes it, ends up exiting silently.
** TODO windbg 6.3 syms messed up
0:000> x minidump!pM*
70974570 minidump!pMiniDumpWriteDump = 0x63e1abed
0:000> x dbghelp!MiniDumpWriteDump
63e170d8 dbghelp!MiniDumpWriteDump =
privload_load_finalize: loaded dbghelp.dll @ 0x63dd0000-0x63efb000 from C:\Program Files (x86)\Windo
ws Kits\8.0\Debuggers\x86\dbghelp.dll
redirect_GetProcAddress: 0x63dd0000MiniDumpWriteDump
redirect_GetProcAddress: MiniDumpWriteDump => 0x63e1abed
0:000> ln 0x63e1abed
(63e1aa7b) dbghelp!GenRemoveMemoryRange+0x172 | (63e1abf1) dbghelp!GenAddPebMemory
0:000> U 0x63e1abed
dbghelp!GenRemoveMemoryRange+0x172:
63e1abed 8bff mov edi,edi
63e1abef 55 push ebp
ok, that's something weird w/ windbg 6.3 -- w/ recent windbg we have:
0:000> x dbghelp!MiniDumpWrite*
63e1abed dbghelp!MiniDumpWriteDump ()
** TODO it's a non-access violation exit, so DR doesn't report it as a client crash
0:000> kn
ChildEBP RetAddr
00 251ee7d0 63e39d02 KERNEL32_2b0000!UnhandledExceptionFilter+0x5f
01 251eeb00 63e213db dbghelp!__report_gsfailure+0xc8
02 251eebe8 cdcdcdcd dbghelp!Win32LiveSystemProvider::GetOsInfo+0x1b6
WARNING: Frame IP not in any known module. Following frames may be wrong.
03 251eec10 63e1a92b 0xcdcdcdcd
04 251eed94 63e1adbb dbghelp!MiniDumpProvideDump+0x12a
05 251eee10 7097125f dbghelp!MiniDumpWriteDump+0x1ce
06 251eeeb4 251b109c minidump!snap_cb3+0x8f [c:\src\dr\bugs\minidump\minidump.c @ 102]
0:000> .exr -1
ExceptionAddress: 002fff55 (KERNEL32_2b0000!UnhandledExceptionFilter+0x0000005f)
ExceptionCode: 80000003 (Break instruction exception)
ExceptionFlags: 00000000
NumberParameters: 1
Parameter[0]: 00000000
Entry:
dbghelp!Win32LiveSystemProvider::GetOsInfo:
63e21225 8bff mov edi,edi
63e21227 55 push ebp
63e21228 8bec mov ebp,esp
63e2122a 81ece0000000 sub esp,0E0h
63e21230 a100d0ec63 mov eax,dword ptr [dbghelp!__security_cookie (63ecd000)]
63e21235 33c5 xor eax,ebp
63e21237 8945fc mov dword ptr [ebp-4],eax
Exit:
dbghelp!Win32LiveSystemProvider::GetOsInfo+0x1aa:
63e213cf 8b4dfc mov ecx,dword ptr [ebp-4]
63e213d2 5e pop esi
63e213d3 33cd xor ecx,ebp
63e213d5 5b pop ebx
63e213d6 e8b8870100 call dbghelp!__security_check_cookie (63e39b93)
63e213db c9 leave
63e213dc c21c00 ret 1Ch
0:000> Uf 63e39b93
dbghelp!__security_check_cookie:
63e39b93 3b0d00d0ec63 cmp ecx,dword ptr [dbghelp!__security_cookie (63ecd000)]
63e39b99 7503 jne dbghelp!__security_check_cookie+0xb (63e39b9e)
dbghelp!__security_check_cookie+0x8:
63e39b9b c20000 ret 0
dbghelp!__security_check_cookie+0xb:
63e39b9e e997000000 jmp dbghelp!__report_gsfailure (63e39c3a)
dbghelp!__report_gsfailure:
63e39c3a 8bff mov edi,edi
...
63e39cef 6a00 push 0
63e39cf1 ff15a4a3ee63 call dword ptr [dbghelp!_imp__SetUnhandledExceptionFilter (63eea3a4)]
63e39cf7 687c10dd63 push offset dbghelp!__xi_z+0x2c (63dd107c)
63e39cfc ff15a8a3ee63 call dword ptr [dbghelp!_imp__UnhandledExceptionFilter (63eea3a8)]
63e39d02 c785dcfcffff01000000 mov dword ptr [ebp-324h],1
63e39d0c 68090400c0 push 0C0000409h
63e39d11 ff1524a4ee63 call dword ptr [dbghelp!_imp__GetCurrentProcess (63eea424)]
63e39d17 50 push eax
63e39d18 ff15a0a3ee63 call dword ptr [dbghelp!_imp__TerminateProcess (63eea3a0)]
63e39d1e c9 leave
63e39d1f c3 ret
0:000> r
eax=00000000 ebx=24a7ed20 ecx=e96a2625 edx=00000000 esi=00000000 edi=24a7ecf8
0:000> dd dbghelp!__security_cookie
63ecd000 addcb782 5223487d 00000000 00000000
** TODO the culprit bug
Stepping through it, ebp-4 is clobbered after the xor'ed value is stored
there by our own memcpy:
0:000> bl
0 e 63e21225 0001 (0001) 0:* dbghelp!Win32LiveSystemProvider::GetOsInfo
1 e 19e9ebe4 w 4 0001 (0001) 0:*
2 e 63ecd000 w 4 0001 (0001) 0:* dbghelp!__security_cookie
3 e 63e213cf 0001 (0001) 0:* dbghelp!Win32LiveSystemProvider::GetOsInfo+0x1aa
0:000> g
Breakpoint 1 hit
0:000> kn
ChildEBP RetAddr
00 19e9e8b0 64237e9f ntdll!memcpy+0x33
01 19e9eae0 63e21391 dynamorio!redirect_RegQueryValueExA+0x18f [c:\src\dr\git\src\core\win32\drwinapi\advapi32_redir.c @ 290]
02 19e9ebe8 63e1a620 dbghelp!Win32LiveSystemProvider::GetOsInfo+0x16c
03 19e9ec10 63e1a92b dbghelp!GetSystemType+0xa2
04 19e9ed94 63e1adbb dbghelp!MiniDumpProvideDump+0x12a
05 19e9ee10 7097125f dbghelp!MiniDumpWriteDump+0x1ce
06 19e9eeb4 19e6109c minidump!snap_cb3+0x8f [c:\src\dr\bugs\minidump\minidump.c @ 102]
0:000> .frame 1
01 19e9eae0 63e21391 dynamorio!redirect_RegQueryValueExA+0x18f [c:\src\dr\git\src\core\win32\drwinapi\advapi32_redir.c @ 290]
0:000> dv
buf = 0x19ee4c44 "Multiprocessor Free"
prev_sofar = 0
sofar = 0x14
hKey = 0x00000094
lpValueName = 0x63de81f8 "CurrentType"
lpReserved = 0x00000000
lpType = 0x19e9eb14
lpData = 0x19e9ebbc "Multiprocessor Free"
lpcbData = 0x19e9eb18
wbuf = wchar_t [255] "CurrentType"
len = 0n11
max_len = 0x28
type = 1
res = 0n0
0:000> ?? *lpcbData
unsigned long 0x34
0:000> ?? lpData + *lpcbData
unsigned char * 0x19e9ebf0
dbghelp!Win32LiveSystemProvider::GetOsInfo+0x13d:
63e21362 8d8530ffffff lea eax,[ebp-0D0h]
63e21368 50 push eax
63e21369 8d45d4 lea eax,[ebp-2Ch]
63e2136c 50 push eax
63e2136d 8d852cffffff lea eax,[ebp-0D4h]
63e21373 50 push eax
63e21374 6a00 push 0
63e21376 68f881de63 push offset dbghelp!`string' (63de81f8)
63e2137b ffb534ffffff push dword ptr [ebp-0CCh]
63e21381 c78530ffffff28000000 mov dword ptr [ebp-0D0h],28h
63e2138b ff1508a3ee63 call dword ptr [dbghelp!_imp__RegQueryValueExA (63eea308)]
hmm, so the max len was upped from 0x28 to 0x34 by
redirect_RegQueryValueExA? ok, it fails to remove the rest of
KEY_VALUE_PARTIAL_INFORMATION in redirect_RegQueryValueExW.
Original issue: http://code.google.com/p/dynamorio/issues/detail?id=1292
The text was updated successfully, but these errors were encountered: