Commit graph

1192 commits

Author SHA1 Message Date
Jérôme Gardou 91587a432b [NTOS:MM] Fix another instance of reentrant spinlock acquisition 2021-06-29 11:49:20 +02:00
Victor Perevertkin 1c7f3476a0
[CMAKE] Use BUILD_MP CMake option correctly 2021-06-28 17:54:09 +03:00
Jérôme Gardou d1f5c31820 [SDK] Add GCC overrides for SAL annotations
GCC has some functions, variables & type attributes which can be used as aliases
for some of the SAL annotations. Although it's not as rich & precise, it's still useful
since we actually enable -Werror on GCC builds whereas we don't use such an option
on MSVC builds.

For now, _Must_inspect_result_ is aliased to warn_result_unused attribute.
2021-06-28 10:20:57 +02:00
Jérôme Gardou 46af941c4c [NTOS:FSRTL] Check return status of FsRtl locking functions
CORE-17637
2021-06-28 10:20:57 +02:00
Jérôme Gardou d924cb8271 [NTOS:CONFIG] Do not ignore Rtl*String functions return value
CORE-17637
2021-06-28 10:20:57 +02:00
Jérôme Gardou 3ad38f29b5 [NTOS:OB] Use RtlInitUnicodeString for constant string
CORE-17637
2021-06-28 10:20:57 +02:00
Jérôme Gardou 8178996559 [NTOS:SE] Do not ignore SepAccessCheckAndAuditAlarmWorker return value
CORE-17637
2021-06-28 10:20:57 +02:00
Jérôme Gardou 07d38cd4c5 [NTOS:PO] Do not ignore IoRegisterPlugPlayNotification return value
CORE-17637
2021-06-28 10:20:57 +02:00
Jérôme Gardou 230e6b9492 [NTOS:INBV] Do not ignore RtlUnicodeStringToOemString return value
CORE-17637
2021-06-28 10:20:57 +02:00
Jérôme Gardou 838abc475c [NTOS:IO] Do not ignore RtlDuplicateUnicodeString return value
CORE-17637
2021-06-28 10:20:57 +02:00
Jérôme Gardou cf1a95a588 [NTOS:EX] Do not ignore PsCreateSystemThread return value
CORE-17637
2021-06-28 10:20:57 +02:00
Jérôme Gardou 93c0d324e0 [NTOS:EX] Do not ignore RtlAnsiStringToUnicodeString return value
CORE-17637
2021-06-28 10:20:57 +02:00
Jérôme Gardou 376fbc5242 [NTOS:MM] Check result of RtlCreateUnicodeString in MmGetFileNameForAddress
CORE-17637
2021-06-28 10:20:57 +02:00
Jérôme Gardou 3f16c8615c [NTOS:IO] Check RtlCreateUnicodeString return value when initializing PnP services
CORE-17637
2021-06-28 10:20:57 +02:00
Jérôme Gardou 24a4e12a76 [NTOS:IO] Check RtlAnsiStringToUnicodeString return value when initializing Arc names
CORE-17637
2021-06-28 10:20:57 +02:00
Jérôme Gardou 293f823053 [NTOS:IO] Check RtlAnsiStringToUnicodeString return value when initializing ramdisk
CORE-17637
2021-06-28 10:20:57 +02:00
George Bișoc 2791ecd303
[NTOS:PS] Fix several issues within info classes in AMD64 build
ProcessUserModeIOPL, ProcessWow64Information and ThreadZeroTlsCell classes fail on AMD64 build because of wrong IQS values assigned to them. Also explicitly tell the compiler that ProcessUserModeIOPL is strictly for x86 as user mode I/O privilege level is 32-bit stuff.
In addition to that, implement IQS_NO_TYPE_LENGTH macro which it'll be used for classes such as ProcessUserModeIOPL where type length is not required and that it should be 0. With that said, we indirectly fix a size length mismatch issue with ProcessUserModeIOPL on 32-bit of ReactOS as well.
2021-06-25 10:33:18 +02:00
Jérôme Gardou 59cddd15e2 [NTOS:MM] Implement MmFlushImageSection(MmFlushForDelete)
CORE-17544
2021-06-25 10:28:51 +02:00
Jérôme Gardou b3e9c89725 [NTOS:MM] Simplify refcounting when adding/deleting a page in a shared segment
CORE-17544
2021-06-25 10:28:51 +02:00
Jérôme Gardou bec42b6530 [NTOS:MM] Do not call ExAllocatePool* with PFN lock acquired
Unsurprisingly, it actually might acquire it
2021-06-25 10:28:51 +02:00
Jérôme Gardou aa2697df2d [NTOSKRNL] Enforce -fno-common on GCC & CLang builds 2021-06-24 18:48:31 +02:00
Jérôme Gardou c6e9fea844 [NTOSKRNL] Deduplicate some symbols 2021-06-24 18:48:31 +02:00
Jérôme Gardou 1c5ce8d11c [NTOS:MM] Fix-up call site of traced PFNs when serving a page fault 2021-06-24 18:48:31 +02:00
Jérôme Gardou 146337cc50 [NTOS:MM] Save caller address when tracing PFNs 2021-06-24 18:48:31 +02:00
Jérôme Gardou c8ce0cc434 [NTOS:MM] Fix one occurrence of MiDeletePte instead of MiDeletePde 2021-06-22 12:05:20 +02:00
Serge Gautherie c2e454b439 [NTOS:CC] CcRosFlushVacb(): Fix Iosb annotation
Addendum to 2ba1926.
2021-06-22 10:33:45 +02:00
Serge Gautherie eab2bb4b20 [NTOS:MM] MmFlushSegment(): Fix Iosb annotation
Addendum to 90c6a65.
2021-06-22 10:33:45 +02:00
Jérôme Gardou 41de1bd724 [NTOS:KE] Do not allow waiting at IRQL >= DISPATCH_LEVEL when providing a timeout in KeWaitForMultipleObjects
CORE-6473
2021-06-21 11:42:01 +02:00
Timo Kreuzer b627352815 [NTOS][SETUP] Add x64 SMP kernel and make SMP the default boot mode on x64 2021-06-19 12:17:18 +02:00
Timo Kreuzer 396167bc7e [NTOS:MM] Improve an ASSERT 2021-06-19 12:17:18 +02:00
Timo Kreuzer 33949028fb [NTOS:MM] Fix PFN lock usage 2021-06-19 12:17:18 +02:00
Timo Kreuzer f4d47faeb7 [NTOS:KE] Fix usage of KTHREAD::SwapBusy 2021-06-19 12:17:18 +02:00
Timo Kreuzer a011d19ed2 [NTOS:KE] Fix some locking issues 2021-06-19 12:17:18 +02:00
Timo Kreuzer 62f62da8ba [NTOS:KE] Fix KxReleaseSpinLock for 64 bit SMP builds 2021-06-19 12:17:18 +02:00
Timo Kreuzer 2ed56fa794 [NTOS] Fix build with CONFIG_SMP 2021-06-19 12:17:18 +02:00
Timo Kreuzer e6fa62a8d2 [NTOS:MM/x64] Fix Interlocked(Compare)ExchangePte and PAGE_FROM_SSE for x64
This fixes using PFNs with more than 20 bits.
2021-06-19 12:01:24 +02:00
George Bișoc 5912c11650
[NTOS:SE] Minor refactor on NtOpenThreadTokenEx
- Remove a redundant call of ObReferenceObjectByHandle. Not only it didn't make much sense (we reference the object from thread handle and the new thread object referencing the same handle!), specifying a request access of THREAD_ALL_ACCESS for the thread object is kind of suspicious and all of these access rights are unwanted.
- Add some failure checks involving the CopyOnOpen code paths
- Add some DPRINT1 debug prints (concerning the CopyOnOpen code paths as usual)
2021-06-18 18:38:12 +02:00
Hermès Bélusca-Maïto 4864c874a2
[NTOS:IOPNP] Both PNP_PROPERTY_REMOVAL_POLICY_OVERRIDE and PNP_PROPERTY_LOCATION_PATHS are unimplemented, return such status.
Fixes CID 1441387: Uninitialized scalar variable (UNINIT),
in the case of PNP_PROPERTY_LOCATION_PATHS.
2021-06-17 00:35:22 +02:00
Hermès Bélusca-Maïto f2645e48b9
[NTOS:IO] Comment out (and explain why it is there) an unused LdrEntry assignment in IopInitializeBootDrivers(). CID 1237114 2021-06-17 00:35:22 +02:00
Hermès Bélusca-Maïto fe416b67dc
[NTOS:IO] Revert part of commit a82ff90b2: don't do direct ULONG data access: it might be unaligned.
Requested by Victor.
2021-06-17 00:35:21 +02:00
Hermès Bélusca-Maïto 32a82eb123
[NTOS:IO] Fix driverName.Buffer leak in some failure paths in IopGetDriverNames().
driverName.Buffer leaked when the "(!NT_SUCCESS(status) || ServiceName != NULL)"
case is taken because ServiceName != NULL, and some of the functions fail.
2021-06-16 22:18:02 +02:00
Hermès Bélusca-Maïto e09d1dec7a
[NTOS:IO] Fix basicInfo handling in IopGetDriverNames().
- Fix CID 1477246: Uninitialized pointer read (UNINIT) (happens in
  the last ExFreePoolWithTag(basicInfo, TAG_IO) call when the
  "(!NT_SUCCESS(status) || ServiceName != NULL)" case is not taken).

- Centralize all the ExFreePoolWithTag(basicInfo, TAG_IO) cleanups
  at the end of the function.

- Both cases "(driverName.Buffer == NULL)" and "(ServiceName != NULL)"
  can only be taken when basicInfo != NULL, so assert on this fact.
2021-06-16 22:18:02 +02:00
Hermès Bélusca-Maïto 0d28f27156
[NTOS:IO] Fix similar bugs in IopGetDriverNames(), IopInitializeBuiltinDriver() and IopLoadDriver().
- As they are initialized, some registry string values must be NULL-terminated.
- When retrieving REG_DWORD registry values, validate their length.
2021-06-16 22:14:01 +02:00
Hermès Bélusca-Maïto a82ff90b21
[NTOS:IO] Minor code style changes...
- Fix/add comments;
- Reduce indentation level;
- Direct copy for registry integer values;
- Use for-loops for linked lists;
- Use ULONG when the API uses it (sizes for Ob, or REG_DWORD data in registry).
2021-06-16 22:14:01 +02:00
Victor Perevertkin 3f601122bc [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
2021-06-16 12:14:27 +02:00
Victor Perevertkin 34593d933b
[FORMATTING][NTOS][HAL][DRIVERS][SDK] Fix trailing spaces 2021-06-11 15:33:08 +03:00
Hermès Bélusca-Maïto 4b4ffa92f5
[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.
2021-06-11 02:21:48 +02:00
Hermès Bélusca-Maïto fdd74eb97e
[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.)
2021-06-11 02:21:47 +02:00
Hermès Bélusca-Maïto 99078646c3
[NTOS:IO] Avoid hardcoding variable types in sizeofs when possible. 2021-06-11 02:21:47 +02:00
Hermès Bélusca-Maïto 6e65e6b28d
[NTOS:IO] Minor code style fixes (typos; improve comments/DPRINT; IN vs. OUT parameter). 2021-06-11 02:21:47 +02:00