mirror of
https://github.com/reactos/reactos.git
synced 2025-02-25 01:39:30 +00:00
- Move SectionPageProtection checks from helper routines to NtCreateSection.
- Remove dependency on ReactOS specific FO_FCB_IS_VALID magic and don't access FCB directly, use NtQueryInformationFile instead. - Fix deleting of section if an early failure during section creation happens and not all structures are initialized yet. svn path=/trunk/; revision=10586
This commit is contained in:
parent
04e70454de
commit
f43bd6e656
1 changed files with 43 additions and 46 deletions
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: section.c,v 1.158 2004/08/15 16:39:08 chorns Exp $
|
/* $Id: section.c,v 1.159 2004/08/18 02:29:37 navaraf Exp $
|
||||||
*
|
*
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/mm/section.c
|
* FILE: ntoskrnl/mm/section.c
|
||||||
|
@ -2007,6 +2007,15 @@ MmpDeleteSection(PVOID ObjectBody)
|
||||||
ULONG RefCount;
|
ULONG RefCount;
|
||||||
PMM_SECTION_SEGMENT SectionSegments;
|
PMM_SECTION_SEGMENT SectionSegments;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NOTE: Section->ImageSection can be NULL for short time
|
||||||
|
* during the section creating. If we fail for some reason
|
||||||
|
* until the image section is properly initialized we shouldn't
|
||||||
|
* process further here.
|
||||||
|
*/
|
||||||
|
if (Section->ImageSection == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
SectionSegments = Section->ImageSection->Segments;
|
SectionSegments = Section->ImageSection->Segments;
|
||||||
NrSegments = Section->ImageSection->NrSegments;
|
NrSegments = Section->ImageSection->NrSegments;
|
||||||
|
|
||||||
|
@ -2029,6 +2038,13 @@ MmpDeleteSection(PVOID ObjectBody)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* NOTE: Section->Segment can be NULL for short time
|
||||||
|
* during the section creating.
|
||||||
|
*/
|
||||||
|
if (Section->Segment == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
if (Section->Segment->Flags & MM_PAGEFILE_SEGMENT)
|
if (Section->Segment->Flags & MM_PAGEFILE_SEGMENT)
|
||||||
{
|
{
|
||||||
MmpFreePageFileSegment(Section->Segment);
|
MmpFreePageFileSegment(Section->Segment);
|
||||||
|
@ -2172,15 +2188,6 @@ MmCreatePageFileSection(PSECTION_OBJECT *SectionObject,
|
||||||
}
|
}
|
||||||
MaximumSize = *UMaximumSize;
|
MaximumSize = *UMaximumSize;
|
||||||
|
|
||||||
/*
|
|
||||||
* Check the protection
|
|
||||||
*/
|
|
||||||
if ((SectionPageProtection & PAGE_FLAGS_VALID_FROM_USER_MODE) !=
|
|
||||||
SectionPageProtection)
|
|
||||||
{
|
|
||||||
return(STATUS_INVALID_PAGE_PROTECTION);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create the section
|
* Create the section
|
||||||
*/
|
*/
|
||||||
|
@ -2203,6 +2210,7 @@ MmCreatePageFileSection(PSECTION_OBJECT *SectionObject,
|
||||||
*/
|
*/
|
||||||
Section->SectionPageProtection = SectionPageProtection;
|
Section->SectionPageProtection = SectionPageProtection;
|
||||||
Section->AllocationAttributes = AllocationAttributes;
|
Section->AllocationAttributes = AllocationAttributes;
|
||||||
|
Section->Segment = NULL;
|
||||||
InitializeListHead(&Section->ViewListHead);
|
InitializeListHead(&Section->ViewListHead);
|
||||||
KeInitializeSpinLock(&Section->ViewListLock);
|
KeInitializeSpinLock(&Section->ViewListLock);
|
||||||
Section->FileObject = NULL;
|
Section->FileObject = NULL;
|
||||||
|
@ -2253,15 +2261,8 @@ MmCreateDataFileSection(PSECTION_OBJECT *SectionObject,
|
||||||
IO_STATUS_BLOCK Iosb;
|
IO_STATUS_BLOCK Iosb;
|
||||||
LARGE_INTEGER Offset;
|
LARGE_INTEGER Offset;
|
||||||
CHAR Buffer;
|
CHAR Buffer;
|
||||||
|
FILE_STANDARD_INFORMATION FileInfo;
|
||||||
|
|
||||||
/*
|
|
||||||
* Check the protection
|
|
||||||
*/
|
|
||||||
if ((SectionPageProtection & PAGE_FLAGS_VALID_FROM_USER_MODE) !=
|
|
||||||
SectionPageProtection)
|
|
||||||
{
|
|
||||||
return(STATUS_INVALID_PAGE_PROTECTION);
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* Create the section
|
* Create the section
|
||||||
*/
|
*/
|
||||||
|
@ -2284,6 +2285,7 @@ MmCreateDataFileSection(PSECTION_OBJECT *SectionObject,
|
||||||
*/
|
*/
|
||||||
Section->SectionPageProtection = SectionPageProtection;
|
Section->SectionPageProtection = SectionPageProtection;
|
||||||
Section->AllocationAttributes = AllocationAttributes;
|
Section->AllocationAttributes = AllocationAttributes;
|
||||||
|
Section->Segment = NULL;
|
||||||
InitializeListHead(&Section->ViewListHead);
|
InitializeListHead(&Section->ViewListHead);
|
||||||
KeInitializeSpinLock(&Section->ViewListLock);
|
KeInitializeSpinLock(&Section->ViewListLock);
|
||||||
|
|
||||||
|
@ -2316,14 +2318,21 @@ MmCreateDataFileSection(PSECTION_OBJECT *SectionObject,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We can't do memory mappings if the file system doesn't support the
|
* FIXME: This is propably not entirely correct. We can't look into
|
||||||
* standard FCB
|
* the standard FCB header because it might not be initialized yet
|
||||||
|
* (as in case of the EXT2FS driver by Manoj Paul Joseph where the
|
||||||
|
* standard file information is filled on first request).
|
||||||
*/
|
*/
|
||||||
if (!(FileObject->Flags & FO_FCB_IS_VALID))
|
Status = NtQueryInformationFile(FileHandle,
|
||||||
|
&Iosb,
|
||||||
|
&FileInfo,
|
||||||
|
sizeof(FILE_STANDARD_INFORMATION),
|
||||||
|
FileStandardInformation);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
ObDereferenceObject(Section);
|
ObDereferenceObject(Section);
|
||||||
ObDereferenceObject(FileObject);
|
ObDereferenceObject(FileObject);
|
||||||
return(STATUS_INVALID_FILE_FOR_SECTION);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2336,12 +2345,10 @@ MmCreateDataFileSection(PSECTION_OBJECT *SectionObject,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MaximumSize =
|
MaximumSize = FileInfo.EndOfFile;
|
||||||
((PFSRTL_COMMON_FCB_HEADER)FileObject->FsContext)->FileSize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MaximumSize.QuadPart >
|
if (MaximumSize.QuadPart > FileInfo.EndOfFile.QuadPart)
|
||||||
((PFSRTL_COMMON_FCB_HEADER)FileObject->FsContext)->FileSize.QuadPart)
|
|
||||||
{
|
{
|
||||||
Status = NtSetInformationFile(FileHandle,
|
Status = NtSetInformationFile(FileHandle,
|
||||||
&Iosb,
|
&Iosb,
|
||||||
|
@ -2515,14 +2522,6 @@ MmCreateImageSection(PSECTION_OBJECT *SectionObject,
|
||||||
ULONG Size;
|
ULONG Size;
|
||||||
ULONG Characteristics;
|
ULONG Characteristics;
|
||||||
ULONG FileAccess = 0;
|
ULONG FileAccess = 0;
|
||||||
/*
|
|
||||||
* Check the protection
|
|
||||||
*/
|
|
||||||
if ((SectionPageProtection & PAGE_FLAGS_VALID_FROM_USER_MODE) !=
|
|
||||||
SectionPageProtection)
|
|
||||||
{
|
|
||||||
return(STATUS_INVALID_PAGE_PROTECTION);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Specifying a maximum size is meaningless for an image section
|
* Specifying a maximum size is meaningless for an image section
|
||||||
|
@ -2673,6 +2672,7 @@ MmCreateImageSection(PSECTION_OBJECT *SectionObject,
|
||||||
*/
|
*/
|
||||||
Section->SectionPageProtection = SectionPageProtection;
|
Section->SectionPageProtection = SectionPageProtection;
|
||||||
Section->AllocationAttributes = AllocationAttributes;
|
Section->AllocationAttributes = AllocationAttributes;
|
||||||
|
Section->ImageSection = NULL;
|
||||||
InitializeListHead(&Section->ViewListHead);
|
InitializeListHead(&Section->ViewListHead);
|
||||||
KeInitializeSpinLock(&Section->ViewListLock);
|
KeInitializeSpinLock(&Section->ViewListLock);
|
||||||
|
|
||||||
|
@ -2688,18 +2688,6 @@ MmCreateImageSection(PSECTION_OBJECT *SectionObject,
|
||||||
FileAccess = FILE_READ_DATA;
|
FileAccess = FILE_READ_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* We can't do memory mappings if the file system doesn't support the
|
|
||||||
* standard FCB
|
|
||||||
*/
|
|
||||||
if (!(FileObject->Flags & FO_FCB_IS_VALID))
|
|
||||||
{
|
|
||||||
ObDereferenceObject(Section);
|
|
||||||
ObDereferenceObject(FileObject);
|
|
||||||
ExFreePool(ImageSections);
|
|
||||||
return(STATUS_INVALID_FILE_FOR_SECTION);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lock the file
|
* Lock the file
|
||||||
*/
|
*/
|
||||||
|
@ -2927,6 +2915,15 @@ NtCreateSection (OUT PHANDLE SectionHandle,
|
||||||
PSECTION_OBJECT SectionObject;
|
PSECTION_OBJECT SectionObject;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check the protection
|
||||||
|
*/
|
||||||
|
if ((SectionPageProtection & PAGE_FLAGS_VALID_FROM_USER_MODE) !=
|
||||||
|
SectionPageProtection)
|
||||||
|
{
|
||||||
|
return(STATUS_INVALID_PAGE_PROTECTION);
|
||||||
|
}
|
||||||
|
|
||||||
Status = MmCreateSection(&SectionObject,
|
Status = MmCreateSection(&SectionObject,
|
||||||
DesiredAccess,
|
DesiredAccess,
|
||||||
ObjectAttributes,
|
ObjectAttributes,
|
||||||
|
|
Loading…
Reference in a new issue