sys: FspPropagateTopFlags: check TopLevelIrp not completed

Add a check to verify that the TopLevelIrp has not been completed. This
became necessary because on recent Windows kernels, IRP's can have "IRP
extensions", which are freed when an IRP is completed. This can trigger
a recursive CLOSE with a top-level IRP that has been completed, which
can bugcheck the system.

Case in point: the new (Win11) NtCopyFileChunk creates IRP's with
COPY_INFORMATION attached. Upon completion of such an IRP the
SourceFileObject is freed, which results in a recursive IRP_MJ_CLOSE
with a completed top-level IRP, which would lead to a BSOD.
This commit is contained in:
Bill Zissimopoulos 2023-08-29 13:15:37 +01:00
parent 6fb72555d3
commit a482183149

View File

@ -324,7 +324,9 @@ VOID FspPropagateTopFlags(PIRP Irp, PIRP TopLevelIrp)
FspFileNodeAcquireMain :
FspFileNodeAcquireFull);
}
else if ((PIRP)MM_SYSTEM_RANGE_START <= TopLevelIrp && IO_TYPE_IRP == TopLevelIrp->Type)
else if ((PIRP)MM_SYSTEM_RANGE_START <= TopLevelIrp &&
IO_TYPE_IRP == TopLevelIrp->Type &&
TopLevelIrp->CurrentLocation <= TopLevelIrp->StackCount)
{
PFILE_OBJECT FileObject = IoGetCurrentIrpStackLocation(Irp)->FileObject;
PFILE_OBJECT TopLevelFileObject = IoGetCurrentIrpStackLocation(TopLevelIrp)->FileObject;