[*] Fixed missed and double mimalloc init, via allocation under SwInfo, being probed by alternative nt clock query logic, under the fallback rng algorithm, possibly under another tls thread_only race condition
This commit is contained in:
parent
48c2175be9
commit
f798c59cb8
@ -114,14 +114,6 @@ namespace Aurora::RNG
|
|||||||
|
|
||||||
static AuUInt32 RngWin32(AuUInt8 *pBuf, AuUInt32 uLen)
|
static AuUInt32 RngWin32(AuUInt8 *pBuf, AuUInt32 uLen)
|
||||||
{
|
{
|
||||||
if (pRtlGenRandom)
|
|
||||||
{
|
|
||||||
if (pRtlGenRandom(pBuf, uLen))
|
|
||||||
{
|
|
||||||
return uLen;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pBCryptGenRandom)
|
if (pBCryptGenRandom)
|
||||||
{
|
{
|
||||||
if (AuSwInfo::IsWindows10OrGreater() ||
|
if (AuSwInfo::IsWindows10OrGreater() ||
|
||||||
@ -133,11 +125,21 @@ namespace Aurora::RNG
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pRtlGenRandom(pBuf, uLen))
|
||||||
|
{
|
||||||
|
return uLen;
|
||||||
|
}
|
||||||
|
|
||||||
if (pBCryptGenRandom(NULL, reinterpret_cast<PUCHAR>(pBuf), uLen, BCRYPT_USE_SYSTEM_PREFERRED_RNG) == 0)
|
if (pBCryptGenRandom(NULL, reinterpret_cast<PUCHAR>(pBuf), uLen, BCRYPT_USE_SYSTEM_PREFERRED_RNG) == 0)
|
||||||
{
|
{
|
||||||
return uLen;
|
return uLen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (pRtlGenRandom &&
|
||||||
|
pRtlGenRandom(pBuf, uLen))
|
||||||
|
{
|
||||||
|
return uLen;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(AURORA_RNG_HAS_OLD_WINCRYPT)
|
#if defined(AURORA_RNG_HAS_OLD_WINCRYPT)
|
||||||
if (gCryptoProv)
|
if (gCryptoProv)
|
||||||
@ -169,7 +171,7 @@ namespace Aurora::RNG
|
|||||||
static AuUInt64 gTimeHolder;
|
static AuUInt64 gTimeHolder;
|
||||||
static AuUInt64 gTime = (gTimeHolder = AuTime::SteadyClockJiffies()) >= 10'000'000ull ?
|
static AuUInt64 gTime = (gTimeHolder = AuTime::SteadyClockJiffies()) >= 10'000'000ull ?
|
||||||
1 :
|
1 :
|
||||||
AuPageRoundUp<AuUInt64>((10'000'000ull / gTimeHolder), 1024);
|
AuPageRoundUp<AuUInt64>(10'000'000ull, 1024) / gTimeHolder;
|
||||||
return AuTime::SteadyClockNS() * gTime / 10'000ull;
|
return AuTime::SteadyClockNS() * gTime / 10'000ull;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -88,13 +88,11 @@ namespace Aurora::SWInfo
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void InitNTInfo(OSInformation &osInfo)
|
void InitNTInfoNoAllocate(OSInformation &osInfo)
|
||||||
{
|
{
|
||||||
OSVERSIONINFOEX info {};
|
OSVERSIONINFOEX info {};
|
||||||
info.dwOSVersionInfoSize = sizeof(info);
|
info.dwOSVersionInfoSize = sizeof(info);
|
||||||
|
|
||||||
osInfo = AuMove(OSInformation(&gKernelString, &gUserlandBrand, &gUserlandDesktopEnv, &gBuildString, Aurora::Build::EPlatform::eEnumInvalid));
|
|
||||||
|
|
||||||
#if defined(AURORA_PLATFORM_WIN32)
|
#if defined(AURORA_PLATFORM_WIN32)
|
||||||
Win32SetIsServer(osInfo);
|
Win32SetIsServer(osInfo);
|
||||||
osInfo.bIsEnterprise = osInfo.bIsServer;//IsWindowsEnterpriseBranch();
|
osInfo.bIsEnterprise = osInfo.bIsServer;//IsWindowsEnterpriseBranch();
|
||||||
@ -103,8 +101,6 @@ namespace Aurora::SWInfo
|
|||||||
osInfo.bIsEnterprise = false;
|
osInfo.bIsEnterprise = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gUserlandDesktopEnv = "Desktop Window Manager";
|
|
||||||
|
|
||||||
if (GetVersionExA(reinterpret_cast<LPOSVERSIONINFOA>(&info)))
|
if (GetVersionExA(reinterpret_cast<LPOSVERSIONINFOA>(&info)))
|
||||||
{
|
{
|
||||||
osInfo.uKernelPatch = info.dwBuildNumber;
|
osInfo.uKernelPatch = info.dwBuildNumber;
|
||||||
@ -131,7 +127,18 @@ namespace Aurora::SWInfo
|
|||||||
osInfo.uUserlandMinor = ovi.wServicePackMajor;
|
osInfo.uUserlandMinor = ovi.wServicePackMajor;
|
||||||
osInfo.uUserlandPatch = ovi.wServicePackMinor;
|
osInfo.uUserlandPatch = ovi.wServicePackMinor;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitNTInfo(OSInformation &osInfo)
|
||||||
|
{
|
||||||
|
osInfo = AuMove(OSInformation(&gKernelString, &gUserlandBrand, &gUserlandDesktopEnv, &gBuildString, Aurora::Build::EPlatform::eEnumInvalid));
|
||||||
|
|
||||||
|
InitNTInfoNoAllocate(osInfo);
|
||||||
|
|
||||||
|
gUserlandDesktopEnv = "Desktop Window Manager";
|
||||||
|
|
||||||
|
#if defined(AURORA_PLATFORM_WIN32)
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
|
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
|
@ -10,4 +10,5 @@
|
|||||||
namespace Aurora::SWInfo
|
namespace Aurora::SWInfo
|
||||||
{
|
{
|
||||||
void InitNTInfo(OSInformation &info);
|
void InitNTInfo(OSInformation &info);
|
||||||
|
void InitNTInfoNoAllocate(OSInformation &info);
|
||||||
}
|
}
|
@ -30,6 +30,7 @@ namespace Aurora::SWInfo
|
|||||||
|
|
||||||
AUKN_SYM const OSInformation &GetPlatformInfo()
|
AUKN_SYM const OSInformation &GetPlatformInfo()
|
||||||
{
|
{
|
||||||
|
SysAssert(gInfo, "No Platform Information Initialized");
|
||||||
return *gInfo;
|
return *gInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,4 +49,13 @@ namespace Aurora::SWInfo
|
|||||||
gTempInfo.ePlatform = Build::kCurrentPlatform;
|
gTempInfo.ePlatform = Build::kCurrentPlatform;
|
||||||
gInfo = &gTempInfo;
|
gInfo = &gTempInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InitSwInfoEarly()
|
||||||
|
{
|
||||||
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||||
|
InitNTInfoNoAllocate(gTempInfo);
|
||||||
|
gTempInfo.ePlatform = Build::kCurrentPlatform;
|
||||||
|
gInfo = &gTempInfo;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
@ -10,4 +10,5 @@
|
|||||||
namespace Aurora::SWInfo
|
namespace Aurora::SWInfo
|
||||||
{
|
{
|
||||||
void InitSwInfo();
|
void InitSwInfo();
|
||||||
|
void InitSwInfoEarly();
|
||||||
}
|
}
|
@ -133,7 +133,7 @@
|
|||||||
gInitOnce.Call([]
|
gInitOnce.Call([]
|
||||||
{
|
{
|
||||||
Aurora::InitNTAddresses();
|
Aurora::InitNTAddresses();
|
||||||
AuSwInfo::InitSwInfo();
|
AuSwInfo::InitSwInfoEarly();
|
||||||
|
|
||||||
if constexpr (AuBuild::kCurrentPlatform == AuBuild::EPlatform::ePlatformWin32)
|
if constexpr (AuBuild::kCurrentPlatform == AuBuild::EPlatform::ePlatformWin32)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user