diff --git a/src/coreclr/vm/assembly.cpp b/src/coreclr/vm/assembly.cpp index 7ec8d6b0db16e0..45d8a4a43ec5ae 100644 --- a/src/coreclr/vm/assembly.cpp +++ b/src/coreclr/vm/assembly.cpp @@ -996,25 +996,11 @@ ReleaseHolder Assembly::GetFriendAssemblyInfo() //***************************************************************************** // Is the given assembly a friend of this assembly? -bool Assembly::GrantsFriendAccessTo(Assembly *pAccessingAssembly, FieldDesc *pFD) +bool Assembly::GrantsFriendAccessTo(Assembly *pAccessingAssembly) { WRAPPER_NO_CONTRACT; - return GetFriendAssemblyInfo()->GrantsFriendAccessTo(pAccessingAssembly, pFD); -} - -bool Assembly::GrantsFriendAccessTo(Assembly *pAccessingAssembly, MethodDesc *pMD) -{ - WRAPPER_NO_CONTRACT; - - return GetFriendAssemblyInfo()->GrantsFriendAccessTo(pAccessingAssembly, pMD); -} - -bool Assembly::GrantsFriendAccessTo(Assembly *pAccessingAssembly, MethodTable *pMT) -{ - WRAPPER_NO_CONTRACT; - - return GetFriendAssemblyInfo()->GrantsFriendAccessTo(pAccessingAssembly, pMT); + return GetFriendAssemblyInfo()->GrantsFriendAccessTo(pAccessingAssembly); } bool Assembly::IgnoresAccessChecksTo(Assembly *pAccessedAssembly) diff --git a/src/coreclr/vm/assembly.hpp b/src/coreclr/vm/assembly.hpp index 9d6bf377e0c523..b2fbda186ee878 100644 --- a/src/coreclr/vm/assembly.hpp +++ b/src/coreclr/vm/assembly.hpp @@ -430,9 +430,7 @@ class Assembly //**************************************************************************************** // Is the given assembly a friend of this assembly? - bool GrantsFriendAccessTo(Assembly *pAccessingAssembly, FieldDesc *pFD); - bool GrantsFriendAccessTo(Assembly *pAccessingAssembly, MethodDesc *pMD); - bool GrantsFriendAccessTo(Assembly *pAccessingAssembly, MethodTable *pMT); + bool GrantsFriendAccessTo(Assembly *pAccessingAssembly); bool IgnoresAccessChecksTo(Assembly *pAccessedAssembly); #ifdef FEATURE_COMINTEROP @@ -578,24 +576,18 @@ class FriendAssemblyDescriptor // // Arguments: // pAccessingAssembly - the assembly requesting friend access - // pMember - the member that is attempting to be accessed // // Return Value: // true if friend access is allowed, false otherwise // - // Notes: - // Template type T should be either FieldDesc, MethodDesc, or MethodTable. - // - template - bool GrantsFriendAccessTo(Assembly *pAccessingAssembly, T *pMember) + bool GrantsFriendAccessTo(Assembly *pAccessingAssembly) { CONTRACTL { THROWS; GC_TRIGGERS; PRECONDITION(CheckPointer(pAccessingAssembly)); - PRECONDITION(CheckPointer(pMember)); } CONTRACTL_END; diff --git a/src/coreclr/vm/clsload.cpp b/src/coreclr/vm/clsload.cpp index 72ca527baa01c4..bdfe777d833130 100644 --- a/src/coreclr/vm/clsload.cpp +++ b/src/coreclr/vm/clsload.cpp @@ -4068,9 +4068,6 @@ void DECLSPEC_NORETURN ThrowTypeAccessException(MethodDesc* pCallerMD, // Arguments: // pAccessingAssembly - The assembly requesting access to the internal member // pTargetAssembly - The assembly which contains the target member -// pOptionalTargetField - Internal field being accessed OR -// pOptionalTargetMethod - Internal type being accessed OR -// pOptionalTargetType - Internal type being accessed // // Return Value: // TRUE if pTargetAssembly is pAccessingAssembly, or if pTargetAssembly allows @@ -4078,10 +4075,7 @@ void DECLSPEC_NORETURN ThrowTypeAccessException(MethodDesc* pCallerMD, // static BOOL AssemblyOrFriendAccessAllowed(Assembly *pAccessingAssembly, - Assembly *pTargetAssembly, - FieldDesc *pOptionalTargetField, - MethodDesc *pOptionalTargetMethod, - MethodTable *pOptionalTargetType) + Assembly *pTargetAssembly) { CONTRACTL { @@ -4089,8 +4083,6 @@ static BOOL AssemblyOrFriendAccessAllowed(Assembly *pAccessingAssembly, GC_TRIGGERS; PRECONDITION(CheckPointer(pAccessingAssembly)); PRECONDITION(CheckPointer(pTargetAssembly)); - PRECONDITION(pOptionalTargetField != NULL || pOptionalTargetMethod != NULL || pOptionalTargetType != NULL); - PRECONDITION(pOptionalTargetField == NULL || pOptionalTargetMethod == NULL); } CONTRACTL_END; @@ -4103,18 +4095,9 @@ static BOOL AssemblyOrFriendAccessAllowed(Assembly *pAccessingAssembly, { return TRUE; } - - else if (pOptionalTargetField != NULL) - { - return pTargetAssembly->GrantsFriendAccessTo(pAccessingAssembly, pOptionalTargetField); - } - else if (pOptionalTargetMethod != NULL) - { - return pTargetAssembly->GrantsFriendAccessTo(pAccessingAssembly, pOptionalTargetMethod); - } else { - return pTargetAssembly->GrantsFriendAccessTo(pAccessingAssembly, pOptionalTargetType); + return pTargetAssembly->GrantsFriendAccessTo(pAccessingAssembly); } } @@ -4247,10 +4230,7 @@ BOOL ClassLoader::CanAccessClass( // True if access is legal, _ASSERTE(pCurrentAssembly != NULL); if (AssemblyOrFriendAccessAllowed(pCurrentAssembly, - pTargetAssembly, - NULL, - NULL, - pTargetClass)) + pTargetAssembly)) { return TRUE; } @@ -4290,7 +4270,7 @@ BOOL ClassLoader::CanAccessClass( // True if access is legal, // protection, we can fail the request now. Otherwise we can check to make sure a public member // of the outer class is allowed, since we have satisfied the target's accessibility rules. - if (AssemblyOrFriendAccessAllowed(pContext->GetCallerAssembly(), pTargetAssembly, NULL, NULL, pTargetClass)) + if (AssemblyOrFriendAccessAllowed(pContext->GetCallerAssembly(), pTargetAssembly)) dwProtection = (dwProtection == tdNestedFamANDAssem) ? mdFamily : mdPublic; else if (dwProtection == tdNestedFamORAssem) dwProtection = mdFamily; @@ -4314,7 +4294,6 @@ BOOL ClassLoader::CanAccessClass( // True if access is legal, pTargetAssembly, dwProtection, NULL, - NULL, accessCheckOptions); } // BOOL ClassLoader::CanAccessClass() @@ -4331,7 +4310,6 @@ BOOL ClassLoader::CanAccess( // TRUE if access is all DWORD dwMemberAccess, // Member access flags of the desired target member (as method bits). MethodDesc* pOptionalTargetMethod, // The target method; NULL if the target is a not a method or // there is no need to check the method's instantiation. - FieldDesc* pOptionalTargetField, // or The desired field; if NULL, return TRUE const AccessCheckOptions & accessCheckOptions) // = s_NormalAccessChecks { CONTRACT(BOOL) @@ -4351,7 +4329,6 @@ BOOL ClassLoader::CanAccess( // TRUE if access is all pTargetAssembly, dwMemberAccess, pOptionalTargetMethod, - pOptionalTargetField, // Suppress exceptions for nested classes since this is not a hard-failure, // and we can do additional checks accessCheckOptionsNoThrow)) @@ -4384,7 +4361,6 @@ BOOL ClassLoader::CanAccess( // TRUE if access is all pTargetAssembly, dwMemberAccess, pOptionalTargetMethod, - pOptionalTargetField, accessCheckOptionsNoThrow); } @@ -4414,7 +4390,6 @@ BOOL ClassLoader::CheckAccessMember( // TRUE if access is allowed DWORD dwMemberAccess, // Member access flags of the desired target member (as method bits). MethodDesc* pOptionalTargetMethod, // The target method; NULL if the target is a not a method or // there is no need to check the method's instantiation. - FieldDesc* pOptionalTargetField, // target field, NULL if there is no Target field const AccessCheckOptions & accessCheckOptions ) { @@ -4449,9 +4424,6 @@ BOOL ClassLoader::CheckAccessMember( // TRUE if access is allowed return FALSE; } - // pOptionalTargetMethod and pOptionalTargetField can never be NULL at the same time. - _ASSERTE(pOptionalTargetMethod == NULL || pOptionalTargetField == NULL); - // Perform transparency checks // We don't need to do transparency check against pTargetMT here because // it was already done in CanAccessClass above. @@ -4503,10 +4475,7 @@ BOOL ClassLoader::CheckAccessMember( // TRUE if access is allowed _ASSERTE(pCurrentAssembly != NULL); const BOOL fAssemblyOrFriendAccessAllowed = AssemblyOrFriendAccessAllowed(pCurrentAssembly, - pTargetAssembly, - pOptionalTargetField, - pOptionalTargetMethod, - pTargetMT); + pTargetAssembly); if ((pTargetMT == NULL || IsMdAssem(dwMemberAccess) || IsMdFamORAssem(dwMemberAccess)) && fAssemblyOrFriendAccessAllowed) diff --git a/src/coreclr/vm/clsload.hpp b/src/coreclr/vm/clsload.hpp index c50dd4a5fc7987..3638466a70c563 100644 --- a/src/coreclr/vm/clsload.hpp +++ b/src/coreclr/vm/clsload.hpp @@ -827,7 +827,6 @@ class ClassLoader Assembly* pTargetAssembly, DWORD dwMemberAttrs, MethodDesc* pOptionalTargetMethod, - FieldDesc* pOptionalTargetField, const AccessCheckOptions & accessCheckOptions = *AccessCheckOptions::s_pNormalAccessChecks); private: @@ -847,7 +846,6 @@ class ClassLoader Assembly* pTargetAssembly, DWORD dwMemberAttrs, MethodDesc* pOptionalTargetMethod, - FieldDesc* pOptionalTargetField, const AccessCheckOptions & accessCheckOptions = *AccessCheckOptions::s_pNormalAccessChecks); diff --git a/src/coreclr/vm/dllimport.cpp b/src/coreclr/vm/dllimport.cpp index 9bf757b3ba0750..682371d6f02c36 100644 --- a/src/coreclr/vm/dllimport.cpp +++ b/src/coreclr/vm/dllimport.cpp @@ -4748,8 +4748,7 @@ HRESULT FindPredefinedILStubMethod(MethodDesc *pTargetMD, DWORD dwStubFlags, Met pStubClassMT, stubClassType.GetAssembly(), pStubMD->GetAttrs(), - pStubMD, - NULL)) + pStubMD)) { StackSString interopMethodName(SString::Utf8, pTargetMD->GetName()); diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index f0e6abfd342a03..d82ce4c5c1b95e 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -1624,7 +1624,6 @@ void CEEInfo::getFieldInfo (CORINFO_RESOLVED_TOKEN * pResolvedToken, fieldTypeForSecurity.GetAssembly(), fieldAttribs, NULL, - (flags & CORINFO_ACCESS_INIT_ARRAY) ? NULL : pField, // For InitializeArray, we don't need tocheck the type of the field. accessCheckOptions); if (!canAccess) @@ -5450,7 +5449,6 @@ void CEEInfo::getCallInfo( calleeTypeForSecurity.GetAssembly(), pCalleeForSecurity->GetAttrs(), pCalleeForSecurity, - NULL, accessCheckOptions ); @@ -13107,7 +13105,6 @@ static TADDR UnsafeJitFunctionWorker( ownerTypeForSecurity.GetAssembly(), pMethodForSecurity->GetAttrs(), pMethodForSecurity, - NULL, accessCheckOptions)) { EX_THROW(EEMethodException, (pMethodForSecurity)); diff --git a/src/coreclr/vm/methodtablebuilder.cpp b/src/coreclr/vm/methodtablebuilder.cpp index f36a4c3f6d1d30..672593d2a67b07 100644 --- a/src/coreclr/vm/methodtablebuilder.cpp +++ b/src/coreclr/vm/methodtablebuilder.cpp @@ -4710,7 +4710,7 @@ BOOL MethodTableBuilder::TestOverrideForAccessibility( if (IsMdCheckAccessOnOverride(dwParentAttrs)) { // Same Assembly - if (isSameAssembly || pParentAssembly->GrantsFriendAccessTo(pChildAssembly, hParentMethod.GetMethodDesc()) + if (isSameAssembly || pParentAssembly->GrantsFriendAccessTo(pChildAssembly) || pChildAssembly->IgnoresAccessChecksTo(pParentAssembly)) { // Can always override any method that has accessibility greater than mdPrivate @@ -4813,7 +4813,7 @@ VOID MethodTableBuilder::TestOverRide(bmtMethodHandle hParentMethod, WIDENING_STATUS entry = rgWideningTable[idxMember][idxParent]; if (entry == e_NO || - (entry == e_SA && !isSameAssembly && !pParentAssembly->GrantsFriendAccessTo(pAssembly, hParentMethod.GetMethodDesc()) + (entry == e_SA && !isSameAssembly && !pParentAssembly->GrantsFriendAccessTo(pAssembly) && !pAssembly->IgnoresAccessChecksTo(pParentAssembly)) || (entry == e_NSA && isSameAssembly) || (entry == e_SM && !isSameModule) diff --git a/src/coreclr/vm/runtimehandles.cpp b/src/coreclr/vm/runtimehandles.cpp index 0219c1aed68770..824e1aa035eb94 100644 --- a/src/coreclr/vm/runtimehandles.cpp +++ b/src/coreclr/vm/runtimehandles.cpp @@ -90,7 +90,6 @@ static BOOL CheckCAVisibilityFromDecoratedType(MethodTable* pCAMT, MethodDesc* p pCAMT->GetAssembly(), dwAttr, pCACtor, - NULL, *AccessCheckOptions::s_pNormalAccessChecks); }