Commit graph

1397 commits

Author SHA1 Message Date
Stanislav Motylkov 84cc81ee29
[NTOS:KE/x64] Detect CPU vendor properly and store value in PRCB
Also generate processor identifier properly based on this value
on the Configuration Manager machine-dependent initialization.

Update processor driver INF file accordingly.

CORE-17970 CORE-14922
2022-01-05 18:28:40 +03:00
Thomas Faber a4b2c80853
[NTOS:KE] Fix buffer overflow when displaying x64 bug checks 2022-01-03 13:25:09 -05:00
Hermès Bélusca-Maïto 10a976e78f
🎊 🍾 🥳 Happy New Year 2022 to the ReactOS Community! 🎆 ⚛️ ☢️
.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:
 __,  ,__)            __,  ,__)       __, ,__)        ░▄████▄░▄███▄░▄████▄░▄████▄░
(--|__| _ ,_ ,_      (--|\ | _       (--\ | _  _ ,_   ░▀▀░▄██░██░██░▀▀░▄██░▀▀░▄██░
  _|  |(_||_)|_)(_|    _| \|(/_(_|_)     \|(/_(_||    ░░▄██▀░░██░██░░▄██▀░░░▄██▀░░
 (        |  |  ,_|   (                (__|           ░██████░▀███▀░██████░██████░
.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:
2022-01-01 00:00:00 +01:00
Stanislav Motylkov f18fb7da09
[NTOS:MM] Unrefernece some dereferences 2021-12-30 01:54:09 +03:00
Victor Perevertkin fd9436d768
[NTOS:PNP] Remove excessive error messages 2021-12-28 04:23:51 +03:00
George Bișoc 3bc2d590a1
[NTOSKRNL] Regroup the pool allocation tags in one dedicated place
We have a special file, tag.h, which serves as a place to store whatever kernel pool allocation tag yet we still have some tags sparse over the kernel code... So just re-group them in one unique place.
2021-12-27 18:57:03 +01:00
Hervé Poussineau 0358fcf9e4 [NTOS:PNP] Let pnproot only report already detected devices
Ignore devices which have DeviceReported=1 in instance key
and not DeviceReported=1 in Control key.

CORE-17874
2021-12-16 16:14:21 +01:00
Hervé Poussineau d380e9777c [NTOS:PNP] Set DeviceReported=1 in Instance key and Control key of legacy devices at report time
CORE-17874
2021-12-16 16:14:21 +01:00
Eric Kohl 990ba54537 [NTOS:LPC] NtReplyWaitReceivePortEx returns the correct TotalLength for connect messages
This fixes the NtAcceptConnectPort apitest.
2021-11-24 18:59:16 +01:00
Eric Kohl 07e19a5e09 [NTOS:IO] Fail, if io completion port and an apc routine are used at the same time
Add checks to NtNotifyChangeDirectoryFile, NtLockFile, NtReadFile and NtWriteFile.
This fixes two ntdll tests.
2021-11-24 13:34:26 +01:00
Thomas Faber 88e3ef5fa0
[NTOS:SE] Don't assert on levels that don't allow impersonation. 2021-11-21 17:19:03 -05:00
Eric Kohl 3e5dcf7937 [NTOS:EX] Fix version specific return value for NtSetSystemInformation:SystemFlagsInformation 2021-11-21 21:42:04 +01:00
Thomas Faber d84022d7fd
[NTOS:SE] Fix always-true assert in SeTokenCanImpersonate.
Courtesy of VS analysis warning C6289:
Incorrect operator:  mutual exclusion over || is always a non-zero constant.  Did you intend to use && instead?
2021-11-21 12:57:50 -05:00
Thomas Faber 0af3689c2e
[REACTOS] Fix traces with missing arguments.
Courtesy of VS Code Analysis warning C6064:
Missing integer argument to 'DbgPrint' that corresponds to conversion specifier 'N'.
2021-11-21 12:57:35 -05:00
Thomas Faber a7b2703479
[NTOS] Fix broken SAL annotations on MmDereferenceSegmentWithLock. 2021-11-21 12:47:46 -05:00
Thomas Faber 2e76fb9fe1
[NTOS:IO] Use a guarded region in IopQueueIrpToThread.
We're protecting against IopCompleteRequest, which is a special
kernel APC. So this is a little bit faster than raising the IRQL.
2021-11-20 14:58:51 -05:00
Hermès Bélusca-Maïto 712f469671
[NTOS:EX] Clarify the situation with the SystemPathInformation class. (#4065)
Since NT 3.51, this information class is trivially implemented.
The path to the NT directory is now stored in KUSER_SHARED_DATA
as the NtSystemRoot member.
Windows Checked builds show the following message and break to
the debugger before failing the function as not implemented:

EX: SystemPathInformation now available via SharedUserData

See https://www.geoffchappell.com/studies/windows/km/ntoskrnl/api/ex/sysinfo/query.htm
and https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/api/ntexapi_x/kuser_shared_data/index.htm
for more information.
2021-11-18 22:37:54 +01:00
Hermès Bélusca-Maïto 1200561fcc
[NTOS:EX] NtQuerySystemInformation: Use same parameter names as documentation. FStatus --> Status. (#4064) 2021-11-18 22:36:07 +01:00
Hermès Bélusca-Maïto d484a68ccb
[NDK][NTOS:EX] Add/fix SAL annotations for Nt/ZwSetSystemInformation + last parameter type. (#4064) 2021-11-18 22:36:07 +01:00
Hermès Bélusca-Maïto 7692a620e7
[NDK][NTOS:EX] Minor formatting. 2021-11-18 22:36:06 +01:00
George Bișoc f909e8762d
[NTOS:SE] Validate the SID lengths when capturing them
SIDs are variadic by nature which means their lengths can vary in a given amount of time and certain factors that allow for this happen. This also especially can lead to issues when capturing SIDs and attributes because SeCaptureSidAndAttributesArray might end up overwriting the buffer during the time it's been called.

Therefore when we're copying the SIDs, validate their lengths. In addition to that, update the documentation header accordingly and add some debug prints in code.
2021-11-16 10:55:44 +01:00
Thomas Faber e8b79e89eb
[NTOS:PS] Fix copypasta in NtQueryInformationJobObject. CID 1441354 2021-11-13 21:23:40 -05:00
Thomas Faber 34f2b7830d
[NTOS:IO] Correctly deal with exceptions when handling FileFsDriverPathInformation. CID 1476847 2021-11-13 21:23:39 -05:00
Thomas Faber a74ff5be17
[NTOS:IO] Don't call IopCompleteRequest with uninitialized context values. CID 716761
NormalContext and NormalRoutine are just for good measure, but
SystemArgument2 is actually used by the function.
And yes, this appears to be a bug in Win 2003.
2021-11-13 21:23:39 -05:00
Thomas Faber 8254585be5
[NTOS:EX] Assert some AcquireResource return values. CID 1321882 2021-11-13 21:23:39 -05:00
Thomas Faber aa9a098196
[NTOS:EX] Correctly handle OOM in NtFindAtom. CID 1237072 2021-11-13 21:23:36 -05:00
George Bișoc 53db5377e2
[NTOS:SE] Implement token filtering
This implements the support of token filtering within the kernel, where the kernel can create restricted tokens of regular ones on demand by the caller. The implementation can be accessed thorough a NT syscall, NtFilterToken, and a kernel mode routine, SeFilterToken.
2021-11-07 14:14:18 +01:00
George Bișoc 05d52aba2b
[NTOS:SE] Partially revert 0129de2
The continue statements do not server any useful purpose in these loops so they're basically pointless. These have been introduced by mistake so my bad.
2021-11-05 10:13:45 +01:00
Serge Gautherie 8110a66b08 [NTOS:MM] MI_IS_*(): Improve documentation
Intel 64 and IA-32 Architectures Software Developer’s Manual
version 075 (June 2021)
2021-11-04 23:20:21 +03:00
Serge Gautherie 94b8095ba2 [NTOS:KE] KiTrap0EHandler(): Use MI_IS_WRITE_ACCESS() 2021-11-04 23:20:21 +03:00
George Bișoc 0129de218b
[NTOS:SE] Mark the token as no longer belonging to admin group upon effective duplication
A scenario where it happens that an access token belongs to an administrators group but it's disabled (that is, SeAliasAdminsSid has no attributes or it doesn't have SE_GROUP_ENABLED turn ON), the function removes this group from the token but still has TOKEN_HAS_ADMIN_GROUP flag which can lead to erratic behavior across the kernel and security modules -- implying that the token still belongs to administrators group.

This is an oversight from my part.
2021-11-04 09:30:00 +01:00
Hervé Poussineau 22d1e7a4e4 [NTOS:IO] Create non volatile registry keys for root devices (as for other devices) 2021-11-01 18:16:25 +01:00
Hervé Poussineau 9967d9aa4c [NTOS:IO] Do not crash when calling IopLegacyResourceAllocation with NULL ResourceRequirements 2021-11-01 18:16:25 +01:00
George Bișoc fdb4205061
[NTOS:SE] Minor cleanup on SepDuplicateToken
The current code that searches for the primary group of token upon duplication is OK as is, remove whatever rest that's no longer needed.
2021-10-23 17:55:12 +02:00
Hervé Poussineau 46fbc6f432 [NTOS:PNP] Fix crash when removing a device without resources
This fixes commit 89fd2b86e4
2021-10-18 22:23:49 +02:00
Hervé Poussineau 89fd2b86e4 [NTOS:PNP] HACK: release resources when device is removed
CORE-17789
2021-10-14 23:39:31 +02:00
Hervé Poussineau 49358f3416 [NTOS:PNP] Fix resource conflict detection
Only resources of HAL were checked against conflicts, not those of PnP Manager

Let IoReportResourceForDetection() make a silent conflict check.
Otherwise IopCheckResourceDescriptor() will always return 'no conflict'.

CORE-17789
2021-10-14 23:39:31 +02:00
Hervé Poussineau a86c3794a6 [NTOS:IO] Remove final NULL char of PDO name before writing to registry
Otherwise, if a PDO has no name (bad!), you'll see two "(Default)" entries
in HKLM\HARDWARE\RESOURCEMAP\PnP Manager\PnpManager
2021-10-14 23:39:30 +02:00
Victor Perevertkin 43f1d91687
[NTOS:PNP] Fix resource conflict detection
Previous code did not detect equal resource ranges as conflicting.
Thanks Hervé Poussineau for pointing this out!

Meanwhile, simplify the code to make it more readable.
2021-10-13 00:00:25 +03:00
Rafał Mikrut 54d5ad7533
[NTOS:KE] Fix copy paste bug in exception helper routine for ARM (#4005) 2021-10-07 23:04:19 +03:00
George Bișoc 9c1c88de3e
[NTOS:SE] Define a name macro for the threshold value
Instead of having this magic value as is, describe it within a macro for readability purposes.
2021-09-27 09:39:23 +02:00
George Bișoc 199f575342
[NTOS:SE] Check the privilege count against the maximum threshold
In SeCaptureLuidAndAttributesArray we must ensure that we don't go onto a potential integer overflow scenario by checking against the maximum limit threshold the kernel states. In addition, write an explicit name macro for the value.
2021-09-27 09:37:28 +02:00
Hermès Bélusca-Maïto 9462350a92
[NTOS:RAWFS] LE JOKE! - Commit 7716bddd (r24564) claimed to "actually create the \\Device names so that user-mode can even talk to it", yet didn't bother to do that!
Certainly due to copy-pasta error from the original code.

A consequence of this oversight, was that the IoGetDeviceObjectPointer()
calls on these device names, in fltmgr!DriverEntry() couldn't work.
(See drivers/filters/fltmgr/Interface.c, line 1880 and below.)
2021-09-26 03:02:58 +02:00
Hermès Bélusca-Maïto 5ccd45ea58
[NTOS:RAWFS] Delete the previously-created devices in case the IoCreateDevice() calls fail. 2021-09-26 03:02:57 +02:00
Hermès Bélusca-Maïto 74513a75ab
[NTOS:OB] Minor refactoring.
- NtQuerySymbolicLinkObject(): Use an intermediate variable for the object header.
- Simplify code in ObpLookupEntryDirectory() by calling ObpReleaseLookupContextObject() instead.
- Use TAG_OBJECT_TYPE instead of hardcoded tag values.
2021-09-25 01:09:01 +02:00
Hermès Bélusca-Maïto 4c63ed5a7a
[NTOS:OB] Clarify and fix the usage of the Obp*DirectoryLock*() and ObpReleaseLookupContextObject() functions.
- Disentangle the usage of ObpAcquireDirectoryLockExclusive() when it's
  used only for accessing a directory structure, or as part of a lookup
  operation.

  The Obp*DirectoryLock*() -- both shared and exclusive -- functions
  are only for locking an OB directory, for reading or writing its
  structure members.

  When performing lookup operations (insertions/deletions of entries
  within a directory), use a ObpAcquireLookupContextLock() function that
  exclusively locks the directory and saves extra lock state, that can
  be used by ObpReleaseLookupContextObject() for cleanup.

- Add documentation for these functions.
2021-09-25 00:47:43 +02:00
George Bișoc 19cdb521d2
[NTOS:OB] Acquire the lock before setting directory's session ID 2021-09-24 19:49:40 +02:00
George Bișoc 0b4763f1b1
[NTOS:SE] Do not set SE_DACL_PRESENT flag that early
The function might assign the flag yet it could possibly fail on creating a DACL and insert an "access allowed" right to the access entry within the DACL. In this case, make sure we actually succeeded on all the tasks and THEN assign the flag that the DACL is truly present.

Also, make sure that the Current buffer size variable gets its new size so that we avoid overidding the memory of the DACL if the security descriptor wants both a DACL and SACL and so that happens that the DACL memory gets overwritten by the SACL.
2021-09-24 19:39:30 +02:00
George Bișoc f341b9080b
[NTOS:SE] Set the SACL to the World security descriptor
Implement the portion chunk of code that is responsible for setting the system access control list (SACL) to the World security descriptor, based from SeWorldSid (World security identifier).
2021-09-24 19:13:16 +02:00
George Bișoc 8e6fc7a5f5
[NTOS:SE] Implement token groups adjusting 2021-09-23 17:38:31 +02:00
George Bișoc 982ee872dd
[NTOS:SE] Privileges adjusting private routine must be paged
SepAdjustPrivileges is a private helper call that must be paged, alongside with its syscall -- NtAdjustPrivilegesToken.
2021-09-21 17:40:53 +02:00
Victor Perevertkin 62d1a2c884
[CMAKE] Fixes for clang-cl build
- User lib.exe instead of llvm-lib due to incompatibility
- Avoid wrapping resource compiler with cmcldeps
- Fix several conditional flags
2021-09-14 17:58:23 +03:00
Hermès Bélusca-Maïto 9393fc320e
[FORMATTING] Remove trailing whitespace. Addendum to 34593d93.
Excluded: 3rd-party code (incl. wine) and most of the win32ss.
2021-09-13 03:52:22 +02:00
Hermès Bélusca-Maïto 9b1edceae1
[REACTOS] Fix some instances of DPRINTs with trailing whitespace before newlines. 2021-09-13 03:52:19 +02:00
Hermès Bélusca-Maïto 6e9ff14e26
[NTOS:KD64,KE] IRQL is automatically adjusted during calls to KdEnterDebugger() and KdExitDebugger(). (#3942)
Addendum to 608032bd and 835c3023.

The IRQL is actually raised by KeFreezeExecution() and lowered by
KeThawExecution(), always to HIGH_IRQL on MP systems, or if necessary
on UP. These functions are called respectively by KdEnterDebugger()
and KdExitDebugger().
2021-09-12 18:20:32 +02:00
Hermès Bélusca-Maïto 05590079cc
[NTOS:KD64] First unlock the KD port then lower the IRQL, instead of doing the reverse. (#3942)
This properly reverses the operation of first raising the IRQL before
locking the KD port.
2021-09-12 18:19:59 +02:00
Hermès Bélusca-Maïto c9f335e996
[NTOS:KD64] KdPollBreakIn(): Use the KeRestoreInterrupts() inline. 2021-09-12 18:16:13 +02:00
George Bișoc fc5bc55fbb
[NTOS:SE] Use the captured security descriptor when access checking
When performing access security check, use the security descriptor that we've captured it to determine based on that descriptor if the client can be granted access or not.
2021-09-12 16:07:44 +02:00
George Bișoc d7255f1584
[NTOS:SE] Explicitly check the auto inherit flags right away
As we now have the SEF_* flags declared within the SDK we can simply check for such flags directly wihout having to check for the hard-coded flag values.
2021-09-09 19:29:53 +02:00
Stanislav Motylkov 3f4c98a425
[ARM] Fix some compilation errors for ARM
CORE-17634 CORE-17604
2021-09-09 19:40:20 +03:00
Hermès Bélusca-Maïto 4795d953c0
[NTOS:IO] Fix an ASSERT. Addendum to commit 1fd730b7. 2021-09-06 01:05:14 +02:00
Hermès Bélusca-Maïto fe9ac14aa3
[NTOS] Move two CODE_SEG("INIT") to a better place. 2021-09-05 21:22:45 +02:00
Hermès Bélusca-Maïto 1fd730b781
[NTOS:IO] IopInitializeDriverModule(): Set the DRVO_LEGACY_DRIVER flag if the driver is not WDM. (#3749) 2021-09-05 20:31:08 +02:00
George Bișoc c407460f6a
[NTOS:SE] Implement effective token option upon duplication
This implements the EffectiveOnly option of SepDuplicateToken routine (used by NtDuplicateToken syscall and other functions alike) which makes the access token effective by removing the disabled parts like privileges and groups.
2021-09-05 17:01:21 +02:00
George Bișoc 84f7bee18f
[NTOS:SE] SepSinglePrivilegeCheck doesn't expect a NT status code value
Fix a wrong returned datatype of the function, as SepSinglePrivilegeCheck calls the internal private SepPrivilegeCheck function which returns a BOOLEAN value.
2021-08-22 11:31:57 +02:00
George Bișoc 8567d8145e
[NTOS:SE] Annotate the remaining functions with SAL 2021-08-22 10:29:58 +02:00
George Bișoc 6413009c10
[NTOS:SE] Document the whole subsystem in Doxygen format
And update the file comment headers.
2021-08-22 10:29:47 +02:00
Victor Perevertkin 6ef6fabfc5
[FREELDR][NTOS][HALPPC][SDK] Remove PowerPC code
Remove PowerPC-related code from the kernel, HAL, SDK and
Freeloader.
2021-08-15 15:35:51 +03:00
James Tabor a81ad376a1 Check for PAE
Checking for PAE and set some logic later to support it.
2021-08-08 20:37:06 -05:00
Jérôme Gardou 589016ddb9 [NTOS:MM] Implement MmFlushImageSection(MmFlushForWrite) 2021-08-07 09:34:58 +02:00
Jérôme Gardou 6618d978cd [CMAKE] Do not disable optimisations on ntoskrnl build 2021-08-06 15:17:49 +02:00
Jérôme Gardou acf28dbc1e [NTOS:MM] Fix the mess created by the "balancer thread"
When processing:
  Make sure that the process is not terminating.
  Make sure that the process WorkingSet is still valid
  Protect accessing & writing to PTEs by acquiring the working set lock

CORE-17595 CORE-17642
2021-08-05 10:06:19 +02:00
Jérôme Gardou 676dc4b441 Revert "[NTOS:MM] Do proper checks & acquire proper locks when sweeping user pages"
This reverts commit 7c006df7e0.
Note to self: This is what happens when you have too many branch and push the wrong one.
2021-08-04 23:57:39 +02:00
Jérôme Gardou 7c006df7e0 [NTOS:MM] Do proper checks & acquire proper locks when sweeping user pages
CORE-17595
2021-08-04 20:38:37 +02:00
Jérôme Gardou 789d7a7741 [NTOS:MM] When mapping pages for zeroing them, disable cache, enable write through
Idea from Thomas Faber
2021-08-04 17:48:39 +02:00
Jérôme Gardou 98e62b9bca [NTOS:MM] In page zeroing thread, zero more than one page at a time. 2021-08-04 17:48:39 +02:00
Jérôme Gardou e98de5ef1f [NTOS:MM] Use KeZeroPages in zeroing thread 2021-08-04 17:48:39 +02:00
Jérôme Gardou 708dc6b7d6 [NTOS:MM] Do not zero-fill pages when not needed 2021-08-04 17:48:39 +02:00
Jérôme Gardou 42bec35f65 [NTOS:KE] Also rewrite KeZeroPages in assembly for amd64
Let's stick with "rep movsq" until we are able to have more precise benchmarks
2021-08-04 17:48:39 +02:00
Jérôme Gardou 51258295bd [NTOS:KE] Rewrite KeZeroPages in assembly
We spend a lot of time in this function, let's optimize it.
2021-08-04 17:48:39 +02:00
Jérôme Gardou 34662e2f6f [NTOS:MM] Copy the WorkingSet page when initializing "hand-built" process
CORE-17642
2021-08-04 11:49:38 +02:00
Jérôme Gardou be6a6b806a [NTOS:MM] Remove dead code 2021-08-03 10:57:12 +02:00
Victor Perevertkin 5176f580e5
[CMAKE] Add memcmp to libntoskrnl for both clang and clang-cl 2021-08-02 20:23:22 +03:00
George Bișoc 632fa1cfbe
[NTOS:SE] Handle the reference logon session of the token
When creating or duplicating an access token object, make sure that the logon session is getting referenced by the token must be inserted onto the logon reference member (a.k.a LogonSession) for proper logon session referencing tracking.

Also when a token object is about to be destroyed or that we are taking away a reference session from it, we must ensure that the referenced logon session data gets removed from the token in question.
CORE-17700
2021-07-31 17:23:05 +02:00
George Bișoc 5e51f8dad2
[NTOS:SE] Implement logon reference insertion/removal to tokens 2021-07-31 16:11:03 +02:00
George Bișoc 7692c10527
[NTOS:SE] Unify all the SRM tags in one place
And rename SEP_LOGON_SESSION_TAG and SEP_LOGON_NOTIFICATION_TAG to TAG_LOGON_SESSION and TAG_LOGON_NOTIFICATION respectively.
2021-07-31 16:10:50 +02:00
Jérôme Gardou b0dfe20981 [NTOS:MM] Fix MiIsUserPte inline 2021-07-30 18:54:54 +02:00
Jérôme Gardou ce65553eaa [NTOS:MM] Annotate some functions with regards to MmPfnLock
Also fix MI_ASSERT_PFN_LOCK_HELD macro.
Now in debug builds, SpinLocks are always non-zero when held.
2021-07-27 15:36:55 +02:00
Jérôme Gardou 6150dc994a [NTOS:MM] Always release PFN lock in MmDereferenceSegmentWithLock
All callers release it after calling it.
CORE-17698
2021-07-27 15:36:55 +02:00
George Bișoc e2a8585edc
[NTOS:SE] Remove redundant commented call on token duplication
When duplicating an access token, the authentication ID is already copied from the existing token to the new one anyway so there's no point on having the commented call still left in the code.
2021-07-25 18:02:32 +02:00
Timo Kreuzer a3763c61dc [PSDK][NDK] Use hex to define MIN/MAX constants like in native SDK
This fixes use of unary minus operator on unsigned type warning.
2021-07-23 22:03:48 +02:00
Hervé Poussineau ad370238d7 [NTOS:PS] Support using QUOTA_LIMITS_EX in NtSetInformationProcess(ProcessQuotaLimits)
Both QUOTA_LIMITS and QUOTA_LIMITS_EX are already supported in PspSetQuotaLimits,
but this was broken by a330b56787
2021-07-15 19:33:45 +02:00
George Bișoc 506cee3219 [NTOS:SE] Implement logon session termination notification
Note to SELF and EVERYONE: the commit implements the initial logon session termination notification implementation, the SeMarkLogonSessionForTerminationNotification function, but as it currently stands there are several other tasks to be addressed in the future in order for the logon termination notification to be fully completed. The tasks as of which are.

1. Our SepRmDereferenceLogonSession is not fully implemented, as it doesn't inform the LSA and filesystems of logon deletion notification
2. Implement two worker routines that are actually in charge of such tasks of informing LSA and FSDs
3. Perform logon deletion
4. Do further investigations and check whatever that is left to address, if any
2021-07-15 19:31:46 +02:00
Timo Kreuzer 47372e2ac9 [NTOS:MM] Fix MiSetSystemCodeProtection
CORE-16387 CORE-17638
Windows only makes the header RO for session space mapped drivers (win32k, dx and display drivers)
2021-07-11 21:43:07 +02:00
George Bișoc 7fb0d13a46
[NTOS:SE] Move SQOS capturing in its own file
* Quality of service kernel stuff bears nothing with security descriptors in anyway, so just have a file specifically for it
* Annotate the function arguments parameters with SAL
* Document the functions
2021-07-05 09:39:06 +02:00
George Bișoc ff0a325116
[NTOS:SE] Allocate pool memory for security descriptor based on the caller pool type request
We're indiscriminately allocate the pool as non paged all the time, thus further ignoring the pool type parameter of the function.
2021-07-04 11:01:54 +02:00
Oleg Dubinskiy 94054a5735 [NTOS:IO] OpenRegistryHandlesFromSymbolicLink: Use REG_OPTION_NON_VOLATILE
Use REG_OPTION_NON_VOLATILE instead of REG_OPTION_VOLATILE in all ZwCreateKey calls of OpenRegistryHandlesFromSymbolicLink, since the keys created/opened by this function, should be non-volatile (in other words, be saved after reboot).
Also Device Parameters subkey that is created in IoOpenDeviceInterfaceRegistryKey (which uses that routine as well), is non-volatile too, so the parent keys whose contain it, cannot be volatile.
It will fix an error with status 0xc0000181 (STATUS_CHILD_MUST_BE_VOLATILE) occuring during loading kernel mode audio drivers from Windows XP/2003, especially checked (debug) versions, with my IoGetDeviceInterfaceAlias implementation. Also it may fix other error cases.
CORE-17361
2021-07-03 21:44:33 +02:00
George Bișoc c869c4778d
[NTOS:SE] Assign the control flag bits to the newly created security descriptor
We allocate memory pool for a new security descriptor with specific info filled by the caller but we don't set the control flag bits for the newly allocated descriptor, which is wrong. Originally spotted by Vadim Galyant.
CORE-17650
2021-07-03 17:20:48 +02:00
Jérôme Gardou 37d0a9c3f4 [NTOS:KE] Unconditionally check IRQL when acquiring & releasing spinlock at DISPATCH_LEVEL 2021-06-29 11:49:20 +02:00
Jérôme Gardou f30136bc79 [NTOS:KE] Test spinlock ownership on both UP & MP build
There is no reason not to, and this avoids introducing bugs stupidly.
2021-06-29 11:49:20 +02:00
Jérôme Gardou 835c30232e [NTOS:KD][NTOS:KD64][NTOS:KDBG] Fix IRQL & spinlock use
KD64: Raise to HIGH_LEVEL when entering trap
KDBG: lower to DISPATCH_LEVEL when applying IRQL hack & use a worker thread to load symbols
KD&KDBG: Actually unload symbols when required
2021-06-29 11:49:20 +02:00
Jérôme Gardou 79c2972035 [NTOS:KD] Release lock before calling KdpPrint
Avoiding resursive spinlock acquisition
2021-06-29 11:49:20 +02:00
Jérôme Gardou 608032bd08 [NTOS:KD64][NTOS:KDBG] Fix spinlocks use
Raise IRQL before entering debugger, so that KeAcquireSpinLockAtDpcLevel works as expected.
 - HIGH_LEVEL since we don't know where we are coming from.

Do not try to read debug symbol from files in KDBG.
 - There is no reason that this works if Mm didn't map it in the first place.
2021-06-29 11:49:20 +02:00
Jérôme Gardou 66dea86d68 [NTOS:KDBG] Use internal KdpDPrintf instead of DbgPrint
DbgPrint is implemented through a breakpoint, and then KD tries to recursively
lock its own spinlock. Call a lower level routine instead.
2021-06-29 11:49:20 +02:00
Jérôme Gardou e312a40ae2 [NTOS:KE] Implement KeAcquireInStackQueuedSpinLockForDpc & KeReleaseInStackQueuedSpinLockForDpc 2021-06-29 11:49:20 +02:00
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