From: Vance Morrison Date: Sat, 23 Jan 2016 00:34:37 +0000 (-0800) Subject: Remove security checks. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a57f3859dabb5b445c63ff01141f45fb776645bb;p=platform%2Fupstream%2Fcoreclr.git Remove security checks. These are holdovers from Silverlight days. We don't support code access security in coreclr. --- diff --git a/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs b/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs index 99dc6f19b1..4e33cf2627 100644 --- a/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs +++ b/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs @@ -438,6 +438,7 @@ namespace System.Reflection.Emit [System.Security.SecurityCritical] // auto-generated private void PerformSecurityCheck(Module m, ref StackCrawlMark stackMark, bool skipVisibility) { +#if !FEATURE_CORECLR if (m == null) throw new ArgumentNullException("m"); Contract.EndContractBlock(); @@ -477,11 +478,13 @@ namespace System.Reflection.Emit new SecurityPermission(SecurityPermissionFlag.ControlEvidence).Demand(); #pragma warning restore 618 #endif //FEATURE_CORECLR +#endif //!FEATURE_CORECLR } [System.Security.SecurityCritical] // auto-generated private void PerformSecurityCheck(Type owner, ref StackCrawlMark stackMark, bool skipVisibility) { +#if !FEATURE_CORECLR if (owner == null) throw new ArgumentNullException("owner"); @@ -519,6 +522,7 @@ namespace System.Reflection.Emit new SecurityPermission(SecurityPermissionFlag.ControlEvidence).Demand(); #pragma warning restore 618 #endif //FEATURE_CORECLR +#endif //!FEATURE_CORECLR } // diff --git a/src/mscorlib/src/System/RtType.cs b/src/mscorlib/src/System/RtType.cs index 8c82af9d3f..8478dcdcc4 100644 --- a/src/mscorlib/src/System/RtType.cs +++ b/src/mscorlib/src/System/RtType.cs @@ -5413,6 +5413,9 @@ namespace System bCanBeCached = false; } #endif +#if FEATURE_CORECLR + bSecurityCheckOff = true; // CoreCLR does not use security at all. +#endif Object instance = RuntimeTypeHandle.CreateInstance(this, publicOnly, bSecurityCheckOff, ref bCanBeCached, ref runtime_ctor, ref bNeedSecurityCheck); @@ -5467,9 +5470,11 @@ namespace System if (ace.m_ctor != null) { +#if !FEATURE_CORECLR // Perform security checks if needed if (ace.m_bNeedSecurityCheck) RuntimeMethodHandle.PerformSecurityCheck(instance, ace.m_hCtorMethodHandle, this, (uint)INVOCATION_FLAGS.INVOCATION_FLAGS_CONSTRUCTOR_INVOKE); +#endif // Call ctor (value types wont have any) try diff --git a/src/mscorlib/src/System/RuntimeHandles.cs b/src/mscorlib/src/System/RuntimeHandles.cs index 21f17ce97b..565169e7aa 100644 --- a/src/mscorlib/src/System/RuntimeHandles.cs +++ b/src/mscorlib/src/System/RuntimeHandles.cs @@ -1196,16 +1196,20 @@ namespace System [MethodImplAttribute(MethodImplOptions.InternalCall)] static extern internal uint GetSpecialSecurityFlags(IRuntimeMethodInfo method); +#if !FEATURE_CORECLR [System.Security.SecurityCritical] // auto-generated [MethodImplAttribute(MethodImplOptions.InternalCall)] static extern internal void PerformSecurityCheck(Object obj, RuntimeMethodHandleInternal method, RuntimeType parent, uint invocationFlags); +#endif //!FEATURE_CORECLR [System.Security.SecurityCritical] static internal void PerformSecurityCheck(Object obj, IRuntimeMethodInfo method, RuntimeType parent, uint invocationFlags) { +#if !FEATURE_CORECLR RuntimeMethodHandle.PerformSecurityCheck(obj, method.Value, parent, invocationFlags); GC.KeepAlive(method); return; +#endif //!FEATURE_CORECLR } #endregion diff --git a/src/vm/ecalllist.h b/src/vm/ecalllist.h index 2eef162012..ee645c2f38 100644 --- a/src/vm/ecalllist.h +++ b/src/vm/ecalllist.h @@ -575,7 +575,9 @@ FCFuncStart(gRuntimeMethodHandle) QCFuncElement("GetCallerType", RuntimeMethodHandle::GetCallerType) FCFuncElement("GetLoaderAllocator", RuntimeMethodHandle::GetLoaderAllocator) FCFuncElement("GetSpecialSecurityFlags", ReflectionInvocation::GetSpecialSecurityFlags) +#ifndef FEATURE_CORECLR FCFuncElement("PerformSecurityCheck", ReflectionInvocation::PerformSecurityCheck) +#endif // FEATURE_CORECLR FCFuncEnd() FCFuncStart(gCOMDefaultBinderFuncs) diff --git a/src/vm/reflectioninvocation.cpp b/src/vm/reflectioninvocation.cpp index f94e2f5373..edbb678502 100644 --- a/src/vm/reflectioninvocation.cpp +++ b/src/vm/reflectioninvocation.cpp @@ -2,10 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. // - // - #include "common.h" #include "reflectioninvocation.h" #include "invokeutil.h" @@ -900,6 +898,8 @@ FCIMPL1(DWORD, ReflectionInvocation::GetSpecialSecurityFlags, ReflectMethodObjec } FCIMPLEND +#ifndef FEATURE_CORECLR + // Can not inline this function. #ifdef _MSC_VER __declspec(noinline) @@ -1000,6 +1000,8 @@ FCIMPL4(void, ReflectionInvocation::PerformSecurityCheck, Object *target, Method } FCIMPLEND +#endif // FEATURE_CORECLR + /****************************************************************************/ /* boxed Nullable are represented as a boxed T, so there is no unboxed Nullable inside to point at by reference. Because of this a byref