Re[2]: Isolation filter related crash

Any filter which takes ownership of the FO should not be allowed to
unload.

If you have a ref counting issue, verifier may not pick up the problem.
You would free the memory and later it would be accessed by some other
component, verifier will not pick this up other than when the invalid
buffer is accessed and a BSOD follows.

Pete


Kernel Drivers
Windows File System and Device Driver Consulting
www.KernelDrivers.com
866.263.9295

------ Original Message ------
From: xxxxx@gmail.com
To: “Windows File Systems Devs Interest List”
Sent: 3/21/2017 12:16:03 PM
Subject: RE:[ntfsd] Isolation filter related crash

>


>The offending address is not found with !verifier 80
>
>


>The FsContext is pointing to invalid memory. That too is not found
>with !verifier 80. The FsContext2 does point to valid memory but it
>looks like it’s was already reallocated by something else.
>
>


>Upper
>
>


>Another file on the same volume
>
>I haven’t been able to recreate this crash and again it doesn’t make a
>lot of sense to me about how it’s happening. I was thinking that I
>might have an issue with reference counting but I would assume verifier
>would pick that up.
>
>Related to that, and your point about the forced teardown made me think
>of it, should an isolation filter be allowed to unload? Because if an
>app opens a file and a SFO is created but then the driver is unloaded
>and FLTMGR forces an unload, as soon as that app does any operation on
>that outstanding FO, it’ll BSOD with the NtfsDecode error. Or will the
>driver not unload until all FOs are closed (which can take a long
>time).
>
>
>—
>NTFSD is sponsored by OSR
>
>
>MONTHLY seminars on crash dump analysis, WDF, Windows internals and
>software drivers!
>Details at http:
>
>To unsubscribe, visit the List Server section of OSR Online at
>http:</http:></http:>

> Related to that, and your point about the forced teardown made me think of

it, should an isolation filter be allowed to unload?

It can only do so it is no longer managing upper file objects. In practice
these days means “never unless you are only attached to a very boring
volume”. So once I was relatively sure that I had no egregious pool leaks
I’d rip the unload code out. Certainly from release builds.

As for your problem I’m relatively convinced that you have a refcounting
issue with UpperFDileObject->FsContext.

R

Peter, Rod,
Thanks for both of your feedback.

I still haven’t been able to recreate the crash but I did a pretty thorough review the past few days and found a few areas that were not handled properly which may have contributed to it (SL_OPEN_TARGET_DIR and the situation described here http://www.osronline.com/ShowThread.cfm?link=162127). So with the changes, I’m back to square one until I get another crash. However, through my testing, I did find cases where certain directories are not being closed. So again, probably a ref count issue but I’m having trouble figuring out where and why it only happens occasionally. The same folder can be opened multiple times with the same options and access and share requests but some just stick around. After trying to unload, I get the Verifier warning.

1: kd> !fltkd.filter FFFFE00091C903D0 8 1

FLT_FILTER: ffffe00091c903d0 “141300”
InstanceList : (ffffe00091c90438)
Resource (ffffe00091c904a0) List [ffffe00091c904a0-ffffe00091c904a0] rCount=0
Object usage/reference information:
References to FLT_CONTEXT : 0
Allocations of FLT_CALLBACK_DATA : 0
Allocations of FLT_DEFERRED_IO_WORKITEM : 0
Allocations of FLT_GENERIC_WORKITEM : 0
References to FLT_FILE_NAME_INFORMATION : 0
Open files : 4
References to FLT_OBJECT : 0
List of objects used/referenced::
FLT_VERIFIER_OBJECT: ffffe000915e91b0
Object: ffffe0008f616450 Type: FILE_OBJECT RefCount: 00000001
FLT_VERIFIER_OBJECT: ffffe0008f8c9b30
Object: ffffe0008f86d520 Type: FILE_OBJECT RefCount: 00000001
FLT_VERIFIER_OBJECT: ffffe00091256a40
Object: ffffe0009176f340 Type: FILE_OBJECT RefCount: 00000001
FLT_VERIFIER_OBJECT: ffffe00091de6bb0
Object: ffffe00091acf420 Type: FILE_OBJECT RefCount: 00000001

1: kd> dt ffffe0008f616450 _FILE_OBJECT
FLTMGR!_FILE_OBJECT
+0x000 Type : 0n5
+0x002 Size : 0n216
+0x008 DeviceObject : 0xffffe0008f2cfa70 _DEVICE_OBJECT +0x010 Vpb : 0xffffe000917319a0 _VPB
+0x018 FsContext : 0xffffc00063c53da0 Void +0x020 FsContext2 : 0xffffc000643fb800 Void
+0x028 SectionObjectPointer : (null)
+0x030 PrivateCacheMap : (null)
+0x038 FinalStatus : 0n0
+0x040 RelatedFileObject : (null)
+0x048 LockOperation : 0 ‘’
+0x049 DeletePending : 0 ‘’
+0x04a ReadAccess : 0x1 ‘’
+0x04b WriteAccess : 0 ‘’
+0x04c DeleteAccess : 0 ‘’
+0x04d SharedRead : 0x1 ‘’
+0x04e SharedWrite : 0x1 ‘’
+0x04f SharedDelete : 0x1 ‘’
+0x050 Flags : 0x40000
+0x058 FileName : _UNICODE_STRING "— memory read error at address 0xffffc00063088c30 ---" +0x068 CurrentByteOffset : _LARGE_INTEGER 0x0 +0x070 Waiters : 0 +0x074 Busy : 0 +0x078 LastLock : (null) +0x080 Lock : _KEVENT +0x098 Event : _KEVENT +0x0b0 CompletionContext : (null) +0x0b8 IrpListLock : 0 +0x0c0 IrpList : _LIST_ENTRY [0xffffe0008f616510 - 0xffffe0008f616510] +0x0d0 FileObjectExtension : 0xffffcf811fc5efb0 Void
1: kd> !object ffffe0008f616450
Object: ffffe0008f616450 Type: (ffffe0008e199b00) File
ObjectHeader: ffffe0008f616420 (new version)
HandleCount: 1 PointerCount: 32768
Directory Object: 00000000 Name: (*** Name not accessible ***) {HarddiskVolume2}
1: kd> !findhandle ffffe0008f616450
Now checking process ffffe0008e083040… WARNING: Could not read handle data at ffffc00060817000. All handles skipped from 0 to 400.

[ffffe0008e083040 System]
b90: Entry ffffc00061a08e40 Granted Access 100081 (Inherit)

1: kd> !trueref ffffe0008f616450
ffffe0008f616450: HandleCount: 1 PointerCount: 32768 RealPointerCount: 2

FsContext and FsContext2 look to be bogus so those context appear to have been torn down.

1: kd> dt 0xffffc000643fb800 _STREAM_HANDLE_CONTEXT +0x000 Ctx : 0x0000080000480507 _INSTANCE_CONTEXT
+0x008 StreamContext : (null)
+0x010 FileName : _UNICODE_STRING “”
+0x020 Cipher : _UNICODE_STRING “”
+0x030 UpperFileObject : (null)
+0x038 LowerFileObject : (null)
+0x040 LowerFileHandle : (null)
+0x048 Resource : 0x00000047004e4f49 _ERESOURCE +0x050 LazyWriteThread : 0x7346744e03040206 _KTHREAD
+0x058 LastWritePaddingAdded : 0x265f13b5
+0x060 LastCacheWriteSize : _LARGE_INTEGER 0xffffc00063d6fa50 +0x068 UpperShareAccess : _SHARE_ACCESS +0x084 LowerShareAccess : _SHARE_ACCESS +0x0a0 SHA2Init : 0x4 '' +0x0a8 SHA2 : _SHA256_CTX 1: kd\> dt 0xffffc00063c53da0 _FSRTL_ADVANCED_FCB_HEADER
FLTMGR!_FSRTL_ADVANCED_FCB_HEADER
+0x000 NodeTypeCode : 0n1283
+0x002 NodeByteSize : 0n608
+0x004 Flags : 0x40 ‘@’
+0x005 IsFastIoPossible : 0 ‘’
+0x006 Flags2 : 0x2 ‘’
+0x007 Reserved : 0y0000
+0x007 Version : 0y0011
+0x008 Resource : 0xffffe000921120e0 _ERESOURCE +0x010 PagingIoResource : 0xffffe00091cb7a00 _ERESOURCE
+0x018 AllocationSize : _LARGE_INTEGER 0x8000
+0x020 FileSize : _LARGE_INTEGER 0x8000
+0x028 ValidDataLength : _LARGE_INTEGER 0x7fffffffffffffff +0x030 FastMutex : 0xffffe0008fa3d568 _FAST_MUTEX
+0x038 FilterContexts : _LIST_ENTRY [0xffffc00063c53dd8 - 0xffffc00063c53dd8]
+0x048 PushLock : 0
+0x050 FileContextSupportPointer : (null)
+0x058 Oplock : (null)
+0x058 ReservedForRemote : (null)
+0x060 ReservedContext : 0xffffe000`8f5069e8 Void