Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results
The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.
Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/
According to my understanding of the docs, this should not happen. Since it is happening...
Code in a PostOp callback:
KIRQL irqLevel = KeGetCurrentIrql(); NTSTATUS status = 0; PFLT_FILE_NAME_INFORMATION pFileNameInformation = NULL; if ( (FlagOn(Data->Iopb->OperationFlags, SL_OPEN_PAGING_FILE)) || (FlagOn(Flags, FLTFL_POST_OPERATION_DRAINING)) ) return FLT_POSTOP_FINISHED_PROCESSING; if (PASSIVE_LEVEL == irqLevel) { status = FltGetFileNameInformation(Data, FLT_FILE_NAME_OPENED | FLT_FILE_NAME_QUERY_DEFAULT, &pFileNameInformation);
The above line causes a crash with the following stack:
nt!DbgBreakPointWithStatus
nt!KiBugCheckDebugBreak+0x12
nt!KeBugCheck2+0x957
nt!KeBugCheckEx+0x107
nt!KiBugCheckDispatch+0x69
nt!KiSystemServiceHandler+0x7c
nt!RtlpExecuteHandlerForException+0xf
nt!RtlDispatchException+0x430
nt!KiDispatchException+0x144
nt!KiExceptionDispatch+0xc2
nt!KiPageFault+0x428
FLTMGR!FltGetFileNameInformation+0x7b
FLTMGR!FltvGetFileNameInformation+0x51
(code shown above in a PostOp function)
FLTMGR!FltpPerformPostMountCallbacks+0x90
FLTMGR!FltpFsControlMountVolume+0x2a5
FLTMGR!FltpFsControl+0x12c
nt!IopfCallDriver+0x56
This is on a fully patched Windows Server 2019. Are there additional cases to check for with FltGetFileNameInformation?
Thanks for any light you can share on this.
Doug
Upcoming OSR Seminars | ||
---|---|---|
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead! | ||
Kernel Debugging | 30 January 2023 | Live, Online |
Developing Minifilters | 20 March 2023 | Live, Online |
Internals & Software Drivers | 17 April 2023 | Live, Online |
Writing WDF Drivers | 22 May 2023 | Live, Online |
Comments
This is not a simple PostOp, but a mount callback. Possibly aftet a
format/lock combo.
The call should not bugcheck, though, IMO, but return an error. I never
tested/tried that path though.
Dejan.
Assuming I can trust what I see in WinDbg (I'm pretty sure this is a checked build), Iopb->MajorFunction is 0xED which I don't recognize. And FltObjects->FileObject is NULL. Maybe FltGetFileNameInformation doesn't handle the NULL FileObject? That might be the case from this output
Looks more like a corruption to me, if MajorFunc is invalid.
I am not sure if FGFNI handles NULL FO, but IMO it should at least not
bugcheck
Dejan.
Sure, not a problem. Checking for NULL prevents the crash (not surprising I guess). Here is the full output with some more stack shown at the bottom. Drive name changed to protect the guilty
Hmmm, for some reason the extra stack I'm trying to post isn't showing up right. I guess I won't mark it as code...
# Child-SP RetAddr : Args to Child : Call Site
00 ffffc905
3fb0bf78 fffff804
80d4b582 : 00000000c0000005 00000000
00000003 ffffc9053fb0c0e0 fffff804
80c19ab0 : nt!DbgBreakPointWithStatus01 ffffc905
3fb0bf80 fffff804
80d4ad07 : 0000000000000003 ffffc905
3fb0c0e0 fffff80480c8a3e0 00000000
0000003b : nt!KiBugCheckDebugBreak+0x1202 ffffc905
3fb0bfe0 fffff804
80c73fa7 : fffff804164ae8c3 fffff804
816198cf ffffc9053fb0fa80 fffff804
81623508 : nt!KeBugCheck2+0x95703 ffffc905
3fb0c700 fffff804
80c87829 : 000000000000003b 00000000
c0000005 fffff80eb4cd553b ffffc905
3fb0d070 : nt!KeBugCheckEx+0x10704 ffffc905
3fb0c740 fffff804
80c86a3c : ffffc9053fb0d828 ffffc905
3fb0d070 ffffc9053fb0d828 00000000
00000000 : nt!KiBugCheckDispatch+0x6905 ffffc905
3fb0c880 fffff804
80c7e1df : fffff80480f9c000 fffff804
80abb000 0005b02000a6d000 00000000
0010001f : nt!KiSystemServiceHandler+0x7c06 ffffc905
3fb0c8c0 fffff804
80b3a990 : ffffc9053fb0cf10 00000000
00000000 ffffc9053fb0ce30 fffff804
80e4a10c : nt!RtlpExecuteHandlerForException+0xf07 ffffc905
3fb0c8f0 fffff804
80b3cc94 : ffffc9053fb0d828 ffffc905
3fb0d570 ffffc9053fb0d828 00000000
00000000 : nt!RtlDispatchException+0x43008 ffffc905
3fb0d040 fffff804
80c87902 : 0000000000000000 ffffc905
3fb0d8d0 0000000000001000 00000000
00000018 : nt!KiDispatchException+0x14409 ffffc905
3fb0d6f0 fffff804
80c834e8 : ffffad2ab7b75187 fffff804
80bd5117 fffff80400000000 00000000
00000004 : nt!KiExceptionDispatch+0xc20a ffffc905
3fb0d8d0 fffff80e
b4cd553b : 0000000000000000 fffff804
80a1faf6 ffffce0f2d10cea0 fffff80e
b4cd2c8b : nt!KiPageFault+0x428 (TrapFrame @ ffffc9053fb0d8d0) 0b ffffc905
3fb0da60 fffff80eb4d2e451 : ffffce0f
2b11f010 ffffce0f2b11f010 ffffc905
3fb0e201 fffff80400000001 : FLTMGR!FltGetFileNameInformation+0x7b 0c ffffc905
3fb0dae0 fffff80480112851 : ffffce0f
2c999a60 0000000000000000 fffff804
8011b093 ffffce0f2c1c3860 : FLTMGR!FltvGetFileNameInformation+0x51 0d ffffc905
3fb0db10 fffff80480116673 : ffffce0f
2c999b48 fffff8048011b470 fffff804
80ef6fc0 ffffc9053fb0e040 : MYDRIVER!LogToDbgPrintWithFileName(struct _FLT_CALLBACK_DATA * Data = 0xffffce0f
2c999b48, char * str = 0xfffff8048011b470 "PAFS: RCPost with ")+0x141 0e ffffc905
3fb0df90 fffff80480116cc9 : ffffce0f
2c999b48 ffffc9053fb0f0a0 00000000
00000000 ffffce0f00000000 : MYDRIVER!RCPostOperationCallback(struct _FLT_CALLBACK_DATA * Data = 0xffffce0f
2c999b48, struct _FLT_RELATED_OBJECTS * FltObjects = 0xffffc9053fb0f0a0, void * CompletionContext = 0x00000000
00000000, unsigned long Flags = 0)+0x730f ffffc905
3fb0e030 fffff80e
b4d1292c : ffffce0f2c999b48 ffffc905
3fb0f0a0 0000000000000000 ffffce0f
00000000 : MYDRIVER!PostOperationCallback(struct _FLT_CALLBACK_DATA * Data = 0xffffce0f2c999b48, struct _FLT_RELATED_OBJECTS * FltObjects = 0xffffc905
3fb0f0a0, void * CompletionContext = 0x0000000000000000, unsigned long Flags = 0)+0x1a9 10 ffffc905
3fb0f070 fffff80eb4d124e9 : 00000000
c0000013 ffffce0f2d0b7920 ffffce0f
2d2ec060 ffffce0f29ed8010 : FLTMGR!FltpPerformPostMountCallbacks+0x90 11 ffffc905
3fb0f0e0 fffff80eb4d0cb8c : ffffce0f
2a902c10 fffff804c0000013 00000000
00000000 ffffce0f2c8ca0a0 : FLTMGR!FltpFsControlMountVolume+0x2a5 12 ffffc905
3fb0f1d0 fffff80480c2b63a : ffffce0f
2d0b7920 0000000000000001 ffffce0f
2a902c10 ffffce0f00000000 : FLTMGR!FltpFsControl+0x12c 13 ffffc905
3fb0f230 fffff804813def49 : ffffce0f
2d0b7920 ffffce0f2a902c10 fffff804
80eef8e0 fffff804`80ae39de : nt!IopfCallDriver+0x56bugcheck. That would be FsContext.
I would have thought FGFNI could handle (with an error code) such a case
(where FO is NULL), but seems not. Maybe that is why I added
IgnoreIfFSIsNull in CREATE two decades ago
To answer your original question, FGFNI is safe to call in your test cade;
it should simply return an error if if should not be called, as long as
Data is not corrupted.
This seems like another case, that needs adding, in the list of 200KB of
FGFNI workaround code that I already have
You could test if it fails for opening of the volume in PreCreate? It
should be a NULL FO IIRC, so calling FGFNI would bugcheck here also? Not
sure about this, it was 2 decades or so since I started adding ignoring of
NULL FO in any of my code.
Regards, Dejan.
This is an IRP_MJ_VOLUME_MOUNT:
#define IRP_MJ_VOLUME_MOUNT ((UCHAR)-19)
There's no File Object for this operation (and no name) so just don't call FGFNI.
-scott
OSR