Skip to content

Commit

Permalink
Merge in 'release/6.0' changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dotnet-bot committed Oct 19, 2023
2 parents a2858e6 + dfda651 commit d7b9518
Show file tree
Hide file tree
Showing 87 changed files with 33,775 additions and 3,699 deletions.
2 changes: 0 additions & 2 deletions NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
<clear />
<!--Begin: Package sources managed by Dependency Flow automation. Do not edit the sources below.-->
<!-- Begin: Package sources from dotnet-emsdk -->
<add key="darc-pub-dotnet-emsdk-f472bde" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-f472bde6/nuget/v3/index.json" />
<add key="darc-pub-dotnet-emsdk-0b73b53" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-0b73b536/nuget/v3/index.json" />
<!-- End: Package sources from dotnet-emsdk -->
<!-- Begin: Package sources from dotnet-wcf -->
<!-- End: Package sources from dotnet-wcf -->
Expand Down
6 changes: 3 additions & 3 deletions THIRD-PARTY-NOTICES.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ License notice for Zlib
-----------------------

https://github.com/madler/zlib
http://zlib.net/zlib_license.html
https://zlib.net/zlib_license.html

/* zlib.h -- interface of the 'zlib' general purpose compression library
version 1.2.11, January 15th, 2017
version 1.2.13, October 13th, 2022

Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler

This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
Expand Down
56 changes: 28 additions & 28 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.NETCore.Runtime.ICU.Transport" Version="6.0.0-rtm.23409.1">
<Dependency Name="Microsoft.NETCore.Runtime.ICU.Transport" Version="6.0.0-rtm.23512.2">
<Uri>https://github.com/dotnet/icu</Uri>
<Sha>0397ca2c2ed47ae1c490edde1fac14ec7200eb71</Sha>
<Sha>0a6b6dc4153f52a42dad0cf275e969c2bfaad1a2</Sha>
</Dependency>
<Dependency Name="System.Net.MsQuic.Transport" Version="6.0.0-servicing.22205.1">
<Uri>https://github.com/dotnet/msquic</Uri>
Expand Down Expand Up @@ -102,49 +102,49 @@
<Uri>https://github.com/microsoft/vstest</Uri>
<Sha>140434f7109d357d0158ade9e5164a4861513965</Sha>
</Dependency>
<Dependency Name="System.ComponentModel.TypeConverter.TestData" Version="6.0.0-beta.23502.2">
<Dependency Name="System.ComponentModel.TypeConverter.TestData" Version="6.0.0-beta.23512.1">
<Uri>https://github.com/dotnet/runtime-assets</Uri>
<Sha>cee46f91361cc16cb1b0e95f52c87f1f5600f2c7</Sha>
<Sha>982dfbc57db3a7ccd49e671ab1ca9779cc7070e5</Sha>
</Dependency>
<Dependency Name="System.Data.Common.TestData" Version="6.0.0-beta.23502.2">
<Dependency Name="System.Data.Common.TestData" Version="6.0.0-beta.23512.1">
<Uri>https://github.com/dotnet/runtime-assets</Uri>
<Sha>cee46f91361cc16cb1b0e95f52c87f1f5600f2c7</Sha>
<Sha>982dfbc57db3a7ccd49e671ab1ca9779cc7070e5</Sha>
</Dependency>
<Dependency Name="System.Drawing.Common.TestData" Version="6.0.0-beta.23502.2">
<Dependency Name="System.Drawing.Common.TestData" Version="6.0.0-beta.23512.1">
<Uri>https://github.com/dotnet/runtime-assets</Uri>
<Sha>cee46f91361cc16cb1b0e95f52c87f1f5600f2c7</Sha>
<Sha>982dfbc57db3a7ccd49e671ab1ca9779cc7070e5</Sha>
</Dependency>
<Dependency Name="System.IO.Compression.TestData" Version="6.0.0-beta.23502.2">
<Dependency Name="System.IO.Compression.TestData" Version="6.0.0-beta.23512.1">
<Uri>https://github.com/dotnet/runtime-assets</Uri>
<Sha>cee46f91361cc16cb1b0e95f52c87f1f5600f2c7</Sha>
<Sha>982dfbc57db3a7ccd49e671ab1ca9779cc7070e5</Sha>
</Dependency>
<Dependency Name="System.IO.Packaging.TestData" Version="6.0.0-beta.23502.2">
<Dependency Name="System.IO.Packaging.TestData" Version="6.0.0-beta.23512.1">
<Uri>https://github.com/dotnet/runtime-assets</Uri>
<Sha>cee46f91361cc16cb1b0e95f52c87f1f5600f2c7</Sha>
<Sha>982dfbc57db3a7ccd49e671ab1ca9779cc7070e5</Sha>
</Dependency>
<Dependency Name="System.Net.TestData" Version="6.0.0-beta.23502.2">
<Dependency Name="System.Net.TestData" Version="6.0.0-beta.23512.1">
<Uri>https://github.com/dotnet/runtime-assets</Uri>
<Sha>cee46f91361cc16cb1b0e95f52c87f1f5600f2c7</Sha>
<Sha>982dfbc57db3a7ccd49e671ab1ca9779cc7070e5</Sha>
</Dependency>
<Dependency Name="System.Private.Runtime.UnicodeData" Version="6.0.0-beta.23502.2">
<Dependency Name="System.Private.Runtime.UnicodeData" Version="6.0.0-beta.23512.1">
<Uri>https://github.com/dotnet/runtime-assets</Uri>
<Sha>cee46f91361cc16cb1b0e95f52c87f1f5600f2c7</Sha>
<Sha>982dfbc57db3a7ccd49e671ab1ca9779cc7070e5</Sha>
</Dependency>
<Dependency Name="System.Runtime.TimeZoneData" Version="6.0.0-beta.23502.2">
<Dependency Name="System.Runtime.TimeZoneData" Version="6.0.0-beta.23512.1">
<Uri>https://github.com/dotnet/runtime-assets</Uri>
<Sha>cee46f91361cc16cb1b0e95f52c87f1f5600f2c7</Sha>
<Sha>982dfbc57db3a7ccd49e671ab1ca9779cc7070e5</Sha>
</Dependency>
<Dependency Name="System.Security.Cryptography.X509Certificates.TestData" Version="6.0.0-beta.23502.2">
<Dependency Name="System.Security.Cryptography.X509Certificates.TestData" Version="6.0.0-beta.23512.1">
<Uri>https://github.com/dotnet/runtime-assets</Uri>
<Sha>cee46f91361cc16cb1b0e95f52c87f1f5600f2c7</Sha>
<Sha>982dfbc57db3a7ccd49e671ab1ca9779cc7070e5</Sha>
</Dependency>
<Dependency Name="System.Windows.Extensions.TestData" Version="6.0.0-beta.23502.2">
<Dependency Name="System.Windows.Extensions.TestData" Version="6.0.0-beta.23512.1">
<Uri>https://github.com/dotnet/runtime-assets</Uri>
<Sha>cee46f91361cc16cb1b0e95f52c87f1f5600f2c7</Sha>
<Sha>982dfbc57db3a7ccd49e671ab1ca9779cc7070e5</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.CilStrip.Sources" Version="6.0.0-beta.23502.2">
<Dependency Name="Microsoft.DotNet.CilStrip.Sources" Version="6.0.0-beta.23512.1">
<Uri>https://github.com/dotnet/runtime-assets</Uri>
<Sha>cee46f91361cc16cb1b0e95f52c87f1f5600f2c7</Sha>
<Sha>982dfbc57db3a7ccd49e671ab1ca9779cc7070e5</Sha>
</Dependency>
<Dependency Name="runtime.linux-arm64.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk" Version="11.1.0-alpha.1.21416.1">
<Uri>https://github.com/dotnet/llvm-project</Uri>
Expand Down Expand Up @@ -242,13 +242,13 @@
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-optimization</Uri>
<Sha>d50065944d8b41d804448a7056351481d583ad3d</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.HotReload.Utils.Generator.BuildTool" Version="6.0.0-alpha.0.23411.2">
<Dependency Name="Microsoft.DotNet.HotReload.Utils.Generator.BuildTool" Version="6.0.0-alpha.0.23512.1">
<Uri>https://github.com/dotnet/hotreload-utils</Uri>
<Sha>dd752be1a2fa9ea5c55fbbf1e28dc65902b3a476</Sha>
<Sha>86bddcfcc07cdbfb62df4b3068f606602919a786</Sha>
</Dependency>
<Dependency Name="System.Runtime.Numerics.TestData" Version="6.0.0-beta.23502.2">
<Dependency Name="System.Runtime.Numerics.TestData" Version="6.0.0-beta.23512.1">
<Uri>https://github.com/dotnet/runtime-assets</Uri>
<Sha>cee46f91361cc16cb1b0e95f52c87f1f5600f2c7</Sha>
<Sha>982dfbc57db3a7ccd49e671ab1ca9779cc7070e5</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0-rc1.21413.4">
<Uri>https://github.com/dotnet/roslyn-analyzers</Uri>
Expand Down
26 changes: 13 additions & 13 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,18 @@
<SystemValueTupleVersion>4.5.0</SystemValueTupleVersion>
<runtimenativeSystemIOPortsVersion>6.0.0-rc.1.21415.6</runtimenativeSystemIOPortsVersion>
<!-- Runtime-Assets dependencies -->
<SystemRuntimeNumericsTestDataVersion>6.0.0-beta.23502.2</SystemRuntimeNumericsTestDataVersion>
<SystemComponentModelTypeConverterTestDataVersion>6.0.0-beta.23502.2</SystemComponentModelTypeConverterTestDataVersion>
<SystemDataCommonTestDataVersion>6.0.0-beta.23502.2</SystemDataCommonTestDataVersion>
<SystemDrawingCommonTestDataVersion>6.0.0-beta.23502.2</SystemDrawingCommonTestDataVersion>
<SystemIOCompressionTestDataVersion>6.0.0-beta.23502.2</SystemIOCompressionTestDataVersion>
<SystemIOPackagingTestDataVersion>6.0.0-beta.23502.2</SystemIOPackagingTestDataVersion>
<SystemNetTestDataVersion>6.0.0-beta.23502.2</SystemNetTestDataVersion>
<SystemPrivateRuntimeUnicodeDataVersion>6.0.0-beta.23502.2</SystemPrivateRuntimeUnicodeDataVersion>
<SystemRuntimeTimeZoneDataVersion>6.0.0-beta.23502.2</SystemRuntimeTimeZoneDataVersion>
<SystemSecurityCryptographyX509CertificatesTestDataVersion>6.0.0-beta.23502.2</SystemSecurityCryptographyX509CertificatesTestDataVersion>
<SystemWindowsExtensionsTestDataVersion>6.0.0-beta.23502.2</SystemWindowsExtensionsTestDataVersion>
<MicrosoftDotNetCilStripSourcesVersion>6.0.0-beta.23502.2</MicrosoftDotNetCilStripSourcesVersion>
<SystemRuntimeNumericsTestDataVersion>6.0.0-beta.23512.1</SystemRuntimeNumericsTestDataVersion>
<SystemComponentModelTypeConverterTestDataVersion>6.0.0-beta.23512.1</SystemComponentModelTypeConverterTestDataVersion>
<SystemDataCommonTestDataVersion>6.0.0-beta.23512.1</SystemDataCommonTestDataVersion>
<SystemDrawingCommonTestDataVersion>6.0.0-beta.23512.1</SystemDrawingCommonTestDataVersion>
<SystemIOCompressionTestDataVersion>6.0.0-beta.23512.1</SystemIOCompressionTestDataVersion>
<SystemIOPackagingTestDataVersion>6.0.0-beta.23512.1</SystemIOPackagingTestDataVersion>
<SystemNetTestDataVersion>6.0.0-beta.23512.1</SystemNetTestDataVersion>
<SystemPrivateRuntimeUnicodeDataVersion>6.0.0-beta.23512.1</SystemPrivateRuntimeUnicodeDataVersion>
<SystemRuntimeTimeZoneDataVersion>6.0.0-beta.23512.1</SystemRuntimeTimeZoneDataVersion>
<SystemSecurityCryptographyX509CertificatesTestDataVersion>6.0.0-beta.23512.1</SystemSecurityCryptographyX509CertificatesTestDataVersion>
<SystemWindowsExtensionsTestDataVersion>6.0.0-beta.23512.1</SystemWindowsExtensionsTestDataVersion>
<MicrosoftDotNetCilStripSourcesVersion>6.0.0-beta.23512.1</MicrosoftDotNetCilStripSourcesVersion>
<!-- dotnet-optimization dependencies -->
<optimizationwindows_ntx64MIBCRuntimeVersion>1.0.0-prerelease.21416.5</optimizationwindows_ntx64MIBCRuntimeVersion>
<optimizationwindows_ntx86MIBCRuntimeVersion>1.0.0-prerelease.21416.5</optimizationwindows_ntx86MIBCRuntimeVersion>
Expand Down Expand Up @@ -163,7 +163,7 @@
<MicrosoftNETILLinkTasksVersion>6.0.100-1.21459.1</MicrosoftNETILLinkTasksVersion>
<MicrosoftNETILLinkAnalyzerPackageVersion>$(MicrosoftNETILLinkTasksVersion)</MicrosoftNETILLinkAnalyzerPackageVersion>
<!-- ICU -->
<MicrosoftNETCoreRuntimeICUTransportVersion>6.0.0-rtm.23409.1</MicrosoftNETCoreRuntimeICUTransportVersion>
<MicrosoftNETCoreRuntimeICUTransportVersion>6.0.0-rtm.23512.2</MicrosoftNETCoreRuntimeICUTransportVersion>
<!-- MsQuic -->
<SystemNetMsQuicTransportVersion>6.0.0-servicing.22205.1</SystemNetMsQuicTransportVersion>
<!-- Mono LLVM -->
Expand Down
9 changes: 4 additions & 5 deletions src/libraries/Native/AnyOS/zlib/pal_zlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
#define c_static_assert(e) static_assert((e),"")
#endif

#if defined(_WIN32) || defined(__EMSCRIPTEN__)
#ifdef INTERNAL_ZLIB_INTEL
#include "../../Windows/System.IO.Compression.Native/zlib-intel/zlib.h"
#elif defined(_WIN32) || defined(__EMSCRIPTEN__)
#include "../../Windows/System.IO.Compression.Native/zlib/zlib.h"
#else
#include "pal_utilities.h"
Expand Down Expand Up @@ -40,14 +42,11 @@ Initializes the PAL_ZStream by creating and setting its underlying z_stream.
*/
static int32_t Init(PAL_ZStream* stream)
{
z_stream* zStream = (z_stream*)malloc(sizeof(z_stream));
z_stream* zStream = (z_stream*)calloc(1, sizeof(z_stream));
stream->internalState = zStream;

if (zStream != NULL)
{
zStream->zalloc = Z_NULL;
zStream->zfree = Z_NULL;
zStream->opaque = Z_NULL;
return PAL_Z_OK;
}
else
Expand Down
201 changes: 201 additions & 0 deletions src/libraries/Native/AnyOS/zlib/zlib_allocator_unix.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#include <stdbool.h>
#include <stdint.h>
#include "../../Windows/System.IO.Compression.Native/zlib/zutil.h"

/* A custom allocator for zlib that provides some defense-in-depth over standard malloc / free.
* (non-Windows version)
*
* 1. When zlib allocates fixed-length data structures for containing stream metadata, we zero
* the memory before using it, preventing use of uninitialized memory within these structures.
* Ideally we would do this for dynamically-sized buffers as well, but there is a measurable
* perf impact to doing this. Zeroing fixed structures seems like a good trade-off here, since
* these data structures contain most of the metadata used for managing the variable-length
* dynamically allocated buffers.
*
* 2. We put a cookie both before and after any allocated memory, which allows us to detect local
* buffer overruns on the call to free(). The cookie values are tied to the addresses where
* the data is located in memory.
*
* 3. We trash the aforementioned cookie on free(), which allows us to detect double-free.
*
* If any of these checks fails, the application raises SIGABRT.
*/

static bool IsMitigationDisabled()
{
enum _MitigationEnablementTristate
{
MITIGATION_NOT_YET_QUERIED = 0,
MITIGATION_DISABLED = 1,
MITIGATION_ENABLED = 2 // really, anything other than 0 or 1
};
static int s_fMitigationEnablementState = MITIGATION_NOT_YET_QUERIED;

// If already initialized, return immediately.
// We don't need a volatile read here since the publish is performed with release semantics.
if (s_fMitigationEnablementState != MITIGATION_NOT_YET_QUERIED)
{
return (s_fMitigationEnablementState == MITIGATION_DISABLED);
}

// Initialize the tri-state now.
// It's ok for multiple threads to do this simultaneously. Only one thread will win.
// Valid env var values to disable mitigation: "true" and "1"
// All other env var values (or error) leaves mitigation enabled.

char* pchEnvVar = getenv("DOTNET_SYSTEM_IO_COMPRESSION_DISABLEZLIBMITIGATIONS");
bool fMitigationDisabled = (pchEnvVar && (strcmp(pchEnvVar, "1") == 0 || strcmp(pchEnvVar, "true") == 0));

// We really don't care about the return value of the ICE operation. If another thread
// beat us to it, so be it. The recursive call will figure it out.
__sync_val_compare_and_swap(
/* destination: */ &s_fMitigationEnablementState,
/* comparand: */ MITIGATION_NOT_YET_QUERIED,
/* exchange: */ fMitigationDisabled ? MITIGATION_DISABLED : MITIGATION_ENABLED);
return IsMitigationDisabled();
}

#ifndef MEMORY_ALLOCATION_ALIGNMENT
// malloc() returns an address suitably aligned for any built-in data type.
// Historically, this has been twice the arch's natural word size.
#ifdef HOST_64BIT
#define MEMORY_ALLOCATION_ALIGNMENT 16
#else
#define MEMORY_ALLOCATION_ALIGNMENT 8
#endif
#endif

typedef struct _DOTNET_ALLOC_COOKIE
{
void* Address;
size_t Size;
} DOTNET_ALLOC_COOKIE;

static bool SafeAdd(size_t a, size_t b, size_t* sum)
{
if (SIZE_MAX - a >= b) { *sum = a + b; return true; }
else { *sum = 0; return false; }
}

static bool SafeMult(size_t a, size_t b, size_t* product)
{
if (SIZE_MAX / a >= b) { *product = a * b; return true; }
else { *product = 0; return false; }
}

static DOTNET_ALLOC_COOKIE ReadAllocCookieUnaligned(const void* pSrc)
{
DOTNET_ALLOC_COOKIE vCookie;
memcpy(&vCookie, pSrc, sizeof(DOTNET_ALLOC_COOKIE));
return vCookie;
}

static void WriteAllocCookieUnaligned(void* pDest, DOTNET_ALLOC_COOKIE vCookie)
{
memcpy(pDest, &vCookie, sizeof(DOTNET_ALLOC_COOKIE));
}

// Historically, the memory allocator always returns addresses aligned to some
// particular boundary. We'll make that same guarantee here just in case somebody
// depends on it.
const size_t DOTNET_ALLOC_HEADER_COOKIE_SIZE_WITH_PADDING = (sizeof(DOTNET_ALLOC_COOKIE) + MEMORY_ALLOCATION_ALIGNMENT - 1) & ~((size_t)MEMORY_ALLOCATION_ALIGNMENT - 1);
const size_t DOTNET_ALLOC_TRAILER_COOKIE_SIZE = sizeof(DOTNET_ALLOC_COOKIE);

voidpf ZLIB_INTERNAL zcalloc(opaque, items, size)
voidpf opaque;
unsigned items;
unsigned size;
{
(void)opaque; // unreferenced formal parameter

if (IsMitigationDisabled())
{
// fallback logic copied from zutil.c
return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
(voidpf)calloc(items, size);
}

// If initializing a fixed-size structure, zero the memory.
bool fZeroMemory = (items == 1);

size_t cbRequested;
if (sizeof(items) + sizeof(size) <= sizeof(cbRequested))
{
// multiplication can't overflow; no need for safeint
cbRequested = (size_t)items * (size_t)size;
}
else
{
// multiplication can overflow; go through safeint
if (!SafeMult((size_t)items, (size_t)size, &cbRequested)) { return NULL; }
}

// Make sure the actual allocation has enough room for our frontside & backside cookies.
size_t cbActualAllocationSize;
if (!SafeAdd(cbRequested, DOTNET_ALLOC_HEADER_COOKIE_SIZE_WITH_PADDING + DOTNET_ALLOC_TRAILER_COOKIE_SIZE, &cbActualAllocationSize)) { return NULL; }

void* pAlloced = (fZeroMemory) ? calloc(1, cbActualAllocationSize) : malloc(cbActualAllocationSize);
if (pAlloced == NULL) { return NULL; } // OOM

DOTNET_ALLOC_COOKIE* pHeaderCookie = (DOTNET_ALLOC_COOKIE*)pAlloced;
uint8_t* pReturnToCaller = (uint8_t*)pAlloced + DOTNET_ALLOC_HEADER_COOKIE_SIZE_WITH_PADDING;
uint8_t* pTrailerCookie = pReturnToCaller + cbRequested;

// Write out the same cookie for the header & the trailer, then we're done.

DOTNET_ALLOC_COOKIE vCookie = { 0 };
vCookie.Address = pReturnToCaller;
vCookie.Size = cbRequested;
*pHeaderCookie = vCookie; // aligned
WriteAllocCookieUnaligned(pTrailerCookie, vCookie);

return pReturnToCaller;
}

static void zcfree_trash_cookie(void* pCookie)
{
memset(pCookie, 0, sizeof(DOTNET_ALLOC_COOKIE));
}

void ZLIB_INTERNAL zcfree(opaque, ptr)
voidpf opaque;
voidpf ptr;
{
(void)opaque; // unreferenced formal parameter

if (IsMitigationDisabled())
{
// fallback logic copied from zutil.c
free(ptr);
return;
}

if (ptr == NULL) { return; } // ok to free nullptr

// Check cookie at beginning

DOTNET_ALLOC_COOKIE* pHeaderCookie = (DOTNET_ALLOC_COOKIE*)((uint8_t*)ptr - DOTNET_ALLOC_HEADER_COOKIE_SIZE_WITH_PADDING);
if (pHeaderCookie->Address != ptr) { goto Fail; }
size_t cbRequested = pHeaderCookie->Size;

// Check cookie at end

uint8_t* pTrailerCookie = (uint8_t*)ptr + cbRequested;
DOTNET_ALLOC_COOKIE vTrailerCookie = ReadAllocCookieUnaligned(pTrailerCookie);
if (vTrailerCookie.Address != ptr) { goto Fail; }
if (vTrailerCookie.Size != cbRequested) { goto Fail; }

// Checks passed - now trash the cookies and free memory

zcfree_trash_cookie(pHeaderCookie);
zcfree_trash_cookie(pTrailerCookie);

free(pHeaderCookie);
return;

Fail:
abort(); // cookie check failed
}
Loading

0 comments on commit d7b9518

Please sign in to comment.