ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
February 2021
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
30 participants
434 discussions
Start a n
N
ew thread
[reactos] 47/100: [NTOS:MM] Have the legacy Mm be less greedy about the number of pages it wants
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=aab24ed1b1a3269de23db…
commit aab24ed1b1a3269de23dbaa334a67741434bc4c1 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Mon Dec 7 11:42:47 2020 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOS:MM] Have the legacy Mm be less greedy about the number of pages it wants --- ntoskrnl/mm/balance.c | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/ntoskrnl/mm/balance.c b/ntoskrnl/mm/balance.c index 29c0dfc6f47..34dddf5dbfa 100644 --- a/ntoskrnl/mm/balance.c +++ b/ntoskrnl/mm/balance.c @@ -28,7 +28,6 @@ MM_ALLOCATION_REQUEST, *PMM_ALLOCATION_REQUEST; MM_MEMORY_CONSUMER MiMemoryConsumers[MC_MAXIMUM]; static ULONG MiMinimumAvailablePages; -static ULONG MiNrTotalPages; static LIST_ENTRY AllocationListHead; static KSPIN_LOCK AllocationListLock; static ULONG MiMinimumPagesPerRun; @@ -49,12 +48,10 @@ MmInitializeBalancer(ULONG NrAvailablePages, ULONG NrSystemPages) InitializeListHead(&AllocationListHead); KeInitializeSpinLock(&AllocationListLock); - MiNrTotalPages = NrAvailablePages; - /* Set up targets. */ MiMinimumAvailablePages = 256; MiMinimumPagesPerRun = 256; - MiMemoryConsumers[MC_USER].PagesTarget = NrAvailablePages - MiMinimumAvailablePages; + MiMemoryConsumers[MC_USER].PagesTarget = NrAvailablePages / 2; } CODE_SEG("INIT") @@ -120,15 +117,12 @@ MiTrimMemoryConsumer(ULONG Consumer, ULONG InitialTarget) Target = (ULONG)max(Target, MiMinimumAvailablePages - MmAvailablePages); } + /* Don't be too greedy if we're not in a hurry */ + if (MmAvailablePages > MiMinimumAvailablePages) + Target = min(Target, 256); + if (Target) { - if (!InitialTarget) - { - /* If there was no initial target, - * swap at least MiMinimumPagesPerRun */ - Target = max(Target, MiMinimumPagesPerRun); - } - /* Now swap the pages out */ Status = MiMemoryConsumers[Consumer].Trim(Target, 0, &NrFreedPages); @@ -138,21 +132,10 @@ MiTrimMemoryConsumer(ULONG Consumer, ULONG InitialTarget) { KeBugCheck(MEMORY_MANAGEMENT); } - - /* Update the target */ - if (NrFreedPages < Target) - Target -= NrFreedPages; - else - Target = 0; - - /* Return the remaining pages needed to meet the target */ - return Target; - } - else - { - /* Initial target is zero and we don't have anything else to add */ - return 0; } + + /* Return the page count needed to be freed to meet the initial target */ + return (InitialTarget > NrFreedPages) ? (InitialTarget - NrFreedPages) : 0; } NTSTATUS
3 years, 10 months
1
0
0
0
[reactos] 46/100: [NTOS:MM] Make the situation about dirty pages in image map a bit clearer
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fb07802956b5d10363b43…
commit fb07802956b5d10363b43d0d0e2ea4427764779f Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Mon Dec 7 09:55:12 2020 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOS:MM] Make the situation about dirty pages in image map a bit clearer --- ntoskrnl/mm/section.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index b38dc0bfc4a..d71bc490934 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -1082,7 +1082,7 @@ MmUnsharePageEntrySectionSegment(PMEMORY_AREA MemoryArea, return FALSE; } - if (IS_DIRTY_SSE(Entry) && !(Segment->Image.Characteristics & IMAGE_SCN_MEM_SHARED)) + if (Dirty && (MemoryArea->VadNode.u.VadFlags.VadType != VadImageMap)) { ASSERT(!Segment->WriteCopy); ASSERT(MmGetSavedSwapEntryPage(Page) == 0); @@ -1092,6 +1092,9 @@ MmUnsharePageEntrySectionSegment(PMEMORY_AREA MemoryArea, return FALSE; } + /* Only valid case for shared dirty pages is shared image section */ + ASSERT(!Dirty || (Segment->Image.Characteristics & IMAGE_SCN_MEM_SHARED)); + SwapEntry = MmGetSavedSwapEntryPage(Page); if (Dirty && !SwapEntry) {
3 years, 10 months
1
0
0
0
[reactos] 45/100: [NTOS:CC] Honor FO_WRITE_THROUGH flag in CcCopyWrite and fix it in CcZeroData
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cd23d6e19aef6daf321f0…
commit cd23d6e19aef6daf321f0d6a5e021e58a09982ef Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri Dec 4 15:45:04 2020 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOS:CC] Honor FO_WRITE_THROUGH flag in CcCopyWrite and fix it in CcZeroData --- ntoskrnl/cc/copy.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ntoskrnl/cc/copy.c b/ntoskrnl/cc/copy.c index d228a981ea2..357e98162e6 100644 --- a/ntoskrnl/cc/copy.c +++ b/ntoskrnl/cc/copy.c @@ -556,16 +556,13 @@ CcCopyWrite ( if (!SharedCacheMap) return FALSE; - /* FIXME: Honor FileObject FO_WRITE_THROUGH flag */ ASSERT((FileOffset->QuadPart + Length) <= SharedCacheMap->SectionSize.QuadPart); - ASSERT((FileObject->Flags & FO_WRITE_THROUGH) == 0); - CurrentOffset = FileOffset->QuadPart; while(CurrentOffset < WriteEnd) { ULONG VacbOffset = CurrentOffset % VACB_MAPPING_GRANULARITY; - ULONG VacbLength = min(Length, VACB_MAPPING_GRANULARITY - VacbOffset); + ULONG VacbLength = min(WriteEnd - CurrentOffset, VACB_MAPPING_GRANULARITY - VacbOffset); Status = CcRosGetVacb(SharedCacheMap, CurrentOffset, &Vacb); if (!NT_SUCCESS(Status)) @@ -585,7 +582,6 @@ CcCopyWrite ( Buffer = (PVOID)((ULONG_PTR)Buffer + VacbLength); CurrentOffset += VacbLength; - Length -= VacbLength; /* Tell Mm */ Status = MmMakePagesDirty(NULL, Add2Ptr(Vacb->BaseAddress, VacbOffset), VacbLength); @@ -600,6 +596,10 @@ CcCopyWrite ( _SEH2_END; } + /* Flush if needed */ + if (FileObject->Flags & FO_WRITE_THROUGH) + CcFlushCache(FileObject->SectionObjectPointer, FileOffset, Length, NULL); + return TRUE; } @@ -757,7 +757,7 @@ CcZeroData ( Length = EndOffset->QuadPart - StartOffset->QuadPart; WriteOffset.QuadPart = StartOffset->QuadPart; - if (!SharedCacheMap || (FileObject->Flags & FO_WRITE_THROUGH)) + if (!SharedCacheMap) { /* Make this a non-cached write */ IO_STATUS_BLOCK Iosb; @@ -848,5 +848,9 @@ CcZeroData ( _SEH2_END; } + /* Flush if needed */ + if (FileObject->Flags & FO_WRITE_THROUGH) + CcFlushCache(FileObject->SectionObjectPointer, StartOffset, EndOffset->QuadPart - StartOffset->QuadPart, NULL); + return TRUE; }
3 years, 10 months
1
0
0
0
[reactos] 44/100: [NTOS:CC] Acquire file for flush when flushing if necessary
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f8aa14ce4e651ca57f119…
commit f8aa14ce4e651ca57f11904b482972fb0f749295 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri Dec 4 10:18:32 2020 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOS:CC] Acquire file for flush when flushing if necessary --- ntoskrnl/cc/view.c | 16 ++++++++++++++++ ntoskrnl/include/internal/fsrtl.h | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c index de4a75ea8f7..ee0ec497d40 100644 --- a/ntoskrnl/cc/view.c +++ b/ntoskrnl/cc/view.c @@ -172,11 +172,27 @@ CcRosFlushVacb ( SIZE_T FlushSize = min(VACB_MAPPING_GRANULARITY, Vacb->SharedCacheMap->SectionSize.QuadPart - Vacb->FileOffset.QuadPart); NTSTATUS Status; + BOOLEAN HaveLock = FALSE; CcRosUnmarkDirtyVacb(Vacb, TRUE); + /* Lock for flush, if we are not already the top-level */ + if (IoGetTopLevelIrp() != (PIRP)FSRTL_CACHE_TOP_LEVEL_IRP) + { + Status = FsRtlAcquireFileForCcFlushEx(Vacb->SharedCacheMap->FileObject); + if (!NT_SUCCESS(Status)) + goto quit; + HaveLock = TRUE; + } + Status = MmFlushVirtualMemory(NULL, &Vacb->BaseAddress, &FlushSize, &Iosb); + if (HaveLock) + { + FsRtlReleaseFileForCcFlush(Vacb->SharedCacheMap->FileObject); + } + +quit: if (!NT_SUCCESS(Status)) CcRosMarkDirtyVacb(Vacb); diff --git a/ntoskrnl/include/internal/fsrtl.h b/ntoskrnl/include/internal/fsrtl.h index 79cc3b6cfbc..228bb7a1cf8 100644 --- a/ntoskrnl/include/internal/fsrtl.h +++ b/ntoskrnl/include/internal/fsrtl.h @@ -148,3 +148,11 @@ NTSTATUS NTAPI FsRtlAcquireToCreateMappedSection(_In_ PFILE_OBJECT FileObject, _In_ ULONG SectionPageProtection); + +VOID +NTAPI +FsRtlReleaseFileForCcFlush(IN PFILE_OBJECT FileObject); + +NTSTATUS +NTAPI +FsRtlAcquireFileForCcFlushEx(IN PFILE_OBJECT FileObject);
3 years, 10 months
1
0
0
0
[reactos] 43/100: [NTOS:MM] Fix file object bad referencing
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d9f7459bb1dcb0893adbe…
commit d9f7459bb1dcb0893adbec74939962e7a4d95d9b Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri Dec 4 09:17:21 2020 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOS:MM] Fix file object bad referencing --- ntoskrnl/mm/section.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index 866b90810e0..b38dc0bfc4a 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -3128,7 +3128,6 @@ MmCreateImageSection(PSECTION *SectionObject, InterlockedExchangePointer(&FileObject->SectionObjectPointer->ImageSectionObject, NULL); ExFreePoolWithTag(ImageSectionObject, TAG_MM_SECTION_SEGMENT); MmDereferenceSegment(DataSectionObject); - ObDereferenceObject(FileObject); ObDereferenceObject(Section); return STATUS_ACCESS_DENIED; }
3 years, 10 months
1
0
0
0
[reactos] 42/100: [NTOS:IO] VFAT sucks less now
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2d3454a809238331dae3f…
commit 2d3454a809238331dae3fd6f25185eb5b92cf73f Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri Dec 4 09:13:01 2020 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOS:IO] VFAT sucks less now --- ntoskrnl/io/iomgr/iofunc.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ntoskrnl/io/iomgr/iofunc.c b/ntoskrnl/io/iomgr/iofunc.c index 80814a70ba3..7d0a08c5395 100644 --- a/ntoskrnl/io/iomgr/iofunc.c +++ b/ntoskrnl/io/iomgr/iofunc.c @@ -3014,10 +3014,8 @@ NtReadFile(IN HANDLE FileHandle, /* Now set the deferred read flags */ Irp->Flags |= (IRP_READ_OPERATION | IRP_DEFER_IO_COMPLETION); -#if 0 - /* FIXME: VFAT SUCKS */ + if (FileObject->Flags & FO_NO_INTERMEDIATE_BUFFERING) Irp->Flags |= IRP_NOCACHE; -#endif /* Perform the call */ return IopPerformSynchronousRequest(DeviceObject, @@ -4082,10 +4080,8 @@ NtWriteFile(IN HANDLE FileHandle, /* Now set the deferred read flags */ Irp->Flags |= (IRP_WRITE_OPERATION | IRP_DEFER_IO_COMPLETION); -#if 0 - /* FIXME: VFAT SUCKS */ + if (FileObject->Flags & FO_NO_INTERMEDIATE_BUFFERING) Irp->Flags |= IRP_NOCACHE; -#endif /* Perform the call */ return IopPerformSynchronousRequest(DeviceObject,
3 years, 10 months
1
0
0
0
[reactos] 41/100: [NTOS:CC] File size check fix
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cbfc04157d9553fe4e7f2…
commit cbfc04157d9553fe4e7f2171db64561be2eaf243 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri Dec 4 09:12:18 2020 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOS:CC] File size check fix --- ntoskrnl/cc/copy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ntoskrnl/cc/copy.c b/ntoskrnl/cc/copy.c index f92040aa0b2..d228a981ea2 100644 --- a/ntoskrnl/cc/copy.c +++ b/ntoskrnl/cc/copy.c @@ -809,7 +809,7 @@ CcZeroData ( return TRUE; } - ASSERT(EndOffset->QuadPart <= SharedCacheMap->FileSize.QuadPart); + ASSERT(EndOffset->QuadPart <= SharedCacheMap->SectionSize.QuadPart); while(WriteOffset.QuadPart < EndOffset->QuadPart) {
3 years, 10 months
1
0
0
0
[reactos] 40/100: [NTOS/MM] Set FSRTL_MOD_WRITE_TOP_LEVEL_IRP top-level IRP when paging-out
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e39fc52d25a577b3c5abd…
commit e39fc52d25a577b3c5abd9a9c9b5d20508c42d88 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri Dec 4 09:10:59 2020 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOS/MM] Set FSRTL_MOD_WRITE_TOP_LEVEL_IRP top-level IRP when paging-out --- ntoskrnl/mm/section.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index 6b6a6cb94be..866b90810e0 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -4685,9 +4685,16 @@ MmCheckDirtySegment( MmUnlockSectionSegment(Segment); + /* Tell the FS driver who we are */ + if (PageOut) + IoSetTopLevelIrp((PIRP)FSRTL_MOD_WRITE_TOP_LEVEL_IRP); + /* Go ahead and write the page */ Status = MiWritePage(Segment, Offset->QuadPart, Page); + if (PageOut) + IoSetTopLevelIrp(NULL); + MmLockSectionSegment(Segment); /* Get the entry again */
3 years, 10 months
1
0
0
0
[reactos] 39/100: [NTOS/MM] Do not zero out the tail of the segment if the mapping is not an image
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f114209782a0f44fa6b80…
commit f114209782a0f44fa6b80cc3aa1e7d583d5dacea Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri Dec 4 09:10:13 2020 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOS/MM] Do not zero out the tail of the segment if the mapping is not an image --- ntoskrnl/mm/section.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index 08e68a20c33..6b6a6cb94be 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -1205,7 +1205,7 @@ MiReadPage(PMEMORY_AREA MemoryArea, Status = STATUS_SUCCESS; } - if ((SegOffset + PAGE_SIZE) > MemoryArea->SectionData.Segment->RawLength.QuadPart) + if ((MemoryArea->VadNode.u.VadFlags.VadType == VadImageMap) && ((SegOffset + PAGE_SIZE) > MemoryArea->SectionData.Segment->RawLength.QuadPart)) { KIRQL OldIrql; PUCHAR PageMap;
3 years, 10 months
1
0
0
0
[reactos] 38/100: [NTOS:MM] Acquire file lock when creating section
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7d70af61e8fff18b24d9b…
commit 7d70af61e8fff18b24d9baa3bb63c37c96aa21c6 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Thu Dec 3 17:18:29 2020 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:22 2021 +0100 [NTOS:MM] Acquire file lock when creating section --- ntoskrnl/mm/section.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index e39f82d0f22..08e68a20c33 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -4290,6 +4290,7 @@ MmCreateSection (OUT PVOID * Section, NTSTATUS Status; ULONG Protection; PSECTION *SectionObject = (PSECTION *)Section; + BOOLEAN FileLock = FALSE; /* Check if an ARM3 section is being created instead */ 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); 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 { @@ -4365,7 +4384,6 @@ MmCreateSection (OUT PVOID * Section, SectionPageProtection, AllocationAttributes, FileObject); - ObDereferenceObject(FileObject); } #ifndef NEWCC else if (FileObject != NULL) @@ -4378,7 +4396,6 @@ MmCreateSection (OUT PVOID * Section, AllocationAttributes, FileObject, FileHandle != NULL); - ObDereferenceObject(FileObject); } #else else if (FileHandle != NULL || FileObject != NULL) @@ -4396,10 +4413,14 @@ MmCreateSection (OUT PVOID * Section, { /* All cases should be handled above */ Status = STATUS_INVALID_PARAMETER; - if (FileObject) - ObDereferenceObject(FileObject); } +Quit: + if (FileLock) + FsRtlReleaseFile(FileObject); + if (FileObject) + ObDereferenceObject(FileObject); + return Status; }
3 years, 10 months
1
0
0
0
← Newer
1
...
34
35
36
37
38
39
40
...
44
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Results per page:
10
25
50
100
200