https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3f601122bce70808381d2…
commit 3f601122bce70808381d2255abb938f9369f2eb5
Author: Victor Perevertkin <victor.perevertkin(a)reactos.org>
AuthorDate: Mon Jun 14 04:50:01 2021 +0300
Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com>
CommitDate: Wed Jun 16 12:14:27 2021 +0200
[NTOS:MM] Fix placing entries into MmNonPagedPoolFreeListHead
When freeing pages, free page entries with pages num == 3 were
incorrectly treated as entries with pages num >= 4 and thus
their re-insertion was not triggered. That lead to non paged pool
fragmentation (can be triggered by kmtest:ExPools, for example)
Also, altered the index acquisition code for MmNonPagedPoolFreeList
entries so it looks more clear
---
ntoskrnl/mm/ARM3/pool.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/ntoskrnl/mm/ARM3/pool.c b/ntoskrnl/mm/ARM3/pool.c
index 5a406e166d8..fe8d6cd1a74 100644
--- a/ntoskrnl/mm/ARM3/pool.c
+++ b/ntoskrnl/mm/ARM3/pool.c
@@ -680,8 +680,7 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
//
// Allocations of less than 4 pages go into their individual buckets
//
- i = SizeInPages - 1;
- if (i >= MI_MAX_FREE_PAGE_LISTS) i = MI_MAX_FREE_PAGE_LISTS - 1;
+ i = min(SizeInPages, MI_MAX_FREE_PAGE_LISTS) - 1;
//
// Loop through all the free page lists based on the page index
@@ -738,8 +737,7 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
if (FreeEntry->Size != 0)
{
/* Check which list to insert this entry into */
- i = FreeEntry->Size - 1;
- if (i >= MI_MAX_FREE_PAGE_LISTS) i = MI_MAX_FREE_PAGE_LISTS - 1;
+ i = min(FreeEntry->Size, MI_MAX_FREE_PAGE_LISTS) - 1;
/* Insert the entry into the free list head, check for prot. pool */
if (MmProtectFreedNonPagedPool)
@@ -1176,11 +1174,11 @@ MiFreePoolPages(IN PVOID StartingVa)
}
//
- // Check if the entry is small enough to be indexed on a free list
+ // Check if the entry is small enough (1-3 pages) to be indexed on a free list
// If it is, we'll want to re-insert it, since we're about to
// collapse our pages on top of it, which will change its count
//
- if (FreeEntry->Size < (MI_MAX_FREE_PAGE_LISTS - 1))
+ if (FreeEntry->Size < MI_MAX_FREE_PAGE_LISTS)
{
/* Remove the item from the list, depending if pool is protected */
if (MmProtectFreedNonPagedPool)
@@ -1196,8 +1194,7 @@ MiFreePoolPages(IN PVOID StartingVa)
//
// And now find the new appropriate list to place it in
//
- i = (ULONG)(FreeEntry->Size - 1);
- if (i >= MI_MAX_FREE_PAGE_LISTS) i = MI_MAX_FREE_PAGE_LISTS - 1;
+ i = min(FreeEntry->Size, MI_MAX_FREE_PAGE_LISTS) - 1;
/* Insert the entry into the free list head, check for prot. pool */
if (MmProtectFreedNonPagedPool)
@@ -1228,8 +1225,7 @@ MiFreePoolPages(IN PVOID StartingVa)
//
// Find the appropriate list we should be on
//
- i = FreeEntry->Size - 1;
- if (i >= MI_MAX_FREE_PAGE_LISTS) i = MI_MAX_FREE_PAGE_LISTS - 1;
+ i = min(FreeEntry->Size, MI_MAX_FREE_PAGE_LISTS) - 1;
/* Insert the entry into the free list head, check for prot. pool */
if (MmProtectFreedNonPagedPool)
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a3cadf630a9b3a61f4ae8…
commit a3cadf630a9b3a61f4ae8525aef7af07e4b53c0d
Author: Joachim Henze <Joachim.Henze(a)reactos.org>
AuthorDate: Wed Jun 16 11:41:56 2021 +0200
Commit: Joachim Henze <Joachim.Henze(a)reactos.org>
CommitDate: Wed Jun 16 11:41:56 2021 +0200
[COMCTL32] Strip EOL whitespace within ifdef __REACTOS__ section
no functional change.
Make that look beautiful before porting it back further.
Addendum to 0.4.15-dev-534-g 887764e6075fdde7fb81d2a54d5255164c046511
(CORE-17062)
---
dll/win32/comctl32/static.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dll/win32/comctl32/static.c b/dll/win32/comctl32/static.c
index b30f0532f3a..b4e240ad91a 100644
--- a/dll/win32/comctl32/static.c
+++ b/dll/win32/comctl32/static.c
@@ -105,9 +105,9 @@ static BOOL get_icon_size( HICON handle, SIZE *size )
size->cy = bmp.bmHeight;
#ifdef __REACTOS__
/*
- If this structure defines a black and white icon, this bitmask is formatted
- so that the upper half is the icon AND bitmask and the lower half is
- the icon XOR bitmask.
+ If this structure defines a black and white icon, this bitmask is formatted
+ so that the upper half is the icon AND bitmask and the lower half is
+ the icon XOR bitmask.
*/
if (!info.hbmColor)
size->cy /= 2;
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d5265b07bbfb6ac6da190…
commit d5265b07bbfb6ac6da190b8213cf2f3f8d9cd675
Author: Joachim Henze <Joachim.Henze(a)reactos.org>
AuthorDate: Sun Jun 13 15:30:49 2021 +0200
Commit: Joachim Henze <Joachim.Henze(a)reactos.org>
CommitDate: Sun Jun 13 15:30:49 2021 +0200
[MSI] Enumerate only type DRIVE_FIXED CORE-17623 (& CORE-14432)
MSI on 2k3sp2 hides empty CD-ROM, and hides CD-ROM with iso mounted.
MSI on 2k3sp2 hides VBox shares, both: writable and read-only-ones.
MSI on 2k3sp2 hides floppy drives with a floppy img mounted.
MSI on XPSP3 hides a mounted writable USB stick.
Thanks to the patches author Doug Lyons.
This patch supersedes
0.4.15-dev-2651-g 864e20b881130cbc9668b8e253a31b8c325e9b99 (CORE-14432)
and we are also better than Wines
https://source.winehq.org/git/wine.git/commit/0dd0d879a1c487dcefedd44762d4e…
---
dll/win32/msi/dialog.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dll/win32/msi/dialog.c b/dll/win32/msi/dialog.c
index 2ed6815ad6b..7a8417ff70c 100644
--- a/dll/win32/msi/dialog.c
+++ b/dll/win32/msi/dialog.c
@@ -3238,7 +3238,7 @@ static void msi_dialog_vcl_add_drives( msi_dialog *dialog, msi_control *control
while (*ptr)
{
#ifdef __REACTOS__
- if (GetDriveTypeW(ptr) == DRIVE_CDROM)
+ if (GetDriveTypeW(ptr) != DRIVE_FIXED)
{
ptr += lstrlenW(ptr) + 1;
continue;
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4b4ffa92f564a334ad919…
commit 4b4ffa92f564a334ad919bdda2404561aa1ab10f
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Thu Jun 10 19:44:59 2021 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Fri Jun 11 02:21:48 2021 +0200
[NTOS:IO] Modify when 'PartitionBuffer' and how 'DriveLayout' are freed in IopCreateArcNamesDisk().
- Manage the lifetime of the temporary 'PartitionBuffer' buffer where
it is locally used only, and free it as soon as possible, just after
calculating the sector checksum. No need to then free it outside of
the main for-loop.
- When the 'DriveLayout' buffer is freed, ensure the pointer is NULL-ed
(and assert this at the top of the main for-loop), since it can also
be freed at cleanup outside this for-loop, and in this case a NULL
check is performed.
This will avoid the scenario of possibly double-freeing a pointer,
in the case the 'DriveLayout' was previously freed (when e.g. reading
the sector for checksum calculation failed), then the for-loop goes to
the next disk and stops early.
---
ntoskrnl/io/iomgr/arcname.c | 38 ++++++++++++++++++++------------------
1 file changed, 20 insertions(+), 18 deletions(-)
diff --git a/ntoskrnl/io/iomgr/arcname.c b/ntoskrnl/io/iomgr/arcname.c
index 3be5930ec69..937b5cfb0c5 100644
--- a/ntoskrnl/io/iomgr/arcname.c
+++ b/ntoskrnl/io/iomgr/arcname.c
@@ -478,6 +478,8 @@ IopCreateArcNamesDisk(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
/* Start browsing disks */
for (DiskNumber = 0; DiskNumber < DiskCount; DiskNumber++)
{
+ ASSERT(DriveLayout == NULL);
+
/* Check if we have an enabled disk */
if (lSymbolicLinkList && *lSymbolicLinkList != UNICODE_NULL)
{
@@ -652,6 +654,7 @@ IopCreateArcNamesDisk(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
&IoStatusBlock);
if (!Irp)
{
+ ExFreePoolWithTag(PartitionBuffer, TAG_IO);
ObDereferenceObject(FileObject);
Status = STATUS_INSUFFICIENT_RESOURCES;
goto Cleanup;
@@ -665,20 +668,26 @@ IopCreateArcNamesDisk(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
Status = IoStatusBlock.Status;
}
- if (!NT_SUCCESS(Status))
+
+ /* If reading succeeded, calculate checksum by adding data */
+ if (NT_SUCCESS(Status))
{
- ExFreePool(DriveLayout);
- ExFreePoolWithTag(PartitionBuffer, TAG_IO);
- ObDereferenceObject(FileObject);
- continue;
+ for (i = 0, CheckSum = 0; i < 512 / sizeof(ULONG); i++)
+ {
+ CheckSum += PartitionBuffer[i];
+ }
}
+ /* Release now unnecessary resources */
+ ExFreePoolWithTag(PartitionBuffer, TAG_IO);
ObDereferenceObject(FileObject);
- /* Calculate checksum by adding data */
- for (i = 0, CheckSum = 0; i < 512 / sizeof(ULONG) ; i++)
+ /* If we failed, release drive layout before going to next disk */
+ if (!NT_SUCCESS(Status))
{
- CheckSum += PartitionBuffer[i];
+ ExFreePool(DriveLayout);
+ DriveLayout = NULL;
+ continue;
}
/* Browse each ARC disk */
@@ -800,29 +809,22 @@ IopCreateArcNamesDisk(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
}
}
- /* Release memory before jumping to next item */
+ /* Finally, release drive layout */
ExFreePool(DriveLayout);
DriveLayout = NULL;
- ExFreePoolWithTag(PartitionBuffer, TAG_IO);
- PartitionBuffer = NULL;
}
Status = STATUS_SUCCESS;
Cleanup:
- if (SymbolicLinkList)
- {
- ExFreePool(SymbolicLinkList);
- }
-
if (DriveLayout)
{
ExFreePool(DriveLayout);
}
- if (PartitionBuffer)
+ if (SymbolicLinkList)
{
- ExFreePoolWithTag(PartitionBuffer, TAG_IO);
+ ExFreePool(SymbolicLinkList);
}
return Status;
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fdd74eb97e79bd7ad62c0…
commit fdd74eb97e79bd7ad62c0fc2f26541db1ff1009c
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Thu Jun 10 19:31:43 2021 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Fri Jun 11 02:21:47 2021 +0200
[NTOS:IO/FSTUB] Fix the determination of 'SingleDisk' in IoGetBootDiskInformation().
The purpose of 'SingleDisk' is the same as in the IopCreateArcNames()
function. It is an optimization for that when looking up the
firmware-recognized ARC disks list, in order to match one of these with
the current NT disk being analysed (see e.g. also in IopCreateArcNamesDisk()),
we avoid a possible IopVerifyDiskSignature() call and directly build a
corresponding ARC name NT symbolic link for it.
'SingleDisk' will actually be TRUE, whether the DiskSignatureListHead
list is empty or contains only one element: Indeed in only both these
cases, 'DiskSignatureListHead.Flink->Flink' will refer to the list head.
(If the list is empty but 'SingleDisk' is TRUE, this does not matter,
because the DiskSignatureListHead looking-up loop never starts.)
---
ntoskrnl/fstub/fstubex.c | 8 +++++---
ntoskrnl/io/iomgr/arcname.c | 4 ++--
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/ntoskrnl/fstub/fstubex.c b/ntoskrnl/fstub/fstubex.c
index 21a0dbd1561..1904d32339a 100644
--- a/ntoskrnl/fstub/fstubex.c
+++ b/ntoskrnl/fstub/fstubex.c
@@ -1866,13 +1866,15 @@ IoGetBootDiskInformation(IN OUT PBOOTDISK_INFORMATION BootDiskInformation,
/* Init some useful stuff:
* Get ARC disks information
- * Check whether we have a single disk
+ * Check whether we have a single disk on the machine
* Check received structure size (extended or not?)
* Init boot strings (system/boot)
* Finaly, get disk count
*/
ArcDiskInformation = IopLoaderBlock->ArcDiskInformation;
- SingleDisk = IsListEmpty(&(ArcDiskInformation->DiskSignatureListHead));
+ SingleDisk = (ArcDiskInformation->DiskSignatureListHead.Flink->Flink ==
+ &ArcDiskInformation->DiskSignatureListHead);
+
IsBootDiskInfoEx = (Size >= sizeof(BOOTDISK_INFORMATION_EX));
RtlInitAnsiString(&ArcBootString, IopLoaderBlock->ArcBootDeviceName);
RtlInitAnsiString(&ArcSystemString, IopLoaderBlock->ArcHalDeviceName);
@@ -2147,7 +2149,7 @@ IoGetBootDiskInformation(IN OUT PBOOTDISK_INFORMATION BootDiskInformation,
}
}
- /* Finally, release drive layout structure */
+ /* Finally, release drive layout */
ExFreePool(DriveLayout);
}
diff --git a/ntoskrnl/io/iomgr/arcname.c b/ntoskrnl/io/iomgr/arcname.c
index bdb3e7b1324..3be5930ec69 100644
--- a/ntoskrnl/io/iomgr/arcname.c
+++ b/ntoskrnl/io/iomgr/arcname.c
@@ -48,8 +48,8 @@ IopCreateArcNames(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
ANSI_STRING ArcSystemString, ArcString, LanmanRedirector, LoaderPathNameA;
/* Check if we only have one disk on the machine */
- SingleDisk = ArcDiskInfo->DiskSignatureListHead.Flink->Flink ==
- (&ArcDiskInfo->DiskSignatureListHead);
+ SingleDisk = (ArcDiskInfo->DiskSignatureListHead.Flink->Flink ==
+ &ArcDiskInfo->DiskSignatureListHead);
/* Create the global HAL partition name */
sprintf(Buffer, "\\ArcName\\%s", LoaderBlock->ArcHalDeviceName);