Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit eb1e835

Browse files
committed
Merge pull request #3063 from dotnet/revert-3027-remove_security_checks
Revert "Remove useless security checks"
2 parents 2a07976 + a5e803c commit eb1e835

File tree

5 files changed

+2
-19
lines changed

5 files changed

+2
-19
lines changed

src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,6 @@ private unsafe void Init(String name,
438438
[System.Security.SecurityCritical] // auto-generated
439439
private void PerformSecurityCheck(Module m, ref StackCrawlMark stackMark, bool skipVisibility)
440440
{
441-
#if !FEATURE_CORECLR
442441
if (m == null)
443442
throw new ArgumentNullException("m");
444443
Contract.EndContractBlock();
@@ -478,13 +477,11 @@ private void PerformSecurityCheck(Module m, ref StackCrawlMark stackMark, bool s
478477
new SecurityPermission(SecurityPermissionFlag.ControlEvidence).Demand();
479478
#pragma warning restore 618
480479
#endif //FEATURE_CORECLR
481-
#endif //!FEATURE_CORECLR
482480
}
483481

484482
[System.Security.SecurityCritical] // auto-generated
485483
private void PerformSecurityCheck(Type owner, ref StackCrawlMark stackMark, bool skipVisibility)
486484
{
487-
#if !FEATURE_CORECLR
488485
if (owner == null)
489486
throw new ArgumentNullException("owner");
490487

@@ -522,7 +519,6 @@ private void PerformSecurityCheck(Type owner, ref StackCrawlMark stackMark, bool
522519
new SecurityPermission(SecurityPermissionFlag.ControlEvidence).Demand();
523520
#pragma warning restore 618
524521
#endif //FEATURE_CORECLR
525-
#endif //!FEATURE_CORECLR
526522
}
527523

528524
//

src/mscorlib/src/System/RtType.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5413,9 +5413,6 @@ internal Object CreateInstanceSlow(bool publicOnly, bool skipCheckThis, bool fil
54135413
bCanBeCached = false;
54145414
}
54155415
#endif
5416-
#if FEATURE_CORECLR
5417-
bSecurityCheckOff = true; // CoreCLR does not use security at all.
5418-
#endif
54195416

54205417
Object instance = RuntimeTypeHandle.CreateInstance(this, publicOnly, bSecurityCheckOff, ref bCanBeCached, ref runtime_ctor, ref bNeedSecurityCheck);
54215418

@@ -5470,11 +5467,9 @@ internal Object CreateInstanceDefaultCtor(bool publicOnly, bool skipCheckThis, b
54705467

54715468
if (ace.m_ctor != null)
54725469
{
5473-
#if !FEATURE_CORECLR
54745470
// Perform security checks if needed
54755471
if (ace.m_bNeedSecurityCheck)
54765472
RuntimeMethodHandle.PerformSecurityCheck(instance, ace.m_hCtorMethodHandle, this, (uint)INVOCATION_FLAGS.INVOCATION_FLAGS_CONSTRUCTOR_INVOKE);
5477-
#endif
54785473

54795474
// Call ctor (value types wont have any)
54805475
try

src/mscorlib/src/System/RuntimeHandles.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,20 +1196,16 @@ internal static INVOCATION_FLAGS GetSecurityFlags(IRuntimeMethodInfo handle)
11961196
[MethodImplAttribute(MethodImplOptions.InternalCall)]
11971197
static extern internal uint GetSpecialSecurityFlags(IRuntimeMethodInfo method);
11981198

1199-
#if !FEATURE_CORECLR
12001199
[System.Security.SecurityCritical] // auto-generated
12011200
[MethodImplAttribute(MethodImplOptions.InternalCall)]
12021201
static extern internal void PerformSecurityCheck(Object obj, RuntimeMethodHandleInternal method, RuntimeType parent, uint invocationFlags);
1203-
#endif //!FEATURE_CORECLR
12041202

12051203
[System.Security.SecurityCritical]
12061204
static internal void PerformSecurityCheck(Object obj, IRuntimeMethodInfo method, RuntimeType parent, uint invocationFlags)
12071205
{
1208-
#if !FEATURE_CORECLR
12091206
RuntimeMethodHandle.PerformSecurityCheck(obj, method.Value, parent, invocationFlags);
12101207
GC.KeepAlive(method);
12111208
return;
1212-
#endif //!FEATURE_CORECLR
12131209
}
12141210
#endregion
12151211

src/vm/ecalllist.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,9 +575,7 @@ FCFuncStart(gRuntimeMethodHandle)
575575
QCFuncElement("GetCallerType", RuntimeMethodHandle::GetCallerType)
576576
FCFuncElement("GetLoaderAllocator", RuntimeMethodHandle::GetLoaderAllocator)
577577
FCFuncElement("GetSpecialSecurityFlags", ReflectionInvocation::GetSpecialSecurityFlags)
578-
#ifndef FEATURE_CORECLR
579578
FCFuncElement("PerformSecurityCheck", ReflectionInvocation::PerformSecurityCheck)
580-
#endif // FEATURE_CORECLR
581579
FCFuncEnd()
582580

583581
FCFuncStart(gCOMDefaultBinderFuncs)

src/vm/reflectioninvocation.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44
//
5+
56
//
67

8+
79
#include "common.h"
810
#include "reflectioninvocation.h"
911
#include "invokeutil.h"
@@ -898,8 +900,6 @@ FCIMPL1(DWORD, ReflectionInvocation::GetSpecialSecurityFlags, ReflectMethodObjec
898900
}
899901
FCIMPLEND
900902

901-
#ifndef FEATURE_CORECLR
902-
903903
// Can not inline this function.
904904
#ifdef _MSC_VER
905905
__declspec(noinline)
@@ -1000,8 +1000,6 @@ FCIMPL4(void, ReflectionInvocation::PerformSecurityCheck, Object *target, Method
10001000
}
10011001
FCIMPLEND
10021002

1003-
#endif // FEATURE_CORECLR
1004-
10051003
/****************************************************************************/
10061004
/* boxed Nullable<T> are represented as a boxed T, so there is no unboxed
10071005
Nullable<T> inside to point at by reference. Because of this a byref

0 commit comments

Comments
 (0)