Commit graph

1246 commits

Author SHA1 Message Date
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