做者:huity
出處:http://www.javashuo.com/article/p-swxwfauk-e.html
版權:本文版權歸做者全部。文章在博客園、看雪、我的博客同時發佈。
轉載:歡迎轉載,但未經做者贊成,必須保留此段聲明;必須在文章中給出原文鏈接;不然必究法律責任。html
kd> !pool fffffa8003f42000 Pool page fffffa8003f42000 region is Nonpaged pool *fffffa8003f42000 size: 410 previous size: 0 (Free) *Irp Pooltag Irp : Io, IRP packets fffffa8003f42410 size: 40 previous size: 410 (Allocated) MmSe fffffa8003f42450 size: 150 previous size: 40 (Allocated) File fffffa8003f425a0 size: 80 previous size: 150 (Allocated) Even fffffa8003f42620 size: c0 previous size: 80 (Allocated) EtwR fffffa8003f426e0 size: d0 previous size: c0 (Allocated) CcBc fffffa8003f427b0 size: d0 previous size: d0 (Allocated) CcBc fffffa8003f42880 size: 20 previous size: d0 (Free) Free fffffa8003f428a0 size: d0 previous size: 20 (Allocated) Wait fffffa8003f42970 size: 80 previous size: d0 (Allocated) CM44 fffffa8003f429f0 size: 80 previous size: 80 (Allocated) Even fffffa8003f42a70 size: 80 previous size: 80 (Allocated) Even fffffa8003f42af0 size: d0 previous size: 80 (Allocated) Wait fffffa8003f42bc0 size: 80 previous size: d0 (Allocated) CM44 fffffa8003f42c40 size: d0 previous size: 80 (Allocated) Wait fffffa8003f42d10 size: 230 previous size: d0 (Allocated) ALPC fffffa8003f42f40 size: c0 previous size: 230 (Allocated) EtwR
因爲許多池分配存儲在同一頁面中,所以每一個驅動程序僅使用已分配的空間相當重要。若是DriverA使用的空間比分配的空間多,則會寫入下一個驅動程序的空間(DriverB)並損壞DriverB的數據。將這種覆蓋到下一個驅動程序的空間的狀況稱爲緩衝區溢出。接着,內存管理器或DriverB將嘗試使用此損壞的內存,並將遇到意外的信息。這種意外信息一般會致使藍屏(BSOD)。數據庫
kd> !analyze -v ******************************************************************************* * * * Bugcheck Analysis * * * ******************************************************************************* SYSTEM_SERVICE_EXCEPTION (3b) An exception happened while executing a system service routine. Arguments: Arg1: 00000000c0000005, Exception code that caused the bugcheck Arg2: fffff8009267244a, Address of the instruction which caused the bugcheck Arg3: fffff88004763560, Address of the context record for the exception that caused the bugcheck Arg4: 0000000000000000, zero.
CONTEXT: fffff88004763560 -- (.cxr 0xfffff88004763560;r)
kd> .cxr 0xfffff88004763560 rax=4f4f4f4f4f4f4f4f rbx=fffff80092690460 rcx=fffff800926fbc60 rdx=0000000000000000 rsi=0000000000001000 rdi=0000000000000000 rip=fffff8009267244a rsp=fffff88004763f60 rbp=fffff8009268fb40 r8=fffffa8001a1b820 r9=0000000000000001 r10=fffff800926fbc60 r11=0000000000000011 r12=0000000000000000 r13=fffff8009268fb48 r14=0000000000000012 r15=000000006374504d iopl=0 nv up ei pl nz na po nc cs=0010 ss=0018 ds=002b es=002b fs=0053 gs=002b efl=00010206 nt!ExAllocatePoolWithTag+0x442: fffff800`9267244a 4c8b4808 mov r9,qword ptr [rax+8] ds:002b:4f4f4f4f`4f4f4f57=????????????????
kd> ub . nt!KzAcquireQueuedSpinLock [inlined in nt!ExAllocatePoolWithTag+0x421]: fffff800`92672429 488d542440 lea rdx,[rsp+40h] fffff800`9267242e 49875500 xchg rdx,qword ptr [r13] fffff800`92672432 4885d2 test rdx,rdx fffff800`92672435 0f85c3030000 jne nt!ExAllocatePoolWithTag+0x7ec (fffff800`926727fe) fffff800`9267243b 48391b cmp qword ptr [rbx],rbx fffff800`9267243e 0f8464060000 je nt!ExAllocatePoolWithTag+0xa94 (fffff800`92672aa8) fffff800`92672444 4c8b03 mov r8,qword ptr [rbx] fffff800`92672447 498b00 mov rax,qword ptr [r8]
kd> dq fffffa8001a1b820 l1
fffffa80`01a1b820 4f4f4f4f`4f4f4f4f
kd> !pool fffffa8001a1b820 Pool page fffffa8001a1b820 region is Nonpaged pool fffffa8001a1b000 size: 810 previous size: 0 (Allocated) None
kd> !pool fffffa8001a1b820 Pool page fffffa8001a1b820 region is Nonpaged pool fffffa8001a1b000 size: 810 previous size: 0 (Allocated) None fffffa8001a1b810 doesn't look like a valid small pool allocation, checking to see if the entire page is actually part of a large page allocation... fffffa8001a1b810 is not a valid large pool allocation, checking large session pool... fffffa8001a1b810 is freed (or corrupt) pool Bad previous allocation size @fffffa8001a1b810, last size was 81 *** *** An error (or corruption) in the pool was detected; *** Attempting to diagnose the problem. *** *** Use !poolval fffffa8001a1b000 for more details. Pool page [ fffffa8001a1b000 ] is __inVALID. Analyzing linked list... [ fffffa8001a1b000 --> fffffa8001a1b010 (size = 0x10 bytes)]: Corrupt region Scanning for single bit errors... None found
kd> dq fffffa8001a1b000 + 810 fffffa80`01a1b810 4f4f4f4f`4f4f4f4f 4f4f4f4f`4f4f4f4f fffffa80`01a1b820 4f4f4f4f`4f4f4f4f 4f4f4f4f`4f4f4f4f fffffa80`01a1b830 4f4f4f4f`4f4f4f4f 00574f4c`46524556 fffffa80`01a1b840 00000000`00000000 00000000`00000000 fffffa80`01a1b850 00000000`00000000 00000000`00000000 fffffa80`01a1b860 00000000`00000000 00000000`00000000 fffffa80`01a1b870 00000000`00000000 00000000`00000000 fffffa80`01a1b880 00000000`00000000 00000000`00000000
kd> !for_each_module s -a @#Base @#End "None" fffff800`92411bc2 4e 6f 6e 65 e9 45 04 26-00 90 90 90 90 90 90 90 None.E.&........ kd> u fffff800`92411bc2-1 nt!ExAllocatePool+0x1: fffff800`92411bc1 b84e6f6e65 mov eax,656E6F4Eh fffff800`92411bc6 e945042600 jmp nt!ExAllocatePoolWithTag (fffff800`92672010) fffff800`92411bcb 90 nop
None - <unknown> - call to ExAllocatePool
verifier /flags 1 /driver myfault.sys
kd> !analyze -v ******************************************************************************* * * * Bugcheck Analysis * * * ******************************************************************************* DRIVER_PAGE_FAULT_BEYOND_END_OF_ALLOCATION (d6) N bytes of memory was allocated and more than N bytes are being referenced. This cannot be protected by try-except. When possible, the guilty driver's name (Unicode string) is printed on the bugcheck screen and saved in KiBugCheckDriver. Arguments: Arg1: fffff9800b5ff000, memory referenced Arg2: 0000000000000001, value 0 = read operation, 1 = write operation Arg3: fffff88004f834eb, if non-zero, the address which referenced memory. Arg4: 0000000000000000, (reserved)
kd> k Child-SP RetAddr Call Site fffff880`04822658 fffff803`721333f1 nt!KeBugCheckEx fffff880`04822660 fffff803`720acacb nt! ?? ::FNODOBFM::`string'+0x33c2b fffff880`04822700 fffff803`7206feee nt!MmAccessFault+0x55b fffff880`04822840 fffff880`04f834eb nt!KiPageFault+0x16e fffff880`048229d0 fffff880`04f83727 myfault+0x14eb fffff880`04822b20 fffff803`72658a4a myfault+0x1727 fffff880`04822b80 fffff803`724476c7 nt!IovCallDriver+0xba fffff880`04822bd0 fffff803`7245c8a6 nt!IopXxxControlFile+0x7e5 fffff880`04822d60 fffff803`72071453 nt!NtDeviceIoControlFile+0x56 fffff880`04822dd0 000007fc`4fe22c5a nt!KiSystemServiceCopyEnd+0x13 00000000`004debb8 00000000`00000000 0x000007fc`4fe22c5a
kd> !pool fffff9800b5ff000 Pool page fffff9800b5ff000 region is Special pool fffff9800b5ff000: Unable to get contents of special pool block
kd> !pte fffff9800b5ff000 VA fffff9800b5ff000 PXE at FFFFF6FB7DBEDF98 PPE at FFFFF6FB7DBF3000 PDE at FFFFF6FB7E6002D0 PTE at FFFFF6FCC005AFF8 contains 0000000001B8F863 contains 000000000138E863 contains 000000001A6A1863 contains 0000000000000000 pfn 1b8f ---DA--KWEV pfn 138e ---DA--KWEV pfn 1a6a1 ---DA--KWEV not valid
kd> !pool fffff9800b5ff000-1000 Pool page fffff9800b5fe000 region is Special pool *fffff9800b5fe000 size: 800 data: fffff9800b5fe800 (NonPaged) *Wrap Owning component : Unknown (update pooltag.txt)
BAD_POOL_CALLER (c2) The current thread is making a bad pool request. Typically this is at a bad IRQL level or double freeing the same allocation, etc. Arguments: Arg1: 0000000000000007, Attempt to free pool which was already freed Arg2: 00000000000011c1, (reserved) Arg3: 0000000004810007, Memory contents of the pool block Arg4: fffffa8001b10800, Address of the block of pool being deallocated
verifier /flags 1 /driver myfault.sys
PAGE_FAULT_IN_NONPAGED_AREA (50) Invalid system memory was referenced. This cannot be protected by try-except, it must be protected by a Probe. Typically the address is just plain bad or it is pointing at freed memory. Arguments: Arg1: fffff9800a7fe7f0, memory referenced. Arg2: 0000000000000000, value 0 = read operation, 1 = write operation. Arg3: fffff80060263888, If non-zero, the instruction address which referenced the bad memory address. Arg4: 0000000000000002, (reserved)
kd> kn # Child-SP RetAddr Call Site 00 fffff880`0419fe28 fffff800`5fd7e28a nt!DbgBreakPointWithStatus 01 fffff880`0419fe30 fffff800`5fd7d8de nt!KiBugCheckDebugBreak+0x12 02 fffff880`0419fe90 fffff800`5fc5b544 nt!KeBugCheck2+0x79f 03 fffff880`041a05b0 fffff800`5fd1c5bc nt!KeBugCheckEx+0x104 04 fffff880`041a05f0 fffff800`5fc95acb nt! ?? ::FNODOBFM::`string'+0x33e2a 05 fffff880`041a0690 fffff800`5fc58eee nt!MmAccessFault+0x55b 06 fffff880`041a07d0 fffff800`60263888 nt!KiPageFault+0x16e 07 fffff880`041a0960 fffff800`6024258c nt!ExFreePoolSanityChecks+0xe8 08 fffff880`041a09a0 fffff880`04c9b5d9 nt!VerifierExFreePoolWithTag+0x3c 09 fffff880`041a09d0 fffff880`04c9b727 myfault!MyfaultDeviceControl+0x2fd 0a fffff880`041a0b20 fffff800`60241a4a myfault!MyfaultDispatch+0xb7 0b fffff880`041a0b80 fffff800`600306c7 nt!IovCallDriver+0xba 0c fffff880`041a0bd0 fffff800`600458a6 nt!IopXxxControlFile+0x7e5 0d fffff880`041a0d60 fffff800`5fc5a453 nt!NtDeviceIoControlFile+0x56 0e fffff880`041a0dd0 000007fd`ea212c5a nt!KiSystemServiceCopyEnd+0x13
kd> dd fffff9800a7fe7f0 fffff980`0a7fe7f0 ???????? ???????? ???????? ???????? fffff980`0a7fe800 ???????? ???????? ???????? ???????? fffff980`0a7fe810 ???????? ???????? ???????? ???????? fffff980`0a7fe820 ???????? ???????? ???????? ???????? fffff980`0a7fe830 ???????? ???????? ???????? ???????? fffff980`0a7fe840 ???????? ???????? ???????? ???????? fffff980`0a7fe850 ???????? ???????? ???????? ???????? fffff980`0a7fe860 ???????? ???????? ???????? ???????? kd> !pte fffff9800a7fe7f0 VA fffff9800a7fe7f0 PXE at FFFFF6FB7DBEDF98 PPE at FFFFF6FB7DBF3000 PDE at FFFFF6FB7E600298 PTE at FFFFF6FCC0053FF0 contains 0000000002A91863 contains 0000000002A10863 contains 0000000000000000 pfn 2a91 ---DA--KWEV pfn 2a10 ---DA--KWEV not valid
kd> .frame /r 9 09 fffff880`041a09d0 fffff880`04c9b727 myfault+0x15d9 rax=0000000000000000 rbx=fffff9800a7fe800 rcx=fffff9800a7fe800 rdx=fffffa8001a37fa0 rsi=fffffa80035975e0 rdi=fffffa8003597610 rip=fffff88004c9b5d9 rsp=fffff880041a09d0 rbp=fffffa80034568d0 r8=fffff9800a7fe801 r9=fffff9800a7fe7f0 r10=fffff9800a7fe800 r11=0000000000000000 r12=0000000000000000 r13=0000000000000000 r14=fffff800600306c7 r15=fffffa8004381b80 iopl=0 nv up ei ng nz na po nc cs=0010 ss=0018 ds=002b es=002b fs=0053 gs=002b efl=00000286 myfault+0x15d9: fffff880`04c9b5d9 eb7a jmp myfault+0x1655 (fffff880`04c9b655)
kd> ub fffff880`04c9b5d9 myfault+0x15ba: fffff880`04c9b5ba ff15a80a0000 call qword ptr [myfault+0x2068 (fffff880`04c9c068)] fffff880`04c9b5c0 33d2 xor edx,edx fffff880`04c9b5c2 488bc8 mov rcx,rax fffff880`04c9b5c5 488bd8 mov rbx,rax fffff880`04c9b5c8 ff154a0a0000 call qword ptr [myfault+0x2018 (fffff880`04c9c018)] fffff880`04c9b5ce 33d2 xor edx,edx fffff880`04c9b5d0 488bcb mov rcx,rbx fffff880`04c9b5d3 ff153f0a0000 call qword ptr [myfault+0x2018 (fffff880`04c9c018)]
kd> !verifier 80 fffff9800a7fe800
====================================================================== Pool block fffff9800a7fe800, Size 0000000000000800, Thread fffffa80046ce4c0 fffff80060251a32 nt!VfFreePoolNotification+0x4a fffff8005fe736c9 nt!ExFreePool+0x595 fffff80060242597 nt!VerifierExFreePoolWithTag+0x47 fffff88004c9b5ce myfault!MyfaultDeviceControl+0x2f2 fffff88004c9b727 myfault!MyfaultDispatch+0xb7 fffff80060241a4a nt!IovCallDriver+0xba fffff800600306c7 nt!IopXxxControlFile+0x7e5 fffff800600458a6 nt!NtDeviceIoControlFile+0x56 fffff8005fc5a453 nt!KiSystemServiceCopyEnd+0x13 ====================================================================== Pool block fffff9800a7fe800, Size 0000000000000800, Thread fffffa80046ce4c0 fffff80060242a5d nt!VeAllocatePoolWithTagPriority+0x2d1 fffff8006024b20e nt!XdvExAllocatePoolInternal+0x12 fffff80060242f69 nt!VerifierExAllocatePool+0x61 fffff88004c9b5c0 myfault!MyfaultDeviceControl+0x2e4 fffff88004c9b727 myfault!MyfaultDispatch+0xb7 fffff80060241a4a nt!IovCallDriver+0xba fffff800600306c7 nt!IopXxxControlFile+0x7e5 fffff800600458a6 nt!NtDeviceIoControlFile+0x56 fffff8005fc5a453 nt!KiSystemServiceCopyEnd+0x13