Remove security checks.
authorVance Morrison <vancem@microsoft.com>
Sat, 23 Jan 2016 00:34:37 +0000 (16:34 -0800)
committerstephentoub <stoub@microsoft.com>
Thu, 4 Feb 2016 15:05:21 +0000 (10:05 -0500)
These are holdovers from Silverlight days.   We don't support code access security in coreclr.

src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs
src/mscorlib/src/System/RtType.cs
src/mscorlib/src/System/RuntimeHandles.cs
src/vm/ecalllist.h
src/vm/reflectioninvocation.cpp

index 99dc6f19b14fdb3ddea929cee936afdd6b17a7b3..4e33cf262713a43c7bbe0b8afd0d5b611ff4b725 100644 (file)
@@ -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
         }
 
         //
index 8c82af9d3f79174f729109c07d61a3d8c090fd96..8478dcdcc4838c259ca2f50282efe2b66a09d495 100644 (file)
@@ -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
index 21f17ce97bf7cc9487f7065834ce2f846216c374..565169e7aab6fe2dd74c922f18817d3e6df084bc 100644 (file)
@@ -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
 
index 2eef162012f1891afb90b552bdf144705fda7622..ee645c2f38bf1653d9e363354c2e62f46557a2c9 100644 (file)
@@ -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)
index f94e2f537330b6ed9e44e4ccae84a402a37c3da0..edbb67850286b90c45b9784f684d75708f0e1a75 100644 (file)
@@ -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<T> are represented as a boxed T, so there is no unboxed
    Nullable<T> inside to point at by reference.  Because of this a byref