sys: FspFsvolNotifyChangeDirectory: fix problem with accessing IRP in FspFileNodeRelease when FspNotifyChangeDirectory completes IRP immediately

This commit is contained in:
Bill Zissimopoulos 2016-04-10 22:12:20 -07:00
parent 83e40f522c
commit adb6819de1

View File

@ -632,6 +632,17 @@ static NTSTATUS FspFsvolNotifyChangeDirectory(
return Result; return Result;
} }
/*
* It is possible for FspNotifyChangeDirectory to complete the IRP immediately.
* In this case trying to access the IRP (to get its IrpFlags) in FspFileNodeRelease
* can lead to a bugcheck. For this reason we set the TopLevelIrp to NULL here.
*
* IRP_MN_NOTIFY_CHANGE_DIRECTORY does not need the TopLevelIrp functionality,
* because it cannot be used recursively (I believe -- famous last words).
*/
PIRP TopLevelIrp = IoGetTopLevelIrp();
IoSetTopLevelIrp(0);
FspFileNodeAcquireExclusive(FileNode, Main); FspFileNodeAcquireExclusive(FileNode, Main);
Result = FspNotifyChangeDirectory( Result = FspNotifyChangeDirectory(
@ -647,6 +658,9 @@ static NTSTATUS FspFsvolNotifyChangeDirectory(
if (!NT_SUCCESS(Result)) if (!NT_SUCCESS(Result))
{ {
/* set back the top level IRP just in case! */
IoSetTopLevelIrp(TopLevelIrp);
FspIrpHookReset(Irp); FspIrpHookReset(Irp);
FspFree(CompletionContext); FspFree(CompletionContext);
return Result; return Result;