Commit graph

137 commits

Author SHA1 Message Date
Colin Finck c2c66aff7d Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
Eric Kohl 58e9053fbc [NTOSKRNL]
- Initialize SepRmDbLock and create the system and anonymous logon sessions in Phase 0, right before the system process token is created.
- Implement functions to reference and dereference a logon session.
- Reference a logon session in SepCreateToken and SepDuplicateToken.
- Dereference a logon session in SepDeleteToken.

svn path=/trunk/; revision=69735
2015-10-29 22:50:14 +00:00
Timo Kreuzer 5ebaa3c3dd [NTOSKRNL]
- Implement SeCheckAuditPrivilege and use it instead of SeSinglePrivilegeCheck, because the latter uses the effective token and we want the primary token
- Implement SePrivilegedServiceAuditAlarm
- Add and initialize missing SeLocalServiceSid and SeNetworkServiceSid

svn path=/trunk/; revision=62245
2014-02-18 17:51:45 +00:00
Timo Kreuzer c01564fe18 [NTOSKRNL]
- Halfplement SeReportSecurityEvent, stub SeSetAuditParameter and enable both exports, which are SP1!

svn path=/trunk/; revision=62207
2014-02-16 09:08:22 +00:00
Timo Kreuzer c135323120 [NTOSKRNL]
Move access check code out of semgr.c into accesschk.c, no code change.

svn path=/trunk/; revision=62035
2014-02-08 14:48:15 +00:00
Timo Kreuzer 8b8043e5bf [NTOSKRNL]
- Implement NtPrivilegedServiceAuditAlarm, the internal function SepAdtPrivilegedServiceAuditAlarm is not implemented yet.
- Stubplement SepAccessCheckAndAuditAlarm and make NtAccessCheckAndAuditAlarm, NtAccessCheckByTypeAndAuditAlarm, NtAccessCheckByTypeResultListAndAuditAlarm and NtAccessCheckByTypeResultListAndAuditAlarmByHandle (love that name) wrappers around it.

svn path=/trunk/; revision=61753
2014-01-22 16:29:26 +00:00
Eric Kohl 40ff0c70f0 [NTOSKRNL]
- Create the Security directory and the LSA_AUTHENTICATION_INITIALIZED event in SepInitializationPhase1().
- Get rid of SeInitSRM().

svn path=/trunk/; revision=61102
2013-11-26 15:27:48 +00:00
Hermès Bélusca-Maïto 645b7d2b00 [REACTOS]
Fix TOO MANY !! :(((( "initialize" misspellings.

Note1: One remains in subsystems/csr/csrsrv/init.c, but will be corrected in my future csrss branch merging.
Note2: In ntoskrnl/se/semgr.c, one tries to create the "LSA_AUTHENTICATION_INITALIZED" event. This is ROS-SPECIFIC !!!! In the sense that it doesn't exist on Windows. Instead, the "LSA_AUTHENTICATION_INITIALIZED" exists. Correct that fact.

svn path=/trunk/; revision=58679
2013-04-04 20:11:17 +00:00
Pierre Schweitzer e6f8602d9d [NTOSKRNL]
Implement SeFastTraverseCheck().
For more information, see:
- http://msdn.microsoft.com/en-us/library/windows/desktop/aa374872(v=vs.85).aspx
- http://msdn.microsoft.com/en-us/library/windows/desktop/aa446683(v=vs.85).aspx

svn path=/trunk/; revision=58230
2013-01-26 19:33:54 +00:00
Alex Ionescu 17fd92fc7b [NTOSKRNL]: Use the token lock acquire/release macros that were already written instead of manually doing it. Also fix the macros since they didn't work in GCC.
No functional change, just code cleanup.

svn path=/trunk/; revision=57284
2012-09-12 16:29:28 +00:00
Alex Ionescu fd222f669a [NTOSKRNL]: Small refactoring and optimizations to some Se routines, mainly generalizations for Restricted Token support once someone implements it. Also start using the token lock when necessary. Add comments when missing. Nothing terribly exciting...
[NTOSKRNL]: As a side effect, implement SeCreateClientSecurityFromSubjectContext and SeGetTokenControlInformation, although most of the code was already there.
[NTOSKRNL]: One useful change, SE_GROUP_USE_FOR_DENY_ONLY (Deny Only Groups) are now handled correctly.

svn path=/trunk/; revision=57261
2012-09-10 08:15:43 +00:00
Alex Ionescu 82a8352b60 [NTOSKRNL]: Fix two NtAccess function prototypes (NO-OP, not implemented/used)
[NTOSKRNL]: Add missing call to ObValidateAccessMask (NO-OP, always returns TRUE).

svn path=/trunk/; revision=57256
2012-09-09 16:59:23 +00:00
Thomas Faber 4b9b72182c [NTOSKRNL]
- Export SeTokenObjectType

svn path=/trunk/; revision=56376
2012-04-21 06:35:45 +00:00
Alex Ionescu e96c88b49b [NTOSKRNL]: Fix the zombie fix. Should fix toolhelp tests.
[NTOSKRNL]: If you're going to fake success when doing access checks, also grant the rights that would normally be refused, for consistency's sake. Should fix a bunch of the kernel32:synch tests (which have nothing to do with synch...).

svn path=/trunk/; revision=55737
2012-02-20 07:30:26 +00:00
Sir Richard 85e5b5be56 [NTOS]: Mark all initialization functions INIT_FUNCTION.
[NTOS]: This will save ~280KB of RAM once we dump INIT from RAM in a future patch.
[NTOS]: Display current free RAM at certain checkpoints.

svn path=/trunk/; revision=49445
2010-11-02 16:29:06 +00:00
Eric Kohl f0910f33d3 [FORMATTING]
No code changes.

svn path=/trunk/; revision=47383
2010-05-28 16:28:27 +00:00
Eric Kohl c1a9403d49 Enable old access check code until the bug that keeps the device installer from working has been fixed.
svn path=/trunk/; revision=46811
2010-04-10 11:44:57 +00:00
Eric Kohl 2af6abad95 [NTOSKRNL]
Ignore inherit only ACEs in a DACL.

svn path=/trunk/; revision=46714
2010-04-04 12:34:53 +00:00
Eric Kohl 2b4f3854dd [NTOSKRNL]
- Check access rights according to the DACL. Granted rights are removed from the remaining rights variable.
- Return success only if there are no more remaining rights. Return failure otherwise.
- Remove outdated code.

svn path=/trunk/; revision=46703
2010-04-03 21:21:52 +00:00
Eric Kohl d384dbd46a [NTOSKRNL]
- Implement the calculation of access rights for the MAXIMUM_ALLOWED case.

svn path=/trunk/; revision=46695
2010-04-03 10:52:17 +00:00
Eric Kohl 74e30b9093 [NTOSKRNL]
- Add the check for ACESSS_SYSTEM_SECURITY.
- Keep the desired access rights that have not been granted yet in the variable RemainingAccess.
- Handle the MAXIMUM_ALLOWED case if the DACL is empty.

svn path=/trunk/; revision=46689
2010-04-02 17:46:24 +00:00
Eric Kohl 249d39c17a [NTOSKRNL]
- Check the SeTakeOwnership privilege only if WRITE_OWNER access is desired.
- Move the check for token ownership from SepAccessCheck because this check grants access rights rather than checking them.

svn path=/trunk/; revision=46683
2010-04-02 15:13:24 +00:00
Eric Kohl baeb295134 [NTORKRNL]
SepAccessCheck: Deny access if the DACL is is empty (but not NULL).

svn path=/trunk/; revision=46629
2010-03-31 21:02:38 +00:00
Eric Kohl abf91accdb [NTOSKRNL]
- Move subject context locking to SeAccessCheck because NtAccessCheck already locks it.
- Do not use the captured security descriptor in NtAccessCheck yet, because SeCaptureSecurityDescriptor seems to create broken SDs.

svn path=/trunk/; revision=46626
2010-03-31 19:53:19 +00:00
Eric Kohl d69c4c5248 [NTOSKRNL]
- Capture the security descriptor before passing it to SepAccessCheck.
- Move the security descriptor check and the impersonation level check from SepAccessCheck to SeAccessCheck.

svn path=/trunk/; revision=46605
2010-03-30 20:16:26 +00:00
Eric Kohl e3949430d7 [NTOSKRNL]
- Move kernel-mode check around, so we won't run it twice when calling NtAccessCheck.
- Fix a wrong check for security descriptors with a NULL-DACL.

svn path=/trunk/; revision=46602
2010-03-30 17:01:23 +00:00
Eric Kohl 2ce28dacb7 [NTOSKRNL]
NtAccessCheck: Check for a valid security descriptor.

svn path=/trunk/; revision=46491
2010-03-27 16:54:02 +00:00
Eric Kohl 0a82f829ed [NTOSKRNL]
NtAccessCheck:
- Fix returned status if the token is not an impersonation token.
- Add a check for the token impersonation level.

svn path=/trunk/; revision=46347
2010-03-23 00:16:14 +00:00
Eric Kohl 1b3286b8e0 [NTOSKRNL]
NtAccessCheck
- Probe parameters.
- Fail if generic access rights have not been mapped.

svn path=/trunk/; revision=46297
2010-03-21 14:10:50 +00:00
Sir Richard 6b007be4cd [NTOS]: While attempting to ressucitate the user-mode shutdown code in CSRSS (disabled since 2006), it seemed clear that one of the main steps is to obtain the caller's LUID in order to kill the right processes. This LUID is obtained from the current thread's token, and we know it's the callers since we're supposed to impersonate the caller. Unfortunately, impersonation failed, making the whole process fail.
Impersonation failed because NtImpersonateThread was actually inverting the THREAD_IMPERSONATE rights, asking the client thread for the server's permissions, and vice versa. Fixing this resulted in yet another failure.
        Analysis of this failure showed that even opening the server (ie: current) thread for THREAD_DIRECT_IMPERSONATION failed, which is unusual since the current thread should have access to all its rights. This is determined in PspCreateThread when the ETHREAD->GrantedAccess field is set.
        Continuing onto this path, tracing revealed that GrantedAccess was merely 0x1607F and not 0x1F3FF as expected, meaning that not all rights were given, including the impersonate right (0x200), explaining the failure, but not the deeper reason behind it.
        Attempting to identify which code path set this GrantedAccess, the SepAccessCheck routine came to light. A bug there caused MAXIMUM_ALLOWED accesses to fail in certain scenarios, such as when the object had no security descriptor, because MAXIMUM_ALLOWED would be granted as an absolute value, when instead of it is a flag that should grant GENERIC_ALL. Fixing that bug, the failure continued.
        Further analysis identified that the Administrators SID was being found with GENERIC_READ + WRITE + EXECUTE access, and no SID was found for GENERIC_ALL access. This happened when searching the system token's default DACL, which is assigned to the kernel (but for kernel-mode callers, this check was skipped), smss, winlogon, etc.
        The code for creating this system token was heavily hacked, so the function to create the system token, as well as NtCreateToken were refactored to use a common piece of token-creating code. Furthermode, the system token was correctly created with Local System as the user, and Administrators as one of the groups. Finally, SeDefaultDacl was used (already setup properly) instead of a badly configured Default DACL. The new shared code also correctly sets the SE_GROUP_ENABLED flag on all SE_GROUP_MANDATORY groups, and scans tokens to set the TOKEN_HAS_ADMIN_GROUP and TOKEN_HAS_TRAVERSE_PRIVILEGE flags which were not previously set.
        With the correct system token and default DACL, the Local System SID was now found, but the failure continued. This was revealed to be due to an even deeper rooted problem, as the SepIsSidInToken routine checked for SE_GROUP_ENABLED before listing a SID as "present". Although this is correct for actual groups, the User SID will never have the SE_GROUP_ENABLED flag as it is not a group. This caused any granted access ACE belonging to a user (instead of a group) to be ignored, causing either access check failures, or limited rights returned (in the MAXIMUM_ALLOWED case).
        Upon fixing this bug, the NtImpersonateThread call finally returned success, since the rights were now correct. Promptly upon calling NtOpenThreadToken to query the LUID however, the system ASSERTED with FALSE.
        The code at fault was a line in NtOpenThreadTokenEx which forcefully ASSERTed if the impersonation code path was taken, presumably because this was never tested, and ReactOS would actually always fail impersonation attempts due to the bugs fixed above. This routine was thus quickly reworked to fix some mistakes (such as forgetting to actually impersonate the client, incorrect referencing/dereferencing of thread/tokens, and assumptions about DACL creation success).
        Having fixed the NtOpenThreadTokenEx routine, the LUID query now went through for the impersonated token, but soon causing a user-mode crash, due to an incorrect parameter reference in the CsrGetProcessLuid function in the csrsrv code by Alex (which I copy/pasted to reduce code duplication).
        Fixing this final bug finally allowed the correct LUID to be queried and I was able to continue development of not-yet-commited user-mode shutdown code.

svn path=/trunk/; revision=46028
2010-03-09 10:35:58 +00:00
Aleksey Bragin 88e41959e1 [ntoskrnl/se]
- Add a hack which prints an annoying message and grants access when it should not be. Callers/bugs should be fixed and this commit reverted after that.
See issue #4169 for more details.

svn path=/trunk/; revision=44348
2009-12-01 21:26:40 +00:00
Aleksey Bragin 78b292be2c [ntoskrnl/se]
- Factor out working code from SeAccessCheck into SepAccessCheck, taking out addition parameter - LowerImpersonationLevel. The lowest level for SeAccessCheck remains SecurityImpersonation, but for NtAccessCheck it's lowered to SecurityIdentification. Name of this patch's author has been lost.
See issue #4169 for more details.

svn path=/trunk/; revision=44260
2009-11-21 17:58:33 +00:00
Dmitry Chapyshev 8954edb33c - Add missed checks of memory allocation failures
svn path=/trunk/; revision=42980
2009-09-02 13:02:30 +00:00
Dmitry Gorbachev ff37974bba Remove a hack from NtAccessCheck(). Bug #4169.
svn path=/trunk/; revision=41610
2009-06-25 13:29:58 +00:00
Dmitry Gorbachev 8101b8e12f Hack: partially undo r38510 changes to overcome regression (bug #4169).
svn path=/trunk/; revision=41603
2009-06-24 22:23:29 +00:00
Stefan Ginsberg fbd7681b84 - Cleanup AccessCheck, and set the correct last error in the case where the check succeeds but access is denied
- Cleanup NtAccessCheck, properly set desired access when previous mode is kernel, remove a duplicate check that is performed in SeAccessCheck, and don't fail with STATUS_ACCESS_DENIED when the check succeeds but denies access -- the result of the access check is returned in the 'AccessStatus' parameter

svn path=/trunk/; revision=38510
2009-01-02 17:39:45 +00:00
Aleksey Bragin 2794dbc70a - Impersonation level should be indeed higher that the lowest one. Fix the check accordingly. Spotted by Dmitry Gorbachev and GCC.
See issue #3939 for more details.

svn path=/trunk/; revision=37998
2008-12-10 15:24:55 +00:00
Dmitry Gorbachev 32580ec32a Silence GCC warnings.
svn path=/trunk/; revision=37919
2008-12-07 21:52:22 +00:00
Stefan Ginsberg 165bfe865b - STDCALL -> NTAPI
svn path=/trunk/; revision=37745
2008-11-29 20:47:48 +00:00
Stefan Ginsberg 4353142bc2 - Rename SeInit to SeInitSystem
svn path=/trunk/; revision=35413
2008-08-17 18:34:37 +00:00
Aleksey Bragin 9dc0da2dea - Reformat Se code and put functions to more appropriate locations.
svn path=/trunk/; revision=33129
2008-04-23 20:38:37 +00:00
Aleksey Bragin 89484a110d The default object security method should not directly call Se* routines on the Security Descriptors, since they belong to the object manger security descriptor cache, and they need to be referenced and dereferenced in order to make sure they don't disappear from beneath the caller.
Additionally, the code for the "Set" operation should actually go in SeSetSecurityDescriptorInfo API, which was unimplemented. By simply copying the code over, this API is now implemented, and the routine works as expected.
Also, the default method was not handling "delete" requests, but was ignoring them, resulting in memory leaks and never-dereferenced descriptors.
Thanks to Alex for finding these bugs. Alex also says SeSetSecurityDescriptorInfo should call the Rtl package (RtlSetObjectSecurity) but we don't implement those functions yet.

svn path=/trunk/; revision=32799
2008-03-31 20:07:02 +00:00
Aleksey Bragin 379a429aa9 - Remove autoupdated "$Id:" lines from the kernel source code.
svn path=/trunk/; revision=32623
2008-03-09 14:11:42 +00:00
Aleksey Bragin fffed3ea73 - SeSet/QuerySecurityAccessMask() should initialize DesiredAccess to 0 (inspired by 30154).
svn path=/trunk/; revision=30170
2007-11-05 12:58:03 +00:00
Art Yerkes 4c33a58449 Mask values that control inheritability of the handle, and don't affect access.
svn path=/trunk/; revision=28973
2007-09-09 12:21:22 +00:00
Hervé Poussineau 478a0d960b ReactOS now supports ACLs... (fix SeAccessCheck to sometimes deny access)
svn path=/trunk/; revision=27409
2007-07-05 17:01:02 +00:00
Hervé Poussineau 55f2798900 Replace tabs by spaces. No code change
svn path=/trunk/; revision=27366
2007-07-02 22:39:11 +00:00
Alex Ionescu 71e781df12 - Fix NPX check in context switcher.
- Fix ObLogSecurityDescriptor.
- Fix some missing features in SeAccessCheck.

svn path=/trunk/; revision=26140
2007-03-19 19:05:39 +00:00
Hervé Poussineau b0385e2a41 Fix SeAccessCheck to perform correct checks.
When returning STATUS_ACCESS_DENIED when required (currently disabled), ReactOS boots up to login screen on 3rd boot.
Now, we just need to fix callers.

svn path=/trunk/; revision=26130
2007-03-18 12:47:27 +00:00
Alex Ionescu bdc7f65b2d - Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use.
- Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before.
- Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2.
- Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization.
- Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot.
- Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration.
- Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it.
- Optimize calling and usage of ExpLoadInitialProcess.
- Add support for Y2K bug fix documented for Windows NT (/YEAR).
- Add support to detect WinPE/MiniNT/ReactOS Live CD.
- Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs.
- Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc.
- Disable calls to ObfDereferenceDeviceMap since it's not yet implemented.

svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00