ReactOS
0.4.15-dev-5608-gafb953a
|
#include <ntoskrnl.h>
#include <debug.h>
Go to the source code of this file.
Macros | |
#define | NDEBUG |
Functions | |
PACCESS_CHECK_RIGHTS | SepInitAccessCheckRights (VOID) |
Allocates memory for the internal access check rights data structure and initializes it for use for the kernel. The purpose of this piece of data is to track down the remaining, granted and denied access rights whilst we are doing an access check procedure. More... | |
VOID | SepFreeAccessCheckRights (_In_ PACCESS_CHECK_RIGHTS AccessRights) |
Frees an allocated access check rights from memory space after access check procedures have finished. More... | |
PACCESS_CHECK_RIGHTS | SepAnalyzeAcesFromDacl (_In_ ACCESS_CHECK_RIGHT_TYPE ActionType, _In_ PACL Dacl, _In_ PACCESS_TOKEN AccessToken, _In_ PACCESS_TOKEN PrimaryAccessToken, _In_ BOOLEAN IsTokenRestricted, _In_ BOOLEAN AccessRightsAllocated, _In_opt_ PSID PrincipalSelfSid, _In_ PGENERIC_MAPPING GenericMapping, _In_opt_ POBJECT_TYPE_LIST ObjectTypeList, _In_ ULONG ObjectTypeListLength, _In_ ACCESS_MASK RemainingAccess) |
Analyzes an access control entry that is present in a discretionary access control list (DACL) for access right masks of each entry with the purpose to judge whether the calling thread can be warranted access check to a certain object or not. More... | |
BOOLEAN NTAPI | SepAccessCheck (_In_ PSECURITY_DESCRIPTOR SecurityDescriptor, _In_opt_ PACCESS_TOKEN ClientAccessToken, _In_ PACCESS_TOKEN PrimaryAccessToken, _In_opt_ PSID PrincipalSelfSid, _In_ ACCESS_MASK DesiredAccess, _In_opt_ POBJECT_TYPE_LIST ObjectTypeList, _In_ ULONG ObjectTypeListLength, _In_ ACCESS_MASK PreviouslyGrantedAccess, _In_ PGENERIC_MAPPING GenericMapping, _In_ KPROCESSOR_MODE AccessMode, _In_ BOOLEAN UseResultList, _Out_opt_ PPRIVILEGE_SET *Privileges, _Out_ PACCESS_MASK GrantedAccessList, _Out_ PNTSTATUS AccessStatusList) |
Private function that determines whether security access rights can be given to the calling thread in order to access an object depending on the security descriptor and other security context entities, such as an owner. This function is the heart and brain of the whole access check algorithm in the kernel. More... | |
static PSID | SepGetSDOwner (_In_ PSECURITY_DESCRIPTOR _SecurityDescriptor) |
Retrieves the main user from a security descriptor. More... | |
static PSID | SepGetSDGroup (_In_ PSECURITY_DESCRIPTOR _SecurityDescriptor) |
Retrieves the group from a security descriptor. More... | |
static ULONG | SepGetPrivilegeSetLength (_In_ PPRIVILEGE_SET PrivilegeSet) |
Retrieves the length size of a set list of privileges structure. More... | |
BOOLEAN NTAPI | SeAccessCheck (_In_ PSECURITY_DESCRIPTOR SecurityDescriptor, _In_ PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext, _In_ BOOLEAN SubjectContextLocked, _In_ ACCESS_MASK DesiredAccess, _In_ ACCESS_MASK PreviouslyGrantedAccess, _Out_ PPRIVILEGE_SET *Privileges, _In_ PGENERIC_MAPPING GenericMapping, _In_ KPROCESSOR_MODE AccessMode, _Out_ PACCESS_MASK GrantedAccess, _Out_ PNTSTATUS AccessStatus) |
Determines whether security access rights can be given to an object depending on the security descriptor and other security context entities, such as an owner. More... | |
BOOLEAN NTAPI | SeFastTraverseCheck (_In_ PSECURITY_DESCRIPTOR SecurityDescriptor, _In_ PACCESS_STATE AccessState, _In_ ACCESS_MASK DesiredAccess, _In_ KPROCESSOR_MODE AccessMode) |
Determines whether security access rights can be given to an object depending on the security descriptor. Unlike the regular access check procedure in the NT kernel, the fast traverse check is a faster way to quickly check if access can be made into an object. More... | |
NTSTATUS NTAPI | NtAccessCheck (_In_ PSECURITY_DESCRIPTOR SecurityDescriptor, _In_ HANDLE TokenHandle, _In_ ACCESS_MASK DesiredAccess, _In_ PGENERIC_MAPPING GenericMapping, _Out_opt_ PPRIVILEGE_SET PrivilegeSet, _Inout_ PULONG PrivilegeSetLength, _Out_ PACCESS_MASK GrantedAccess, _Out_ PNTSTATUS AccessStatus) |
Determines whether security access rights can be given to an object depending on the security descriptor and a valid handle to an access token. More... | |
NTSTATUS NTAPI | NtAccessCheckByType (_In_ PSECURITY_DESCRIPTOR SecurityDescriptor, _In_ PSID PrincipalSelfSid, _In_ HANDLE ClientToken, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_TYPE_LIST ObjectTypeList, _In_ ULONG ObjectTypeLength, _In_ PGENERIC_MAPPING GenericMapping, _In_ PPRIVILEGE_SET PrivilegeSet, _Inout_ PULONG PrivilegeSetLength, _Out_ PACCESS_MASK GrantedAccess, _Out_ PNTSTATUS AccessStatus) |
Determines whether security access could be granted or not on an object by the requestor who wants such access through type. More... | |
NTSTATUS NTAPI | NtAccessCheckByTypeResultList (_In_ PSECURITY_DESCRIPTOR SecurityDescriptor, _In_ PSID PrincipalSelfSid, _In_ HANDLE ClientToken, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_TYPE_LIST ObjectTypeList, _In_ ULONG ObjectTypeLength, _In_ PGENERIC_MAPPING GenericMapping, _In_ PPRIVILEGE_SET PrivilegeSet, _Inout_ PULONG PrivilegeSetLength, _Out_ PACCESS_MASK GrantedAccess, _Out_ PNTSTATUS AccessStatus) |
Determines whether security access could be granted or not on an object by the requestor who wants such access through type list. More... | |
#define NDEBUG |
Definition at line 13 of file accesschk.c.
NTSTATUS NTAPI NtAccessCheck | ( | _In_ PSECURITY_DESCRIPTOR | SecurityDescriptor, |
_In_ HANDLE | TokenHandle, | ||
_In_ ACCESS_MASK | DesiredAccess, | ||
_In_ PGENERIC_MAPPING | GenericMapping, | ||
_Out_opt_ PPRIVILEGE_SET | PrivilegeSet, | ||
_Inout_ PULONG | PrivilegeSetLength, | ||
_Out_ PACCESS_MASK | GrantedAccess, | ||
_Out_ PNTSTATUS | AccessStatus | ||
) |
Determines whether security access rights can be given to an object depending on the security descriptor and a valid handle to an access token.
[in] | SecurityDescriptor | Security descriptor of the object that is being accessed. |
[in] | TokenHandle | A handle to a token. |
[in] | DesiredAccess | The access right bitmask where the calling thread wants to acquire. |
[in] | GenericMapping | The generic mapping of access rights of an object type. |
[out] | PrivilegeSet | The returned set of privileges. |
[in,out] | PrivilegeSetLength | The total length size of a set of privileges. |
[out] | GrantedAccess | A list of granted access rights. |
[out] | AccessStatus | The returned status code specifying why access cannot be made onto an object (if said access is denied in the first place). |
Definition at line 1164 of file accesschk.c.
Referenced by AccessCheck(), and CheckTokenMembership().
NTSTATUS NTAPI NtAccessCheckByType | ( | _In_ PSECURITY_DESCRIPTOR | SecurityDescriptor, |
_In_ PSID | PrincipalSelfSid, | ||
_In_ HANDLE | ClientToken, | ||
_In_ ACCESS_MASK | DesiredAccess, | ||
_In_ POBJECT_TYPE_LIST | ObjectTypeList, | ||
_In_ ULONG | ObjectTypeLength, | ||
_In_ PGENERIC_MAPPING | GenericMapping, | ||
_In_ PPRIVILEGE_SET | PrivilegeSet, | ||
_Inout_ PULONG | PrivilegeSetLength, | ||
_Out_ PACCESS_MASK | GrantedAccess, | ||
_Out_ PNTSTATUS | AccessStatus | ||
) |
Determines whether security access could be granted or not on an object by the requestor who wants such access through type.
[in] | SecurityDescriptor | A security descriptor with information data for auditing. |
[in] | PrincipalSelfSid | A principal self user SID. |
[in] | ClientToken | A client access token. |
[in] | DesiredAccess | The desired access masks rights requested by the caller. |
[in] | ObjectTypeList | A list of object types. |
[in] | ObjectTypeLength | The length size of the list. |
[in] | GenericMapping | The generic mapping list of access masks rights. |
[in] | PrivilegeSet | An array set of privileges. |
[in,out] | PrivilegeSetLength | The length size of the array set of privileges. |
[out] | GrantedAccess | The returned granted access rights. |
[out] | AccessStatus | The returned NTSTATUS code indicating the final results of auditing. |
Definition at line 1454 of file accesschk.c.
NTSTATUS NTAPI NtAccessCheckByTypeResultList | ( | _In_ PSECURITY_DESCRIPTOR | SecurityDescriptor, |
_In_ PSID | PrincipalSelfSid, | ||
_In_ HANDLE | ClientToken, | ||
_In_ ACCESS_MASK | DesiredAccess, | ||
_In_ POBJECT_TYPE_LIST | ObjectTypeList, | ||
_In_ ULONG | ObjectTypeLength, | ||
_In_ PGENERIC_MAPPING | GenericMapping, | ||
_In_ PPRIVILEGE_SET | PrivilegeSet, | ||
_Inout_ PULONG | PrivilegeSetLength, | ||
_Out_ PACCESS_MASK | GrantedAccess, | ||
_Out_ PNTSTATUS | AccessStatus | ||
) |
Determines whether security access could be granted or not on an object by the requestor who wants such access through type list.
[in] | SecurityDescriptor | A security descriptor with information data for auditing. |
[in] | PrincipalSelfSid | A principal self user SID. |
[in] | ClientToken | A client access token. |
[in] | DesiredAccess | The desired access masks rights requested by the caller. |
[in] | ObjectTypeList | A list of object types. |
[in] | ObjectTypeLength | The length size of the list. |
[in] | GenericMapping | The generic mapping list of access masks rights. |
[in] | PrivilegeSet | An array set of privileges. |
[in,out] | PrivilegeSetLength | The length size of the array set of privileges. |
[out] | GrantedAccess | The returned granted access rights. |
[out] | AccessStatus | The returned NTSTATUS code indicating the final results of auditing. |
Definition at line 1516 of file accesschk.c.
BOOLEAN NTAPI SeAccessCheck | ( | _In_ PSECURITY_DESCRIPTOR | SecurityDescriptor, |
_In_ PSECURITY_SUBJECT_CONTEXT | SubjectSecurityContext, | ||
_In_ BOOLEAN | SubjectContextLocked, | ||
_In_ ACCESS_MASK | DesiredAccess, | ||
_In_ ACCESS_MASK | PreviouslyGrantedAccess, | ||
_Out_ PPRIVILEGE_SET * | Privileges, | ||
_In_ PGENERIC_MAPPING | GenericMapping, | ||
_In_ KPROCESSOR_MODE | AccessMode, | ||
_Out_ PACCESS_MASK | GrantedAccess, | ||
_Out_ PNTSTATUS | AccessStatus | ||
) |
Determines whether security access rights can be given to an object depending on the security descriptor and other security context entities, such as an owner.
[in] | SecurityDescriptor | Security descriptor of the object that is being accessed. |
[in] | SubjectSecurityContext | The captured subject security context. |
[in] | SubjectContextLocked | If set to TRUE, the caller acknowledges that the subject context has already been locked by the caller himself. If set to FALSE, the function locks the subject context. |
[in] | DesiredAccess | Access right bitmask that the calling thread wants to acquire. |
[in] | PreviouslyGrantedAccess | The access rights previously acquired in the past. |
[out] | Privileges | The returned set of privileges. |
[in] | GenericMapping | The generic mapping of access rights of an object type. |
[in] | AccessMode | The processor request level mode. |
[out] | GrantedAccess | A list of granted access rights. |
[out] | AccessStatus | The returned status code specifying why access cannot be made onto an object (if said access is denied in the first place). |
Definition at line 910 of file accesschk.c.
Referenced by create_stream(), FatExplicitDeviceAccessGranted(), file_create(), IopParseDevice(), NpCreateClientEnd(), NpCreateExistingNamedPipe(), ObCheckCreateObjectAccess(), ObCheckObjectAccess(), ObpCheckObjectReference(), ObpCheckTraverseAccess(), open_file2(), PspCreateProcess(), PspCreateThread(), PspSetPrimaryToken(), set_link_information(), set_rename_information(), START_TEST(), and UDFCheckAccessRights().
BOOLEAN NTAPI SeFastTraverseCheck | ( | _In_ PSECURITY_DESCRIPTOR | SecurityDescriptor, |
_In_ PACCESS_STATE | AccessState, | ||
_In_ ACCESS_MASK | DesiredAccess, | ||
_In_ KPROCESSOR_MODE | AccessMode | ||
) |
Determines whether security access rights can be given to an object depending on the security descriptor. Unlike the regular access check procedure in the NT kernel, the fast traverse check is a faster way to quickly check if access can be made into an object.
[in] | SecurityDescriptor | Security descriptor of the object that is being accessed. |
[in] | AccessState | An access state to determine if the access token in the current security context of the object is an restricted token. |
[in] | DesiredAccess | The access right bitmask where the calling thread wants to acquire. |
[in] | AccessMode | Process level request mode. |
Definition at line 1054 of file accesschk.c.
Referenced by IopParseDevice(), and ObpCheckTraverseAccess().
BOOLEAN NTAPI SepAccessCheck | ( | _In_ PSECURITY_DESCRIPTOR | SecurityDescriptor, |
_In_opt_ PACCESS_TOKEN | ClientAccessToken, | ||
_In_ PACCESS_TOKEN | PrimaryAccessToken, | ||
_In_opt_ PSID | PrincipalSelfSid, | ||
_In_ ACCESS_MASK | DesiredAccess, | ||
_In_opt_ POBJECT_TYPE_LIST | ObjectTypeList, | ||
_In_ ULONG | ObjectTypeListLength, | ||
_In_ ACCESS_MASK | PreviouslyGrantedAccess, | ||
_In_ PGENERIC_MAPPING | GenericMapping, | ||
_In_ KPROCESSOR_MODE | AccessMode, | ||
_In_ BOOLEAN | UseResultList, | ||
_Out_opt_ PPRIVILEGE_SET * | Privileges, | ||
_Out_ PACCESS_MASK | GrantedAccessList, | ||
_Out_ PNTSTATUS | AccessStatusList | ||
) |
Private function that determines whether security access rights can be given to the calling thread in order to access an object depending on the security descriptor and other security context entities, such as an owner. This function is the heart and brain of the whole access check algorithm in the kernel.
[in] | ClientAccessToken | A pointer to a client (thread) access token that requests access rights of an object or subset of multiple objects. |
[in] | PrimaryAccessToken | A pointer to a primary access token that describes the primary security context of the main calling process. |
[in] | PrincipalSelfSid | A pointer to a security identifier that represents a security principal, that is, a user object associated with its security descriptor. |
[in] | DesiredAccess | The access rights desired by the calling thread to acquire in order to access an object. |
[in] | ObjectTypeList | An array list of object types to be checked against for access. The function will act accordingly in this case by checking each sub-object of an object of primary level and such. If this parameter is NULL, the function will perform a normal access check against the target object itself. |
[in] | ObjectTypeListLength | The length of a object type list. Such length represents the number of elements in this list. |
[in] | PreviouslyGrantedAccess | The access rights previously acquired in the past. If this parameter is 0, it is deemed that the calling thread hasn't acquired any rights. Access checks are more tighten in this case. |
[in] | GenericMapping | A pointer to a generic mapping of access rights of the target object. |
[in] | AccessMode | The processor request level mode. |
[in] | UseResultList | If set to TRUE, the function will return a list of granted access rights of each sub-object as well as status code for each. If this parameter is set to FALSE, then the function will just return only the granted access rights and status code for single object that's been target for access checks. |
[out] | Privileges | A pointer to a definite set of privileges that have been audited whilst doing access check procedures. Such set of privileges are optionally returned to the caller. This can be set to NULL if the caller doesn't want to obtain a set of privileges. |
[out] | GrantedAccessList | A list of granted access rights returned to the caller. This list can comprehend multiple elements which represent the sub-objects that have been checked or a single element which is the target object itself. |
[out] | AccessStatusList | A list of access status codes returned to the caller. This list can comprehend multiple elements which represent the sub-objects that have been checked or a single element which is the target object itself. |
Definition at line 465 of file accesschk.c.
Referenced by NtAccessCheck(), and SeAccessCheck().
PACCESS_CHECK_RIGHTS SepAnalyzeAcesFromDacl | ( | _In_ ACCESS_CHECK_RIGHT_TYPE | ActionType, |
_In_ PACL | Dacl, | ||
_In_ PACCESS_TOKEN | AccessToken, | ||
_In_ PACCESS_TOKEN | PrimaryAccessToken, | ||
_In_ BOOLEAN | IsTokenRestricted, | ||
_In_ BOOLEAN | AccessRightsAllocated, | ||
_In_opt_ PSID | PrincipalSelfSid, | ||
_In_ PGENERIC_MAPPING | GenericMapping, | ||
_In_opt_ POBJECT_TYPE_LIST | ObjectTypeList, | ||
_In_ ULONG | ObjectTypeListLength, | ||
_In_ ACCESS_MASK | RemainingAccess | ||
) |
Analyzes an access control entry that is present in a discretionary access control list (DACL) for access right masks of each entry with the purpose to judge whether the calling thread can be warranted access check to a certain object or not.
[in] | ActionType | The type of analysis to be done against an access entry. This type influences how access rights are gathered. This can either be AccessCheckMaximum which means the algorithm will perform analysis against ACEs on behalf of the requestor that gave us the acknowledgement that he desires MAXIMUM_ALLOWED access right or AccessCheckRegular if the requestor wants a subset of access rights. |
[in] | Dacl | The discretionary access control list to be given to this function. This DACL must have at least one ACE currently present in the list. |
[in] | AccessToken | A pointer to an access token, where an equality comparison check is performed if the security identifier (SID) from a ACE of a certain object is present in this token. This token represents the effective (calling thread) token of the caller. |
[in] | PrimaryAccessToken | A pointer to an access token, represented as an access token associated with the primary calling process. This token describes the primary security context of the main process. |
[in] | IsTokenRestricted | If this parameter is set to TRUE, the function considers the token pointed by AccessToken parameter argument as restricted. That is, the token has restricted SIDs therefore the function will act accordingly against that token by checking for restricted SIDs only when doing an equaility comparison check between the two identifiers. |
[in] | AccessRightsAllocated | If this parameter is set to TRUE, the function will not allocate the access check rights again. This is typical when we have to do additional analysis of ACEs because a token has restricted SIDs (see IsTokenRestricted parameter) of which we already initialized the access check rights pointer before. |
[in] | PrincipalSelfSid | A pointer to a security identifier that represents a principal. A principal identifies a user object which is associated with its own security descriptor. |
[in] | GenericMapping | A pointer to a generic mapping that is associated with the object in question being checked for access. If certain set of desired access rights have a generic access right, this parameter is needed to map generic rights. |
[in] | ObjectTypeList | A pointer to a list array of object types. If such array is provided to the function, the algorithm will perform a different approach by doing analysis against ACEs each sub-object of an object of primary level (level 0) or sub-objects of a sub-object of an object. If this parameter is NULL, the function will normally analyze the ACEs of a DACL of the target object itself. |
[in] | ObjectTypeListLength | The length of the object type list array, pointed by ObjectTypeList. This length in question represents the number of elements in such array. This parameter must be 0 if no array list is provided. |
[in] | RemainingAccess | The remaining access rights that have yet to be granted to the calling thread whomst requests access to a certain object. This parameter mustn't be 0 as the remaining rights are left to be addressed. This is the case if we have to address the remaining rights on a regular subset basis (the requestor didn't ask for MAXIMUM_ALLOWED). Otherwise this parameter can be 0. |
Otherwise NULL is returned and thus access check procedure can't any longer continue further. We have prematurely failed this access check operation at this point.
Definition at line 161 of file accesschk.c.
Referenced by SepAccessCheck().
VOID SepFreeAccessCheckRights | ( | _In_ PACCESS_CHECK_RIGHTS | AccessRights | ) |
Frees an allocated access check rights from memory space after access check procedures have finished.
[in] | AccessRights | A pointer to access check rights of which is to be freed from memory. |
Definition at line 70 of file accesschk.c.
Referenced by SepAccessCheck().
|
static |
Retrieves the length size of a set list of privileges structure.
[in] | PrivilegeSet | A valid set of privileges. |
Definition at line 850 of file accesschk.c.
Referenced by NtAccessCheck().
|
static |
Retrieves the group from a security descriptor.
[in] | SecurityDescriptor | A valid allocated security descriptor structure where the group is to be retrieved. |
Definition at line 823 of file accesschk.c.
Referenced by NtAccessCheck().
|
static |
Retrieves the main user from a security descriptor.
[in] | SecurityDescriptor | A valid allocated security descriptor structure where the owner is to be retrieved. |
Definition at line 796 of file accesschk.c.
Referenced by NtAccessCheck().
PACCESS_CHECK_RIGHTS SepInitAccessCheckRights | ( | VOID | ) |
Allocates memory for the internal access check rights data structure and initializes it for use for the kernel. The purpose of this piece of data is to track down the remaining, granted and denied access rights whilst we are doing an access check procedure.
Definition at line 31 of file accesschk.c.
Referenced by SepAnalyzeAcesFromDacl().