mirror of
https://github.com/reactos/reactos.git
synced 2025-06-20 07:36:05 +00:00
- Fix OB_SECURITY_METHOD prototype, callers, and implementors.
- Add call to SeOpenObjectAuditAlarm in ObCheckObjectAccess. - Start adding Ob Callout validation on checked builds. For now only done around security functions. - Set *MemoryAllocated to FALSE in ObGetObjectSecurity early on to avoid inconcistent state if the callback failed. - Implement new XP function ObSetSecurityObjectByPointer and simplify NtSetSecurityObject by making it use it. - More Win 2003 SecurityDescriptor Cache functions to sdcache instead of obsecure.c. svn path=/trunk/; revision=25240
This commit is contained in:
parent
635dda87ec
commit
8f2eb74d99
12 changed files with 279 additions and 164 deletions
|
@ -215,7 +215,7 @@ typedef NTSTATUS
|
||||||
(NTAPI *OB_SECURITY_METHOD)(
|
(NTAPI *OB_SECURITY_METHOD)(
|
||||||
IN PVOID Object,
|
IN PVOID Object,
|
||||||
IN SECURITY_OPERATION_CODE OperationType,
|
IN SECURITY_OPERATION_CODE OperationType,
|
||||||
IN SECURITY_INFORMATION SecurityInformation, // FIXME: <= should be a pointer
|
IN PSECURITY_INFORMATION SecurityInformation,
|
||||||
IN PSECURITY_DESCRIPTOR SecurityDescriptor,
|
IN PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
IN OUT PULONG CapturedLength,
|
IN OUT PULONG CapturedLength,
|
||||||
IN OUT PSECURITY_DESCRIPTOR *ObjectSecurityDescriptor,
|
IN OUT PSECURITY_DESCRIPTOR *ObjectSecurityDescriptor,
|
||||||
|
|
|
@ -165,7 +165,7 @@ CmiObjectDelete(PVOID DeletedObject);
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
CmiObjectSecurity(PVOID ObjectBody,
|
CmiObjectSecurity(PVOID ObjectBody,
|
||||||
SECURITY_OPERATION_CODE OperationCode,
|
SECURITY_OPERATION_CODE OperationCode,
|
||||||
SECURITY_INFORMATION SecurityInformation,
|
PSECURITY_INFORMATION SecurityInformation,
|
||||||
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
PULONG BufferLength,
|
PULONG BufferLength,
|
||||||
PSECURITY_DESCRIPTOR *OldSecurityDescriptor,
|
PSECURITY_DESCRIPTOR *OldSecurityDescriptor,
|
||||||
|
|
|
@ -669,7 +669,7 @@ CmiAssignSecurityDescriptor(PKEY_OBJECT KeyObject,
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
CmiObjectSecurity(PVOID ObjectBody,
|
CmiObjectSecurity(PVOID ObjectBody,
|
||||||
SECURITY_OPERATION_CODE OperationCode,
|
SECURITY_OPERATION_CODE OperationCode,
|
||||||
SECURITY_INFORMATION SecurityInformation,
|
PSECURITY_INFORMATION SecurityInformation,
|
||||||
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
PULONG BufferLength,
|
PULONG BufferLength,
|
||||||
PSECURITY_DESCRIPTOR *OldSecurityDescriptor,
|
PSECURITY_DESCRIPTOR *OldSecurityDescriptor,
|
||||||
|
@ -687,7 +687,7 @@ CmiObjectSecurity(PVOID ObjectBody,
|
||||||
case QuerySecurityDescriptor:
|
case QuerySecurityDescriptor:
|
||||||
DPRINT("Query security descriptor\n");
|
DPRINT("Query security descriptor\n");
|
||||||
return CmiQuerySecurityDescriptor((PKEY_OBJECT)ObjectBody,
|
return CmiQuerySecurityDescriptor((PKEY_OBJECT)ObjectBody,
|
||||||
SecurityInformation,
|
*SecurityInformation,
|
||||||
SecurityDescriptor,
|
SecurityDescriptor,
|
||||||
BufferLength);
|
BufferLength);
|
||||||
|
|
||||||
|
|
|
@ -898,7 +898,7 @@ NTAPI
|
||||||
IopSecurityFile(
|
IopSecurityFile(
|
||||||
IN PVOID ObjectBody,
|
IN PVOID ObjectBody,
|
||||||
IN SECURITY_OPERATION_CODE OperationCode,
|
IN SECURITY_OPERATION_CODE OperationCode,
|
||||||
IN SECURITY_INFORMATION SecurityInformation,
|
IN PSECURITY_INFORMATION SecurityInformation,
|
||||||
IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
|
IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
IN OUT PULONG BufferLength,
|
IN OUT PULONG BufferLength,
|
||||||
OUT PSECURITY_DESCRIPTOR *OldSecurityDescriptor,
|
OUT PSECURITY_DESCRIPTOR *OldSecurityDescriptor,
|
||||||
|
|
|
@ -6,6 +6,53 @@
|
||||||
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if DBG
|
||||||
|
VOID
|
||||||
|
FORCEINLINE
|
||||||
|
ObpCalloutStart(IN PKIRQL CalloutIrql)
|
||||||
|
{
|
||||||
|
/* Save the callout IRQL */
|
||||||
|
*CalloutIrql = KeGetCurrentIrql();
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
FORCEINLINE
|
||||||
|
ObpCalloutEnd(IN KIRQL CalloutIrql,
|
||||||
|
IN PCHAR Procedure,
|
||||||
|
IN POBJECT_TYPE ObjectType,
|
||||||
|
IN PVOID Object)
|
||||||
|
{
|
||||||
|
/* Detect IRQL change */
|
||||||
|
if (CalloutIrql != KeGetCurrentIrql())
|
||||||
|
{
|
||||||
|
/* Print error */
|
||||||
|
DbgPrint("OB: ObjectType: %wZ Procedure: %s Object: %08x\n",
|
||||||
|
&ObjectType->Name, Procedure, Object);
|
||||||
|
DbgPrint(" Returned at %x IRQL, but was called at %x IRQL\n",
|
||||||
|
KeGetCurrentIrql(), CalloutIrql);
|
||||||
|
DbgBreakPoint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
VOID
|
||||||
|
FORCEINLINE
|
||||||
|
ObpCalloutStart(IN PKIRQL CalloutIrql)
|
||||||
|
{
|
||||||
|
/* No-op */
|
||||||
|
UNREFERENCED_PARAMETER(CalloutIrql);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
FORCEINLINE
|
||||||
|
ObpCalloutEnd(IN KIRQL CalloutIrql,
|
||||||
|
IN PCHAR Procedure,
|
||||||
|
IN POBJECT_TYPE ObjectType,
|
||||||
|
IN PVOID Object)
|
||||||
|
{
|
||||||
|
UNREFERENCED_PARAMETER(CalloutIrql);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
FORCEINLINE
|
FORCEINLINE
|
||||||
ObpEnterObjectTypeMutex(IN POBJECT_TYPE ObjectType)
|
ObpEnterObjectTypeMutex(IN POBJECT_TYPE ObjectType)
|
||||||
|
|
|
@ -299,7 +299,7 @@ NTAPI
|
||||||
SeDefaultObjectMethod(
|
SeDefaultObjectMethod(
|
||||||
PVOID Object,
|
PVOID Object,
|
||||||
SECURITY_OPERATION_CODE OperationType,
|
SECURITY_OPERATION_CODE OperationType,
|
||||||
SECURITY_INFORMATION SecurityInformation,
|
PSECURITY_INFORMATION SecurityInformation,
|
||||||
PSECURITY_DESCRIPTOR NewSecurityDescriptor,
|
PSECURITY_DESCRIPTOR NewSecurityDescriptor,
|
||||||
PULONG ReturnLength,
|
PULONG ReturnLength,
|
||||||
PSECURITY_DESCRIPTOR *OldSecurityDescriptor,
|
PSECURITY_DESCRIPTOR *OldSecurityDescriptor,
|
||||||
|
|
|
@ -162,5 +162,6 @@
|
||||||
#define TAG_SEPA TAG('S', 'e', 'P', 'a')
|
#define TAG_SEPA TAG('S', 'e', 'P', 'a')
|
||||||
|
|
||||||
#define TAG_WAIT TAG('W', 'a', 'i', 't')
|
#define TAG_WAIT TAG('W', 'a', 'i', 't')
|
||||||
|
#define TAG_SEC_QUERY TAG('O', 'b', 'S', 'q')
|
||||||
|
|
||||||
#endif /* _NTOSKRNL_TAG_H */
|
#endif /* _NTOSKRNL_TAG_H */
|
||||||
|
|
|
@ -1055,7 +1055,7 @@ NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IopSecurityFile(IN PVOID ObjectBody,
|
IopSecurityFile(IN PVOID ObjectBody,
|
||||||
IN SECURITY_OPERATION_CODE OperationCode,
|
IN SECURITY_OPERATION_CODE OperationCode,
|
||||||
IN SECURITY_INFORMATION SecurityInformation,
|
IN PSECURITY_INFORMATION SecurityInformation,
|
||||||
IN PSECURITY_DESCRIPTOR SecurityDescriptor,
|
IN PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
IN OUT PULONG BufferLength,
|
IN OUT PULONG BufferLength,
|
||||||
IN OUT PSECURITY_DESCRIPTOR *OldSecurityDescriptor,
|
IN OUT PSECURITY_DESCRIPTOR *OldSecurityDescriptor,
|
||||||
|
@ -1183,7 +1183,7 @@ IopSecurityFile(IN PVOID ObjectBody,
|
||||||
/* Set the major function and parameters */
|
/* Set the major function and parameters */
|
||||||
StackPtr->MajorFunction = IRP_MJ_QUERY_SECURITY;
|
StackPtr->MajorFunction = IRP_MJ_QUERY_SECURITY;
|
||||||
StackPtr->Parameters.QuerySecurity.SecurityInformation =
|
StackPtr->Parameters.QuerySecurity.SecurityInformation =
|
||||||
SecurityInformation;
|
*SecurityInformation;
|
||||||
StackPtr->Parameters.QuerySecurity.Length = *BufferLength;
|
StackPtr->Parameters.QuerySecurity.Length = *BufferLength;
|
||||||
Irp->UserBuffer = SecurityDescriptor;
|
Irp->UserBuffer = SecurityDescriptor;
|
||||||
}
|
}
|
||||||
|
@ -1192,7 +1192,7 @@ IopSecurityFile(IN PVOID ObjectBody,
|
||||||
/* Set the major function and parameters for a set */
|
/* Set the major function and parameters for a set */
|
||||||
StackPtr->MajorFunction = IRP_MJ_SET_SECURITY;
|
StackPtr->MajorFunction = IRP_MJ_SET_SECURITY;
|
||||||
StackPtr->Parameters.SetSecurity.SecurityInformation =
|
StackPtr->Parameters.SetSecurity.SecurityInformation =
|
||||||
SecurityInformation;
|
*SecurityInformation;
|
||||||
StackPtr->Parameters.SetSecurity.SecurityDescriptor =
|
StackPtr->Parameters.SetSecurity.SecurityDescriptor =
|
||||||
SecurityDescriptor;
|
SecurityDescriptor;
|
||||||
}
|
}
|
||||||
|
@ -1246,7 +1246,7 @@ IopSecurityFile(IN PVOID ObjectBody,
|
||||||
if (OperationCode == QuerySecurityDescriptor)
|
if (OperationCode == QuerySecurityDescriptor)
|
||||||
{
|
{
|
||||||
/* Set a World Security Descriptor */
|
/* Set a World Security Descriptor */
|
||||||
Status = SeSetWorldSecurityDescriptor(SecurityInformation,
|
Status = SeSetWorldSecurityDescriptor(*SecurityInformation,
|
||||||
SecurityDescriptor,
|
SecurityDescriptor,
|
||||||
BufferLength);
|
BufferLength);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,6 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
#define TAG_SEC_QUERY TAG('O', 'b', 'S', 'q')
|
|
||||||
|
|
||||||
/* PRIVATE FUNCTIONS *********************************************************/
|
/* PRIVATE FUNCTIONS *********************************************************/
|
||||||
|
|
||||||
/*++
|
/*++
|
||||||
|
@ -109,6 +107,17 @@ ObCheckObjectAccess(IN PVOID Object,
|
||||||
AccessState->PreviouslyGrantedAccess |= GrantedAccess;
|
AccessState->PreviouslyGrantedAccess |= GrantedAccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Do audit alarm */
|
||||||
|
SeOpenObjectAuditAlarm(&ObjectType->Name,
|
||||||
|
Object,
|
||||||
|
NULL,
|
||||||
|
SecurityDescriptor,
|
||||||
|
AccessState,
|
||||||
|
FALSE,
|
||||||
|
Result,
|
||||||
|
AccessMode,
|
||||||
|
&AccessState->GenerateOnClose);
|
||||||
|
|
||||||
/* We're done, unlock the context and release security */
|
/* We're done, unlock the context and release security */
|
||||||
SeUnlockSubjectContext(&AccessState->SubjectSecurityContext);
|
SeUnlockSubjectContext(&AccessState->SubjectSecurityContext);
|
||||||
ObReleaseObjectSecurity(SecurityDescriptor, SdAllocated);
|
ObReleaseObjectSecurity(SecurityDescriptor, SdAllocated);
|
||||||
|
@ -149,6 +158,7 @@ ObAssignSecurity(IN PACCESS_STATE AccessState,
|
||||||
{
|
{
|
||||||
PSECURITY_DESCRIPTOR NewDescriptor;
|
PSECURITY_DESCRIPTOR NewDescriptor;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
KIRQL CalloutIrql;
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
|
||||||
/* Build the new security descriptor */
|
/* Build the new security descriptor */
|
||||||
|
@ -162,19 +172,19 @@ ObAssignSecurity(IN PACCESS_STATE AccessState,
|
||||||
if (!NT_SUCCESS(Status)) return Status;
|
if (!NT_SUCCESS(Status)) return Status;
|
||||||
|
|
||||||
/* Call the security method */
|
/* Call the security method */
|
||||||
|
ObpCalloutStart(&CalloutIrql);
|
||||||
Status = Type->TypeInfo.SecurityProcedure(Object,
|
Status = Type->TypeInfo.SecurityProcedure(Object,
|
||||||
AssignSecurityDescriptor,
|
AssignSecurityDescriptor,
|
||||||
0,
|
NULL,
|
||||||
NewDescriptor,
|
NewDescriptor,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
PagedPool,
|
PagedPool,
|
||||||
&Type->TypeInfo.GenericMapping);
|
&Type->TypeInfo.GenericMapping);
|
||||||
if (!NT_SUCCESS(Status))
|
ObpCalloutEnd(CalloutIrql, "Security", Type, Object);
|
||||||
{
|
|
||||||
/* Release the new security descriptor */
|
/* Check for failure and deassign security if so */
|
||||||
SeDeassignSecurity(&NewDescriptor);
|
if (!NT_SUCCESS(Status)) SeDeassignSecurity(&NewDescriptor);
|
||||||
}
|
|
||||||
|
|
||||||
/* Return to caller */
|
/* Return to caller */
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -208,39 +218,47 @@ ObGetObjectSecurity(IN PVOID Object,
|
||||||
{
|
{
|
||||||
POBJECT_HEADER Header;
|
POBJECT_HEADER Header;
|
||||||
POBJECT_TYPE Type;
|
POBJECT_TYPE Type;
|
||||||
ULONG Length;
|
ULONG Length = 0;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
SECURITY_INFORMATION SecurityInformation;
|
||||||
|
KIRQL CalloutIrql;
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
|
||||||
/* Get the object header and type */
|
/* Get the object header and type */
|
||||||
Header = OBJECT_TO_OBJECT_HEADER(Object);
|
Header = OBJECT_TO_OBJECT_HEADER(Object);
|
||||||
Type = Header->Type;
|
Type = Header->Type;
|
||||||
|
|
||||||
|
/* Tell the caller that we didn't have to allocate anything yet */
|
||||||
|
*MemoryAllocated = FALSE;
|
||||||
|
|
||||||
/* Check if the object uses default security */
|
/* Check if the object uses default security */
|
||||||
if (Type->TypeInfo.SecurityProcedure == SeDefaultObjectMethod)
|
if (Type->TypeInfo.SecurityProcedure == SeDefaultObjectMethod)
|
||||||
{
|
{
|
||||||
/* Reference the descriptor */
|
/* Reference the descriptor */
|
||||||
*SecurityDescriptor =
|
*SecurityDescriptor =
|
||||||
ObpReferenceCachedSecurityDescriptor(Header->SecurityDescriptor);
|
ObpReferenceCachedSecurityDescriptor(Header->SecurityDescriptor);
|
||||||
|
|
||||||
/* Tell the caller that we didn't have to allocate anything */
|
|
||||||
*MemoryAllocated = FALSE;
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the security descriptor size */
|
/* Set mask to query */
|
||||||
Length = 0;
|
SecurityInformation = OWNER_SECURITY_INFORMATION |
|
||||||
Status = Type->TypeInfo.SecurityProcedure(Object,
|
|
||||||
QuerySecurityDescriptor,
|
|
||||||
OWNER_SECURITY_INFORMATION |
|
|
||||||
GROUP_SECURITY_INFORMATION |
|
GROUP_SECURITY_INFORMATION |
|
||||||
DACL_SECURITY_INFORMATION |
|
DACL_SECURITY_INFORMATION |
|
||||||
SACL_SECURITY_INFORMATION,
|
SACL_SECURITY_INFORMATION;
|
||||||
|
|
||||||
|
/* Get the security descriptor size */
|
||||||
|
ObpCalloutStart(&CalloutIrql);
|
||||||
|
Status = Type->TypeInfo.SecurityProcedure(Object,
|
||||||
|
QuerySecurityDescriptor,
|
||||||
|
&SecurityInformation,
|
||||||
*SecurityDescriptor,
|
*SecurityDescriptor,
|
||||||
&Length,
|
&Length,
|
||||||
&Header->SecurityDescriptor,
|
&Header->SecurityDescriptor,
|
||||||
Type->TypeInfo.PoolType,
|
Type->TypeInfo.PoolType,
|
||||||
&Type->TypeInfo.GenericMapping);
|
&Type->TypeInfo.GenericMapping);
|
||||||
|
ObpCalloutEnd(CalloutIrql, "Security", Type, Object);
|
||||||
|
|
||||||
|
/* Check for failure */
|
||||||
if (Status != STATUS_BUFFER_TOO_SMALL) return Status;
|
if (Status != STATUS_BUFFER_TOO_SMALL) return Status;
|
||||||
|
|
||||||
/* Allocate security descriptor */
|
/* Allocate security descriptor */
|
||||||
|
@ -248,20 +266,21 @@ ObGetObjectSecurity(IN PVOID Object,
|
||||||
Length,
|
Length,
|
||||||
TAG_SEC_QUERY);
|
TAG_SEC_QUERY);
|
||||||
if (!(*SecurityDescriptor)) return STATUS_INSUFFICIENT_RESOURCES;
|
if (!(*SecurityDescriptor)) return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
*MemoryAllocated = TRUE;
|
||||||
|
|
||||||
/* Query security descriptor */
|
/* Query security descriptor */
|
||||||
*MemoryAllocated = TRUE;
|
ObpCalloutStart(&CalloutIrql);
|
||||||
Status = Type->TypeInfo.SecurityProcedure(Object,
|
Status = Type->TypeInfo.SecurityProcedure(Object,
|
||||||
QuerySecurityDescriptor,
|
QuerySecurityDescriptor,
|
||||||
OWNER_SECURITY_INFORMATION |
|
&SecurityInformation,
|
||||||
GROUP_SECURITY_INFORMATION |
|
|
||||||
DACL_SECURITY_INFORMATION |
|
|
||||||
SACL_SECURITY_INFORMATION,
|
|
||||||
*SecurityDescriptor,
|
*SecurityDescriptor,
|
||||||
&Length,
|
&Length,
|
||||||
&Header->SecurityDescriptor,
|
&Header->SecurityDescriptor,
|
||||||
Type->TypeInfo.PoolType,
|
Type->TypeInfo.PoolType,
|
||||||
&Type->TypeInfo.GenericMapping);
|
&Type->TypeInfo.GenericMapping);
|
||||||
|
ObpCalloutEnd(CalloutIrql, "Security", Type, Object);
|
||||||
|
|
||||||
|
/* Check for failure */
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
/* Free the descriptor and tell the caller we failed */
|
/* Free the descriptor and tell the caller we failed */
|
||||||
|
@ -313,6 +332,51 @@ ObReleaseObjectSecurity(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*++
|
||||||
|
* @name ObSetSecurityObjectByPointer
|
||||||
|
* @implemented NT5.1
|
||||||
|
*
|
||||||
|
* The ObSetSecurityObjectByPointer routine <FILLMEIN>
|
||||||
|
*
|
||||||
|
* @param SecurityDescriptor
|
||||||
|
* <FILLMEIN>
|
||||||
|
*
|
||||||
|
* @param MemoryAllocated
|
||||||
|
* <FILLMEIN>
|
||||||
|
*
|
||||||
|
* @return STATUS_SUCCESS or appropriate error value.
|
||||||
|
*
|
||||||
|
* @remarks None.
|
||||||
|
*
|
||||||
|
*--*/
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
ObSetSecurityObjectByPointer(IN PVOID Object,
|
||||||
|
IN SECURITY_INFORMATION SecurityInformation,
|
||||||
|
IN PSECURITY_DESCRIPTOR SecurityDescriptor)
|
||||||
|
{
|
||||||
|
POBJECT_TYPE Type;
|
||||||
|
POBJECT_HEADER Header;
|
||||||
|
PAGED_CODE();
|
||||||
|
|
||||||
|
/* Get the header and type */
|
||||||
|
Header = OBJECT_TO_OBJECT_HEADER(Object);
|
||||||
|
Type = Header->Type;
|
||||||
|
|
||||||
|
/* Sanity check */
|
||||||
|
ASSERT(SecurityDescriptor);
|
||||||
|
|
||||||
|
/* Call the security procedure */
|
||||||
|
return Type->TypeInfo.SecurityProcedure(Object,
|
||||||
|
SetSecurityDescriptor,
|
||||||
|
&SecurityInformation,
|
||||||
|
SecurityDescriptor,
|
||||||
|
NULL,
|
||||||
|
&Header->SecurityDescriptor,
|
||||||
|
Type->TypeInfo.PoolType,
|
||||||
|
&Type->TypeInfo.GenericMapping);
|
||||||
|
}
|
||||||
|
|
||||||
/*++
|
/*++
|
||||||
* @name NtQuerySecurityObject
|
* @name NtQuerySecurityObject
|
||||||
* @implemented NT4
|
* @implemented NT4
|
||||||
|
@ -395,7 +459,7 @@ NtQuerySecurityObject(IN HANDLE Handle,
|
||||||
/* Call the security procedure's query function */
|
/* Call the security procedure's query function */
|
||||||
Status = Type->TypeInfo.SecurityProcedure(Object,
|
Status = Type->TypeInfo.SecurityProcedure(Object,
|
||||||
QuerySecurityDescriptor,
|
QuerySecurityDescriptor,
|
||||||
SecurityInformation,
|
&SecurityInformation,
|
||||||
SecurityDescriptor,
|
SecurityDescriptor,
|
||||||
&Length,
|
&Length,
|
||||||
&Header->SecurityDescriptor,
|
&Header->SecurityDescriptor,
|
||||||
|
@ -450,8 +514,6 @@ NtSetSecurityObject(IN HANDLE Handle,
|
||||||
{
|
{
|
||||||
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
|
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
|
||||||
PVOID Object;
|
PVOID Object;
|
||||||
POBJECT_HEADER Header;
|
|
||||||
POBJECT_TYPE Type;
|
|
||||||
SECURITY_DESCRIPTOR_RELATIVE *CapturedDescriptor;
|
SECURITY_DESCRIPTOR_RELATIVE *CapturedDescriptor;
|
||||||
ACCESS_MASK DesiredAccess;
|
ACCESS_MASK DesiredAccess;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -460,6 +522,18 @@ NtSetSecurityObject(IN HANDLE Handle,
|
||||||
/* Make sure the caller doesn't pass a NULL security descriptor! */
|
/* Make sure the caller doesn't pass a NULL security descriptor! */
|
||||||
if (!SecurityDescriptor) return STATUS_ACCESS_VIOLATION;
|
if (!SecurityDescriptor) return STATUS_ACCESS_VIOLATION;
|
||||||
|
|
||||||
|
/* Set the required access rights for the operation */
|
||||||
|
SeSetSecurityAccessMask(SecurityInformation, &DesiredAccess);
|
||||||
|
|
||||||
|
/* Reference the object */
|
||||||
|
Status = ObReferenceObjectByHandle(Handle,
|
||||||
|
DesiredAccess,
|
||||||
|
NULL,
|
||||||
|
PreviousMode,
|
||||||
|
&Object,
|
||||||
|
NULL);
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
/* Capture and make a copy of the security descriptor */
|
/* Capture and make a copy of the security descriptor */
|
||||||
Status = SeCaptureSecurityDescriptor(SecurityDescriptor,
|
Status = SeCaptureSecurityDescriptor(SecurityDescriptor,
|
||||||
PreviousMode,
|
PreviousMode,
|
||||||
|
@ -467,7 +541,15 @@ NtSetSecurityObject(IN HANDLE Handle,
|
||||||
TRUE,
|
TRUE,
|
||||||
(PSECURITY_DESCRIPTOR*)
|
(PSECURITY_DESCRIPTOR*)
|
||||||
&CapturedDescriptor);
|
&CapturedDescriptor);
|
||||||
if (!NT_SUCCESS(Status)) return Status;
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
/* Fail */
|
||||||
|
ObDereferenceObject(Object);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sanity check */
|
||||||
|
ASSERT(CapturedDescriptor->Control & SE_SELF_RELATIVE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure the security descriptor passed by the caller
|
* Make sure the security descriptor passed by the caller
|
||||||
|
@ -483,43 +565,20 @@ NtSetSecurityObject(IN HANDLE Handle,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Set the required access rights for the operation */
|
/* Set security */
|
||||||
SeSetSecurityAccessMask(SecurityInformation, &DesiredAccess);
|
Status = ObSetSecurityObjectByPointer(Object,
|
||||||
|
|
||||||
/* Reference the object */
|
|
||||||
Status = ObReferenceObjectByHandle(Handle,
|
|
||||||
DesiredAccess,
|
|
||||||
NULL,
|
|
||||||
PreviousMode,
|
|
||||||
&Object,
|
|
||||||
NULL);
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
/* Get the Object Header and Type */
|
|
||||||
Header = OBJECT_TO_OBJECT_HEADER(Object);
|
|
||||||
Type = Header->Type;
|
|
||||||
|
|
||||||
/* Call the security procedure's set function */
|
|
||||||
Status = Type->TypeInfo.SecurityProcedure(Object,
|
|
||||||
SetSecurityDescriptor,
|
|
||||||
SecurityInformation,
|
SecurityInformation,
|
||||||
SecurityDescriptor,
|
CapturedDescriptor);
|
||||||
NULL,
|
|
||||||
&Header->
|
|
||||||
SecurityDescriptor,
|
|
||||||
Type->TypeInfo.PoolType,
|
|
||||||
&Type->
|
|
||||||
TypeInfo.GenericMapping);
|
|
||||||
|
|
||||||
/* Now we can dereference the object */
|
|
||||||
ObDereferenceObject(Object);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Release the descriptor and return status */
|
/* Release the descriptor and return status */
|
||||||
SeReleaseSecurityDescriptor((PSECURITY_DESCRIPTOR)CapturedDescriptor,
|
SeReleaseSecurityDescriptor((PSECURITY_DESCRIPTOR)CapturedDescriptor,
|
||||||
PreviousMode,
|
PreviousMode,
|
||||||
TRUE);
|
TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now we can dereference the object */
|
||||||
|
ObDereferenceObject(Object);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -588,66 +647,4 @@ ObQueryObjectAuditingByHandle(IN HANDLE Handle,
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*++
|
|
||||||
* @name ObLogSecurityDescriptor
|
|
||||||
* @unimplemented NT5.2
|
|
||||||
*
|
|
||||||
* The ObLogSecurityDescriptor routine <FILLMEIN>
|
|
||||||
*
|
|
||||||
* @param InputSecurityDescriptor
|
|
||||||
* <FILLMEIN>
|
|
||||||
*
|
|
||||||
* @param OutputSecurityDescriptor
|
|
||||||
* <FILLMEIN>
|
|
||||||
*
|
|
||||||
* @param RefBias
|
|
||||||
* <FILLMEIN>
|
|
||||||
*
|
|
||||||
* @return STATUS_SUCCESS or appropriate error value.
|
|
||||||
*
|
|
||||||
* @remarks None.
|
|
||||||
*
|
|
||||||
*--*/
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
ObLogSecurityDescriptor(IN PSECURITY_DESCRIPTOR InputSecurityDescriptor,
|
|
||||||
OUT PSECURITY_DESCRIPTOR *OutputSecurityDescriptor,
|
|
||||||
IN ULONG RefBias)
|
|
||||||
{
|
|
||||||
/* HACK: Return the same descriptor back */
|
|
||||||
PISECURITY_DESCRIPTOR SdCopy;
|
|
||||||
DPRINT1("ObLogSecurityDescriptor is not implemented!\n",
|
|
||||||
InputSecurityDescriptor);
|
|
||||||
|
|
||||||
SdCopy = ExAllocatePool(PagedPool, sizeof(*SdCopy));
|
|
||||||
RtlCopyMemory(SdCopy, InputSecurityDescriptor, sizeof(*SdCopy));
|
|
||||||
*OutputSecurityDescriptor = SdCopy;
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*++
|
|
||||||
* @name ObDereferenceSecurityDescriptor
|
|
||||||
* @unimplemented NT5.2
|
|
||||||
*
|
|
||||||
* The ObDereferenceSecurityDescriptor routine <FILLMEIN>
|
|
||||||
*
|
|
||||||
* @param SecurityDescriptor
|
|
||||||
* <FILLMEIN>
|
|
||||||
*
|
|
||||||
* @param Count
|
|
||||||
* <FILLMEIN>
|
|
||||||
*
|
|
||||||
* @return STATUS_SUCCESS or appropriate error value.
|
|
||||||
*
|
|
||||||
* @remarks None.
|
|
||||||
*
|
|
||||||
*--*/
|
|
||||||
VOID
|
|
||||||
NTAPI
|
|
||||||
ObDereferenceSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
|
|
||||||
IN ULONG Count)
|
|
||||||
{
|
|
||||||
DPRINT1("ObDereferenceSecurityDescriptor is not implemented!\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -343,4 +343,66 @@ ObpDereferenceCachedSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescripto
|
||||||
DPRINT("ObpDereferenceCachedSecurityDescriptor() done\n");
|
DPRINT("ObpDereferenceCachedSecurityDescriptor() done\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*++
|
||||||
|
* @name ObLogSecurityDescriptor
|
||||||
|
* @unimplemented NT5.2
|
||||||
|
*
|
||||||
|
* The ObLogSecurityDescriptor routine <FILLMEIN>
|
||||||
|
*
|
||||||
|
* @param InputSecurityDescriptor
|
||||||
|
* <FILLMEIN>
|
||||||
|
*
|
||||||
|
* @param OutputSecurityDescriptor
|
||||||
|
* <FILLMEIN>
|
||||||
|
*
|
||||||
|
* @param RefBias
|
||||||
|
* <FILLMEIN>
|
||||||
|
*
|
||||||
|
* @return STATUS_SUCCESS or appropriate error value.
|
||||||
|
*
|
||||||
|
* @remarks None.
|
||||||
|
*
|
||||||
|
*--*/
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
ObLogSecurityDescriptor(IN PSECURITY_DESCRIPTOR InputSecurityDescriptor,
|
||||||
|
OUT PSECURITY_DESCRIPTOR *OutputSecurityDescriptor,
|
||||||
|
IN ULONG RefBias)
|
||||||
|
{
|
||||||
|
/* HACK: Return the same descriptor back */
|
||||||
|
PISECURITY_DESCRIPTOR SdCopy;
|
||||||
|
DPRINT1("ObLogSecurityDescriptor is not implemented!\n",
|
||||||
|
InputSecurityDescriptor);
|
||||||
|
|
||||||
|
SdCopy = ExAllocatePool(PagedPool, sizeof(*SdCopy));
|
||||||
|
RtlCopyMemory(SdCopy, InputSecurityDescriptor, sizeof(*SdCopy));
|
||||||
|
*OutputSecurityDescriptor = SdCopy;
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*++
|
||||||
|
* @name ObDereferenceSecurityDescriptor
|
||||||
|
* @unimplemented NT5.2
|
||||||
|
*
|
||||||
|
* The ObDereferenceSecurityDescriptor routine <FILLMEIN>
|
||||||
|
*
|
||||||
|
* @param SecurityDescriptor
|
||||||
|
* <FILLMEIN>
|
||||||
|
*
|
||||||
|
* @param Count
|
||||||
|
* <FILLMEIN>
|
||||||
|
*
|
||||||
|
* @return STATUS_SUCCESS or appropriate error value.
|
||||||
|
*
|
||||||
|
* @remarks None.
|
||||||
|
*
|
||||||
|
*--*/
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
ObDereferenceSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
|
IN ULONG Count)
|
||||||
|
{
|
||||||
|
DPRINT1("ObDereferenceSecurityDescriptor is not implemented!\n");
|
||||||
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -376,11 +376,11 @@ SeDeleteObjectAuditAlarm(IN PVOID Object,
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @unimplemented
|
||||||
*/
|
*/
|
||||||
VOID STDCALL
|
VOID
|
||||||
|
NTAPI
|
||||||
SeOpenObjectAuditAlarm(IN PUNICODE_STRING ObjectTypeName,
|
SeOpenObjectAuditAlarm(IN PUNICODE_STRING ObjectTypeName,
|
||||||
IN PVOID Object OPTIONAL,
|
IN PVOID Object OPTIONAL,
|
||||||
IN PUNICODE_STRING AbsoluteObjectName OPTIONAL,
|
IN PUNICODE_STRING AbsoluteObjectName OPTIONAL,
|
||||||
|
@ -391,9 +391,15 @@ SeOpenObjectAuditAlarm(IN PUNICODE_STRING ObjectTypeName,
|
||||||
IN KPROCESSOR_MODE AccessMode,
|
IN KPROCESSOR_MODE AccessMode,
|
||||||
OUT PBOOLEAN GenerateOnClose)
|
OUT PBOOLEAN GenerateOnClose)
|
||||||
{
|
{
|
||||||
DPRINT1("SeOpenObjectAuditAlarm is UNIMPLEMENTED!\n");
|
PAGED_CODE();
|
||||||
}
|
|
||||||
|
|
||||||
|
/* Audits aren't done on kernel-mode access */
|
||||||
|
if (AccessMode == KernelMode) return;
|
||||||
|
|
||||||
|
/* Otherwise, unimplemented! */
|
||||||
|
//UNIMPLEMENTED;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @unimplemented
|
||||||
|
|
|
@ -203,7 +203,7 @@ NTSTATUS
|
||||||
STDCALL
|
STDCALL
|
||||||
SeDefaultObjectMethod(PVOID Object,
|
SeDefaultObjectMethod(PVOID Object,
|
||||||
SECURITY_OPERATION_CODE OperationType,
|
SECURITY_OPERATION_CODE OperationType,
|
||||||
SECURITY_INFORMATION SecurityInformation,
|
PSECURITY_INFORMATION _SecurityInformation,
|
||||||
PSECURITY_DESCRIPTOR _SecurityDescriptor,
|
PSECURITY_DESCRIPTOR _SecurityDescriptor,
|
||||||
PULONG ReturnLength,
|
PULONG ReturnLength,
|
||||||
PSECURITY_DESCRIPTOR *OldSecurityDescriptor,
|
PSECURITY_DESCRIPTOR *OldSecurityDescriptor,
|
||||||
|
@ -225,10 +225,12 @@ SeDefaultObjectMethod(PVOID Object,
|
||||||
ULONG Control = 0;
|
ULONG Control = 0;
|
||||||
ULONG_PTR Current;
|
ULONG_PTR Current;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
SECURITY_INFORMATION SecurityInformation;
|
||||||
|
|
||||||
if (OperationType == SetSecurityDescriptor)
|
if (OperationType == SetSecurityDescriptor)
|
||||||
{
|
{
|
||||||
ObjectSd = Header->SecurityDescriptor;
|
ObjectSd = Header->SecurityDescriptor;
|
||||||
|
SecurityInformation = *_SecurityInformation;
|
||||||
|
|
||||||
/* Get owner and owner size */
|
/* Get owner and owner size */
|
||||||
if (SecurityInformation & OWNER_SECURITY_INFORMATION)
|
if (SecurityInformation & OWNER_SECURITY_INFORMATION)
|
||||||
|
@ -401,7 +403,7 @@ SeDefaultObjectMethod(PVOID Object,
|
||||||
}
|
}
|
||||||
else if (OperationType == QuerySecurityDescriptor)
|
else if (OperationType == QuerySecurityDescriptor)
|
||||||
{
|
{
|
||||||
Status = SeQuerySecurityDescriptorInfo(&SecurityInformation,
|
Status = SeQuerySecurityDescriptorInfo(_SecurityInformation,
|
||||||
SecurityDescriptor,
|
SecurityDescriptor,
|
||||||
ReturnLength,
|
ReturnLength,
|
||||||
&Header->SecurityDescriptor);
|
&Header->SecurityDescriptor);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue