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

Strip some security related attributes #8571

Merged
merged 1 commit into from
Dec 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
17 changes: 0 additions & 17 deletions src/mscorlib/Common/PinnableBufferCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ internal sealed class PinnableBufferCache
/// Create a PinnableBufferCache that works on any object (it is intended for OverlappedData)
/// This is only used in mscorlib.
/// </summary>
#if (ENABLE || MINBUFFERS)
#pragma warning disable 618
[EnvironmentPermission(SecurityAction.Assert, Unrestricted = true)]
#pragma warning restore 618
[System.Security.SecuritySafeCritical]
#endif
internal PinnableBufferCache(string cacheName, Func<object> factory)
{
m_NotGen2 = new List<object>(DefaultNumberOfBuffers);
Expand Down Expand Up @@ -100,7 +94,6 @@ internal PinnableBufferCache(string cacheName, Func<object> factory)
/// <summary>
/// Get a object from the buffer manager. If no buffers exist, allocate a new one.
/// </summary>
[System.Security.SecuritySafeCritical]
internal object Allocate()
{
#if ENABLE
Expand Down Expand Up @@ -146,7 +139,6 @@ internal object Allocate()
/// <summary>
/// Return a buffer back to the buffer manager.
/// </summary>
[System.Security.SecuritySafeCritical]
internal void Free(object buffer)
{
#if ENABLE
Expand Down Expand Up @@ -185,7 +177,6 @@ internal void Free(object buffer)
/// Called when we don't have any buffers in our free list to give out.
/// </summary>
/// <returns></returns>
[System.Security.SecuritySafeCritical]
private void Restock(out object returnBuffer)
{
lock (this)
Expand Down Expand Up @@ -238,7 +229,6 @@ private void Restock(out object returnBuffer)
/// <summary>
/// See if we can promote the buffers to the free list. Returns true if sucessful.
/// </summary>
[System.Security.SecuritySafeCritical]
private bool AgePendingBuffers()
{
if (m_gen1CountAtLastRestock < GC.CollectionCount(GC.MaxGeneration - 1))
Expand Down Expand Up @@ -314,7 +304,6 @@ private void CreateNewBuffers()
/// otherwise, we root the cache to the Gen2GcCallback object, and leak the cache even when
/// the application no longer needs it.
/// </summary>
[System.Security.SecuritySafeCritical]
private static bool Gen2GcCallbackFunc(object targetObj)
{
return ((PinnableBufferCache)(targetObj)).TrimFreeListIfNeeded();
Expand All @@ -325,7 +314,6 @@ private static bool Gen2GcCallbackFunc(object targetObj)
/// NOTE: DO NOT CALL THIS DIRECTLY FROM THE GEN2GCCALLBACK. INSTEAD CALL IT VIA A STATIC FUNCTION (SEE ABOVE).
/// If you register a non-static function as a callback, then this object will be leaked.
/// </summary>
[System.Security.SecuritySafeCritical]
private bool TrimFreeListIfNeeded()
{
int curMSec = Environment.TickCount;
Expand Down Expand Up @@ -478,7 +466,6 @@ private bool TrimFreeListIfNeeded()
/// </summary>
internal sealed class Gen2GcCallback : CriticalFinalizerObject
{
[System.Security.SecuritySafeCritical]
public Gen2GcCallback()
: base()
{
Expand All @@ -503,14 +490,12 @@ public static void Register(Func<object, bool> callback, object targetObj)
private Func<object, bool> m_callback;
private GCHandle m_weakTargetObj;

[System.Security.SecuritySafeCritical]
private void Setup(Func<object, bool> callback, object targetObj)
{
m_callback = callback;
m_weakTargetObj = GCHandle.Alloc(targetObj, GCHandleType.Weak);
}

[System.Security.SecuritySafeCritical]
~Gen2GcCallback()
{
// Check to see if the target object is still alive.
Expand Down Expand Up @@ -578,7 +563,6 @@ static internal ulong AddressOf(object obj)
return 0;
}

[System.Security.SecuritySafeCritical]
static internal unsafe long AddressOfObject(byte[] array)
{
return 0;
Expand Down Expand Up @@ -650,7 +634,6 @@ static internal ulong AddressOf(object obj)
return 0;
}

[System.Security.SecuritySafeCritical]
static internal unsafe long AddressOfByteArray(byte[] array)
{
if (array == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ internal partial class mincore
/// "lpt1:", etc. Use this to avoid security problems, like allowing a web client asking a server
/// for "http://server/com1.aspx" and then causing a worker process to hang.
/// </summary>
[System.Security.SecurityCritical] // auto-generated
internal static SafeFileHandle SafeCreateFile(
String lpFileName,
int dwDesiredAccess,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ internal partial class Interop
{
internal partial class mincore
{
[System.Security.SecurityCritical] // auto-generated
internal static SafeFileHandle UnsafeCreateFile(
string lpFileName,
int dwDesiredAccess,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace Microsoft.Win32.SafeHandles
{
[System.Security.SecurityCritical] // auto-generated_required
public sealed class SafeFileHandle : SafeHandleZeroOrMinusOneIsInvalid
{
private bool? _isAsync;
Expand Down Expand Up @@ -42,7 +41,6 @@ internal bool? IsAsync

internal ThreadPoolBoundHandle ThreadPoolBinding { get; set; }

[System.Security.SecurityCritical]
override protected bool ReleaseHandle()
{
return Interop.mincore.CloseHandle(handle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ internal unsafe char* CharPointer
/// <summary>
/// True if the buffer contains the given character.
/// </summary>
[System.Security.SecurityCritical]
public unsafe bool Contains(char value)
{
char* start = CharPointer;
Expand Down
26 changes: 0 additions & 26 deletions src/mscorlib/src/Internal/Runtime/Augments/RuntimeThread.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ private Thread AsThread()
=========================================================================*/
public extern bool IsAlive
{
[SecuritySafeCritical] // auto-generated
[MethodImpl(MethodImplOptions.InternalCall)]
get;
}
Expand All @@ -46,18 +45,14 @@ public extern bool IsAlive
=========================================================================*/
public bool IsBackground
{
[SecuritySafeCritical] // auto-generated
get { return IsBackgroundNative(); }
[SecuritySafeCritical] // auto-generated
[HostProtection(SelfAffectingThreading = true)]
set { SetBackgroundNative(value); }
}

[SecurityCritical] // auto-generated
[MethodImpl(MethodImplOptions.InternalCall)]
private extern bool IsBackgroundNative();

[SecurityCritical] // auto-generated
[MethodImpl(MethodImplOptions.InternalCall)]
private extern void SetBackgroundNative(bool isBackground);

Expand All @@ -66,7 +61,6 @@ public bool IsBackground
=========================================================================*/
public extern bool IsThreadPoolThread
{
[SecuritySafeCritical] // auto-generated
[MethodImpl(MethodImplOptions.InternalCall)]
get;
}
Expand All @@ -81,18 +75,14 @@ public extern bool IsThreadPoolThread
=========================================================================*/
public ThreadPriority Priority
{
[SecuritySafeCritical] // auto-generated
get { return (ThreadPriority)GetPriorityNative(); }
[SecuritySafeCritical] // auto-generated
[HostProtection(SelfAffectingThreading = true)]
set { SetPriorityNative((int)value); }
}

[SecurityCritical] // auto-generated
[MethodImpl(MethodImplOptions.InternalCall)]
private extern int GetPriorityNative();

[SecurityCritical] // auto-generated
[MethodImpl(MethodImplOptions.InternalCall)]
private extern void SetPriorityNative(int priority);

Expand All @@ -102,15 +92,12 @@ public ThreadPriority Priority
=========================================================================*/
public ThreadState ThreadState
{
[SecuritySafeCritical] // auto-generated
get { return (ThreadState)GetThreadStateNative(); }
}

[SecurityCritical] // auto-generated
[MethodImpl(MethodImplOptions.InternalCall)]
private extern int GetThreadStateNative();

[SecuritySafeCritical] // auto-generated
public ApartmentState GetApartmentState()
{
#if FEATURE_COMINTEROP_APARTMENT_SUPPORT
Expand All @@ -125,7 +112,6 @@ public ApartmentState GetApartmentState()
** An unstarted thread can be marked to indicate that it will host a
** single-threaded or multi-threaded apartment.
=========================================================================*/
[SecuritySafeCritical] // auto-generated
[HostProtection(Synchronization = true, SelfAffectingThreading = true)]
public bool TrySetApartmentState(ApartmentState state)
{
Expand All @@ -138,7 +124,6 @@ public bool TrySetApartmentState(ApartmentState state)
}

#if FEATURE_COMINTEROP_APARTMENT_SUPPORT
[SecurityCritical] // auto-generated
internal bool SetApartmentStateHelper(ApartmentState state, bool fireMDAOnMismatch)
{
ApartmentState retState = (ApartmentState)SetApartmentStateNative((int)state, fireMDAOnMismatch);
Expand All @@ -156,22 +141,18 @@ internal bool SetApartmentStateHelper(ApartmentState state, bool fireMDAOnMismat
return true;
}

[SecurityCritical] // auto-generated
[MethodImpl(MethodImplOptions.InternalCall)]
internal extern int GetApartmentStateNative();

[SecurityCritical] // auto-generated
[MethodImpl(MethodImplOptions.InternalCall)]
internal extern int SetApartmentStateNative(int state, bool fireMDAOnMismatch);
#endif // FEATURE_COMINTEROP_APARTMENT_SUPPORT

#if FEATURE_COMINTEROP
[SecurityCritical] // auto-generated
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImpl(MethodImplOptions.InternalCall)]
public extern void DisableComObjectEagerCleanup();
#else // !FEATURE_COMINTEROP
[SecurityCritical] // auto-generated
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public void DisableComObjectEagerCleanup()
{
Expand All @@ -185,18 +166,14 @@ public void DisableComObjectEagerCleanup()
** when it next begins to block.
=========================================================================*/
#if FEATURE_CORECLR
[SecurityCritical] // auto-generated
#else
[SecuritySafeCritical] // auto-generated
#endif
#pragma warning disable 618 // obsolete types: SecurityPermissionAttribute, SecurityAction
[SecurityPermission(SecurityAction.Demand, ControlThread = true)]
#pragma warning restore 618 // obsolete types: SecurityPermissionAttribute, SecurityAction
public void Interrupt() => InterruptInternal();

// Internal helper (since we can't place security demands on
// ecalls/fcalls).
[SecurityCritical] // auto-generated
[MethodImpl(MethodImplOptions.InternalCall)]
private extern void InterruptInternal();

Expand All @@ -209,15 +186,12 @@ public void DisableComObjectEagerCleanup()
** ThreadInterruptedException if the thread is interrupted while waiting.
** ThreadStateException if the thread has not been started yet.
=========================================================================*/
[SecuritySafeCritical]
[HostProtection(Synchronization = true, ExternalThreading = true)]
public void Join() => JoinInternal(Timeout.Infinite);

[SecuritySafeCritical]
[HostProtection(Synchronization = true, ExternalThreading = true)]
public bool Join(int millisecondsTimeout) => JoinInternal(millisecondsTimeout);

[SecurityCritical]
[MethodImpl(MethodImplOptions.InternalCall)]
private extern bool JoinInternal(int millisecondsTimeout);

Expand Down
2 changes: 0 additions & 2 deletions src/mscorlib/src/Microsoft/Win32/OAVariantLib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ internal static class OAVariantLib
* Variant and the types that CLR supports explicitly in the
* CLR Variant class.
*/
[System.Security.SecurityCritical] // auto-generated
internal static Variant ChangeType(Variant source, Type targetClass, short options, CultureInfo culture)
{
if (targetClass == null)
Expand Down Expand Up @@ -125,7 +124,6 @@ private static int GetCVTypeFromClass(Type ctype)

#region Private FCalls

[System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern void ChangeTypeEx(ref Variant result, ref Variant source, int lcid, IntPtr typeHandle, int cvType, short flags);

Expand Down
4 changes: 0 additions & 4 deletions src/mscorlib/src/Microsoft/Win32/Registry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace Microsoft.Win32 {
//This class contains only static members and does not need to be serializable.
[ComVisible(true)]
public static class Registry {
[System.Security.SecuritySafeCritical] // auto-generated
static Registry()
{
}
Expand Down Expand Up @@ -70,7 +69,6 @@ static Registry()
// If the keyName is not valid, we will throw ArgumentException.
// The return value shouldn't be null.
//
[System.Security.SecurityCritical] // auto-generated
private static RegistryKey GetBaseKeyFromKeyName(string keyName, out string subKeyName) {
if( keyName == null) {
throw new ArgumentNullException(nameof(keyName));
Expand Down Expand Up @@ -117,7 +115,6 @@ private static RegistryKey GetBaseKeyFromKeyName(string keyName, out string subK
return basekey;
}

[System.Security.SecuritySafeCritical] // auto-generated
public static object GetValue(string keyName, string valueName, object defaultValue ) {
string subKeyName;
RegistryKey basekey = GetBaseKeyFromKeyName(keyName, out subKeyName);
Expand All @@ -138,7 +135,6 @@ public static void SetValue(string keyName, string valueName, object value ) {
SetValue(keyName, valueName, value, RegistryValueKind.Unknown);
}

[System.Security.SecuritySafeCritical] // auto-generated
public static void SetValue(string keyName, string valueName, object value, RegistryValueKind valueKind ) {
string subKeyName;
RegistryKey basekey = GetBaseKeyFromKeyName(keyName, out subKeyName);
Expand Down
Loading