mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 12:55:43 +00:00
[NTOS:MM] Acquire file lock when creating section
This commit is contained in:
parent
76ac898bc5
commit
7d70af61e8
1 changed files with 25 additions and 4 deletions
|
@ -4290,6 +4290,7 @@ MmCreateSection (OUT PVOID * Section,
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
ULONG Protection;
|
ULONG Protection;
|
||||||
PSECTION *SectionObject = (PSECTION *)Section;
|
PSECTION *SectionObject = (PSECTION *)Section;
|
||||||
|
BOOLEAN FileLock = FALSE;
|
||||||
|
|
||||||
/* Check if an ARM3 section is being created instead */
|
/* Check if an ARM3 section is being created instead */
|
||||||
if (!(AllocationAttributes & (SEC_IMAGE | SEC_PHYSICALMEMORY)))
|
if (!(AllocationAttributes & (SEC_IMAGE | SEC_PHYSICALMEMORY)))
|
||||||
|
@ -4343,6 +4344,24 @@ MmCreateSection (OUT PVOID * Section,
|
||||||
DPRINT1("Failed to get a handle to the FO: %lx\n", Status);
|
DPRINT1("Failed to get a handle to the FO: %lx\n", Status);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Lock the file */
|
||||||
|
Status = FsRtlAcquireToCreateMappedSection(FileObject, SectionPageProtection);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
ObDereferenceObject(FileObject);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
FileLock = TRUE;
|
||||||
|
|
||||||
|
/* Deny access if there are writes on the file */
|
||||||
|
if ((AllocationAttributes & SEC_IMAGE) && (Status == STATUS_FILE_LOCKED_WITH_WRITERS))
|
||||||
|
{
|
||||||
|
DPRINT1("Cannot create image maps with writers open on the file!\n");
|
||||||
|
Status = STATUS_ACCESS_DENIED;
|
||||||
|
goto Quit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -4365,7 +4384,6 @@ MmCreateSection (OUT PVOID * Section,
|
||||||
SectionPageProtection,
|
SectionPageProtection,
|
||||||
AllocationAttributes,
|
AllocationAttributes,
|
||||||
FileObject);
|
FileObject);
|
||||||
ObDereferenceObject(FileObject);
|
|
||||||
}
|
}
|
||||||
#ifndef NEWCC
|
#ifndef NEWCC
|
||||||
else if (FileObject != NULL)
|
else if (FileObject != NULL)
|
||||||
|
@ -4378,7 +4396,6 @@ MmCreateSection (OUT PVOID * Section,
|
||||||
AllocationAttributes,
|
AllocationAttributes,
|
||||||
FileObject,
|
FileObject,
|
||||||
FileHandle != NULL);
|
FileHandle != NULL);
|
||||||
ObDereferenceObject(FileObject);
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
else if (FileHandle != NULL || FileObject != NULL)
|
else if (FileHandle != NULL || FileObject != NULL)
|
||||||
|
@ -4396,10 +4413,14 @@ MmCreateSection (OUT PVOID * Section,
|
||||||
{
|
{
|
||||||
/* All cases should be handled above */
|
/* All cases should be handled above */
|
||||||
Status = STATUS_INVALID_PARAMETER;
|
Status = STATUS_INVALID_PARAMETER;
|
||||||
if (FileObject)
|
|
||||||
ObDereferenceObject(FileObject);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Quit:
|
||||||
|
if (FileLock)
|
||||||
|
FsRtlReleaseFile(FileObject);
|
||||||
|
if (FileObject)
|
||||||
|
ObDereferenceObject(FileObject);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue