From 5d44e007049712100fc1c6fd2b7beeebd4f7fd90 Mon Sep 17 00:00:00 2001 From: Alex Ionescu Date: Thu, 30 Nov 2006 18:04:22 +0000 Subject: [PATCH] - Fix critical I/O bugs in IopParseFile which were causing the file object's device object pointer to be associated to the FSD (File System Device) instead of the Disk Driver, as well as the dereference of the FSD after the Disk Driver had been referenced (causing too many derefs for one, and to many refs for the other). Also fix a bug in IopQueryDeviceInformation which was querying the Disk Driver instead of the FSD. - This also fixes IopQueryNameFile to properly return the entire name of the file now, instead of only the FSD part (probably fixes a dozen regressions). svn path=/trunk/; revision=24996 --- reactos/ntoskrnl/io/iomgr/file.c | 27 +++++++++++++-------------- reactos/ntoskrnl/io/iomgr/iofunc.c | 2 +- reactos/ntoskrnl/mm/section.c | 1 - 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/reactos/ntoskrnl/io/iomgr/file.c b/reactos/ntoskrnl/io/iomgr/file.c index 210c0a6a633..0e34c71d908 100644 --- a/reactos/ntoskrnl/io/iomgr/file.c +++ b/reactos/ntoskrnl/io/iomgr/file.c @@ -101,7 +101,7 @@ IopParseDevice(IN PVOID ParseObject, !(OpenPacket->RelatedFileObject->Flags & FO_DIRECT_DEVICE_OPEN)) { /* The device object is the one we were given */ - DeviceObject = OriginalDeviceObject; + DeviceObject = ParseObject; /* Check if the related FO had a VPB */ if (OpenPacket->RelatedFileObject->Vpb) @@ -119,11 +119,11 @@ IopParseDevice(IN PVOID ParseObject, DeviceObject = OriginalDeviceObject; /* Check if it has a VPB */ - if ((DeviceObject->Vpb) && !(DirectOpen)) + if ((OriginalDeviceObject->Vpb) && !(DirectOpen)) { /* Check if the VPB is mounted, and mount it */ Vpb = IopCheckVpbMounted(OpenPacket, - DeviceObject, + OriginalDeviceObject, RemainingName, &Status); if (!Vpb) return Status; @@ -145,7 +145,7 @@ IopParseDevice(IN PVOID ParseObject, if (!Irp) { /* Dereference the device and VPB, then fail */ - IopDereferenceDeviceObject(DeviceObject, FALSE); + IopDereferenceDeviceObject(OriginalDeviceObject, FALSE); if (Vpb) IopDereferenceVpb(Vpb); return STATUS_INSUFFICIENT_RESOURCES; } @@ -243,7 +243,7 @@ IopParseDevice(IN PVOID ParseObject, IoFreeIrp(Irp); /* Dereference the device and VPB */ - IopDereferenceDeviceObject(DeviceObject, FALSE); + IopDereferenceDeviceObject(OriginalDeviceObject, FALSE); if (Vpb) IopDereferenceVpb(Vpb); /* We failed, return status */ @@ -320,7 +320,7 @@ IopParseDevice(IN PVOID ParseObject, FileObject->Type = IO_TYPE_FILE; FileObject->Size = sizeof(FILE_OBJECT); FileObject->RelatedFileObject = OpenPacket->RelatedFileObject; - FileObject->DeviceObject = DeviceObject; + FileObject->DeviceObject = OriginalDeviceObject; /* Check if this is a direct device open */ if (DirectOpen) FileObject->Flags |= FO_DIRECT_DEVICE_OPEN; @@ -353,7 +353,7 @@ IopParseDevice(IN PVOID ParseObject, IoFreeIrp(Irp); /* Dereference the device object and VPB */ - IopDereferenceDeviceObject(DeviceObject, FALSE); + IopDereferenceDeviceObject(OriginalDeviceObject, FALSE); if (Vpb) IopDereferenceVpb(Vpb); /* Clear the FO and dereference it */ @@ -391,7 +391,7 @@ IopParseDevice(IN PVOID ParseObject, { /* We'll have to complete it ourselves */ ASSERT(!Irp->PendingReturned); - ASSERT(!Irp->MdlAddress ); + ASSERT(!Irp->MdlAddress); /* Completion happens at APC_LEVEL */ KeRaiseIrql(APC_LEVEL, &OldIrql); @@ -445,7 +445,10 @@ IopParseDevice(IN PVOID ParseObject, /* Dereference the file object */ if (!UseDummyFile) ObDereferenceObject(FileObject); - /* Unless the driver canelled the open, dereference the VPB */ + /* Dereference the device object */ + IopDereferenceDeviceObject(OriginalDeviceObject, FALSE); + + /* Unless the driver cancelled the open, dereference the VPB */ if (!(OpenCancelled) && (Vpb)) IopDereferenceVpb(Vpb); /* Set the status and return */ @@ -929,10 +932,6 @@ IopQueryNameFile(IN PVOID ObjectBody, if (!LocalInfo) return STATUS_INSUFFICIENT_RESOURCES; /* Query the name */ - DPRINT("Do. Drv, DrvName: %p %p %wZ\n", - FileObject->DeviceObject, - FileObject->DeviceObject->DriverObject, - &FileObject->DeviceObject->DriverObject->DriverName); Status = ObQueryNameString(FileObject->DeviceObject, LocalInfo, Length, @@ -1416,7 +1415,7 @@ IoCreateFile(OUT PHANDLE FileHandle, else if ((OpenPacket.FileObject) && (OpenPacket.ParseCheck != 1)) { /* - * This can happen in the very bizare case where the parse routine + * This can happen in the very bizarre case where the parse routine * actually executed more then once (due to a reparse) and ended * up failing after already having created the File Object. */ diff --git a/reactos/ntoskrnl/io/iomgr/iofunc.c b/reactos/ntoskrnl/io/iomgr/iofunc.c index 34459124170..3b97b5bf8c4 100644 --- a/reactos/ntoskrnl/io/iomgr/iofunc.c +++ b/reactos/ntoskrnl/io/iomgr/iofunc.c @@ -450,7 +450,7 @@ IopQueryDeviceInformation(IN PFILE_OBJECT FileObject, //IopQueueIrpToThread(Irp); /* Call the Driver */ - Status = IoCallDriver(FileObject->DeviceObject, Irp); + Status = IoCallDriver(DeviceObject, Irp); /* Check if this was synch I/O */ if (!LocalEvent) diff --git a/reactos/ntoskrnl/mm/section.c b/reactos/ntoskrnl/mm/section.c index d9e7eec90fd..0ca3ca9385e 100644 --- a/reactos/ntoskrnl/mm/section.c +++ b/reactos/ntoskrnl/mm/section.c @@ -3470,7 +3470,6 @@ NtCreateSection (OUT PHANDLE SectionHandle, AllocationAttributes, FileHandle, NULL); - if (NT_SUCCESS(Status)) { Status = ObInsertObject ((PVOID)SectionObject,