You've already forked linux-packaging-mono
Imported Upstream version 4.2.0.179
Former-commit-id: 0a113cb3a6feb7873f632839b1307cc6033cd595
This commit is contained in:
committed by
Jo Shields
parent
183bba2c9a
commit
6992685b86
@@ -11,9 +11,11 @@ namespace System.Runtime
|
||||
|
||||
abstract class ActionItem
|
||||
{
|
||||
#if FEATURE_COMPRESSEDSTACK
|
||||
[Fx.Tag.SecurityNote(Critical = "Stores the security context, used later in binding back into")]
|
||||
[SecurityCritical]
|
||||
SecurityContext context;
|
||||
#endif
|
||||
bool isScheduled;
|
||||
|
||||
bool lowPriority;
|
||||
@@ -76,6 +78,7 @@ namespace System.Runtime
|
||||
}
|
||||
|
||||
this.isScheduled = true;
|
||||
#if FEATURE_COMPRESSEDSTACK
|
||||
if (PartialTrustHelpers.ShouldFlowSecurityContext)
|
||||
{
|
||||
this.context = PartialTrustHelpers.CaptureSecurityContextNoIdentityFlow();
|
||||
@@ -85,10 +88,12 @@ namespace System.Runtime
|
||||
ScheduleCallback(CallbackHelper.InvokeWithContextCallback);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
ScheduleCallback(CallbackHelper.InvokeWithoutContextCallback);
|
||||
}
|
||||
}
|
||||
#if FEATURE_COMPRESSEDSTACK
|
||||
[Fx.Tag.SecurityNote(Critical = "Access critical field context and critical property " +
|
||||
"CallbackHelper.InvokeWithContextCallback, calls into critical method ScheduleCallback; " +
|
||||
"since nothing is known about the given context, can't be treated as safe")]
|
||||
@@ -108,6 +113,8 @@ namespace System.Runtime
|
||||
this.context = context.CreateCopy();
|
||||
ScheduleCallback(CallbackHelper.InvokeWithContextCallback);
|
||||
}
|
||||
#endif
|
||||
|
||||
[Fx.Tag.SecurityNote(Critical = "Access critical property CallbackHelper.InvokeWithoutContextCallback, " +
|
||||
"Calls into critical method ScheduleCallback; not bound to a security context")]
|
||||
[SecurityCritical]
|
||||
@@ -137,7 +144,7 @@ namespace System.Runtime
|
||||
IOThreadScheduler.ScheduleCallbackNoFlow(callback, state);
|
||||
}
|
||||
}
|
||||
|
||||
#if FEATURE_COMPRESSEDSTACK
|
||||
[Fx.Tag.SecurityNote(Critical = "Extract the security context stored and reset the critical field")]
|
||||
[SecurityCritical]
|
||||
SecurityContext ExtractContext()
|
||||
@@ -148,7 +155,7 @@ namespace System.Runtime
|
||||
this.context = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
[Fx.Tag.SecurityNote(Critical = "Calls into critical static method ScheduleCallback")]
|
||||
[SecurityCritical]
|
||||
void ScheduleCallback(Action<object> callback)
|
||||
@@ -159,12 +166,16 @@ namespace System.Runtime
|
||||
[SecurityCritical]
|
||||
static class CallbackHelper
|
||||
{
|
||||
#if FEATURE_COMPRESSEDSTACK
|
||||
[Fx.Tag.SecurityNote(Critical = "Stores a delegate to a critical method")]
|
||||
static Action<object> invokeWithContextCallback;
|
||||
#endif
|
||||
[Fx.Tag.SecurityNote(Critical = "Stores a delegate to a critical method")]
|
||||
static Action<object> invokeWithoutContextCallback;
|
||||
[Fx.Tag.SecurityNote(Critical = "Stores a delegate to a critical method")]
|
||||
static ContextCallback onContextAppliedCallback;
|
||||
|
||||
#if FEATURE_COMPRESSEDSTACK
|
||||
[Fx.Tag.SecurityNote(Critical = "Provides access to a critical field; Initialize it with " +
|
||||
"a delegate to a critical method")]
|
||||
public static Action<object> InvokeWithContextCallback
|
||||
@@ -178,7 +189,7 @@ namespace System.Runtime
|
||||
return invokeWithContextCallback;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
[Fx.Tag.SecurityNote(Critical = "Provides access to a critical field; Initialize it with " +
|
||||
"a delegate to a critical method")]
|
||||
public static Action<object> InvokeWithoutContextCallback
|
||||
@@ -205,13 +216,14 @@ namespace System.Runtime
|
||||
return onContextAppliedCallback;
|
||||
}
|
||||
}
|
||||
#if FEATURE_COMPRESSEDSTACK
|
||||
[Fx.Tag.SecurityNote(Critical = "Called by the scheduler without any user context on the stack")]
|
||||
static void InvokeWithContext(object state)
|
||||
{
|
||||
SecurityContext context = ((ActionItem)state).ExtractContext();
|
||||
SecurityContext.Run(context, OnContextAppliedCallback, state);
|
||||
}
|
||||
|
||||
#endif
|
||||
[Fx.Tag.SecurityNote(Critical = "Called by the scheduler without any user context on the stack")]
|
||||
static void InvokeWithoutContext(object state)
|
||||
{
|
||||
|
@@ -36,6 +36,9 @@ namespace System.Runtime
|
||||
[SecurityCritical]
|
||||
internal static bool IsInFullTrust()
|
||||
{
|
||||
#if DISABLE_CAS_USE
|
||||
return true;
|
||||
#else
|
||||
if (!SecurityManager.CurrentThreadRequiresSecurityContextCapture())
|
||||
{
|
||||
return true;
|
||||
@@ -50,8 +53,9 @@ namespace System.Runtime
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if FEATURE_COMPRESSEDSTACK
|
||||
[Fx.Tag.SecurityNote(Critical = "Captures security context with identity flow suppressed, " +
|
||||
"this requires satisfying a LinkDemand for infrastructure.")]
|
||||
[SecurityCritical]
|
||||
@@ -70,7 +74,7 @@ namespace System.Runtime
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
[Fx.Tag.SecurityNote(Critical = "used in a security-sensitive decision")]
|
||||
[SecurityCritical]
|
||||
internal static bool IsTypeAptca(Type type)
|
||||
@@ -110,17 +114,25 @@ namespace System.Runtime
|
||||
[SecurityCritical]
|
||||
internal static bool CheckAppDomainPermissions(PermissionSet permissions)
|
||||
{
|
||||
#if DISABLE_CAS_USE
|
||||
return true;
|
||||
#else
|
||||
return AppDomain.CurrentDomain.IsHomogenous &&
|
||||
permissions.IsSubsetOf(AppDomain.CurrentDomain.PermissionSet);
|
||||
#endif
|
||||
}
|
||||
|
||||
[Fx.Tag.SecurityNote(Critical = "used in a security-sensitive decision")]
|
||||
[SecurityCritical]
|
||||
internal static bool HasEtwPermissions()
|
||||
{
|
||||
#if DISABLE_CAS_USE
|
||||
return true;
|
||||
#else
|
||||
//Currently unrestricted permissions are required to create Etw provider.
|
||||
PermissionSet permissions = new PermissionSet(PermissionState.Unrestricted);
|
||||
return CheckAppDomainPermissions(permissions);
|
||||
#endif
|
||||
}
|
||||
|
||||
internal static bool AppDomainFullyTrusted
|
||||
@@ -130,6 +142,9 @@ namespace System.Runtime
|
||||
[SecuritySafeCritical]
|
||||
get
|
||||
{
|
||||
#if DISABLE_CAS_USE
|
||||
return true;
|
||||
#else
|
||||
if (!checkedForFullTrust)
|
||||
{
|
||||
inFullTrust = AppDomain.CurrentDomain.IsFullyTrusted;
|
||||
@@ -137,6 +152,7 @@ namespace System.Runtime
|
||||
}
|
||||
|
||||
return inFullTrust;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user