Hi,
We have a legacy filter driver which crashes randomly. The crash occurs
while sending IRP_MJ_CLEAN
operation for my FileObject which was created using
IoCreateStreamFileObject. This FileObject is created
for IRP_MJ_DIRECTORY_CONTROL (IRP_MN_QUERY_DIRECTORY).
So I did the following steps:
- Call IoCreateStreamFileObject. Set FileNameBuffer.
I compared my code with the code outlined here :
http://www.osronline.com/showThread.cfm?link=78034
I feel that I have found the reason for crash but I want to confirm if that
is the reason.
The crash is occuring in nt!FsRtlNotifyFilterReportChange while accessing
FileNameBuffer in FileObject. As
outlined the in the code at the above link, we were also doing same thing.
We were freeing FileNameBuffer
before doing cleanup. But then there was comment that we need to do that
after cleanup.
Question :
- Shall we free the FileNameBuffer after Cleanup as mentioned below:
A couple of comments on my orignal posting… Defending the indefensible
There is a bug in the post-create freeing of the filename buffer. This
code should be moved to after the CLEANUP has completed. Why? 'cause either
NTFS or the CM may keep a copy of a pointer to this Unicode buffer. Freeing
it prematurely caused some interesting BugChecks in the Verifier in NTFS.
2) We are also not copying flags as mentioned in the code
// cloneFileObject->Flags &= ~(FO_STREAM_FILE | FO_HANDLE_CREATED |
FO_CLEANUP_COMPLETE);
cloneFileObject->Flags = fileObject->Flags;
cloneFileObject->RelatedFileObject = fileObject->RelatedFileObject;
Is it required?
- After cleanup, we send the IRP_MJ_CLOSE. However this step is not
mentioned. So do we require that step
or IO manager will send that when reference counts goes 0. So when we should
send IRP_MJ_CLOSE for our
FileObject. Do its require remving and setting FO_STREAM_FILE
- I searched the list for FsControl field in FileObject returned by
IoCreateStreamFIleObject. I have seen
this comment:
Just so everyone is clear on this. With the introduction of the filter
manager it is now a requirement for
all file systems to use at least the COMMON_FCB_HEADER and we strongly
encourage all file systems to use
the AVANCED_FCB_HEADER. If there are released file systems that don’t and it
runs on W2K or later they need
to be fixed ASAP because the machine will crash when minifilters start being
released.
Neal Christiansen
Microsoft File System Filter Group Lead
We do not initialize FsContext field but we do set it to NULL after sending
down IRP_MJ_CLOSE. However, sometimes
we get crash in CacheManager while accessing the FsContext. So I think we
should not touch it.
Any help is greatly appreciated as we are having lot of crashes at customer
location.
Thanks
Ashish