Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.2(EOL), 10.3(EOL), 10.4(EOL), 10.5
Description
As noted in MDEV-20377, inline assembler will cause MemorySanitizer to report false positives for uninitialized values. It would be more portable to use the compiler built-in functions not only on Windows, but on all platforms.
Here is a crude patch for WolfSSL:
diff --git a/wolfcrypt/src/random.c b/wolfcrypt/src/random.c
|
index 6b0d5dafc..817619d16 100644
|
--- a/wolfcrypt/src/random.c
|
+++ b/wolfcrypt/src/random.c
|
@@ -173,7 +173,7 @@ int wc_RNG_GenerateByte(WC_RNG* rng, byte* b)
|
static int wc_GenerateRand_IntelRD(OS_Seed* os, byte* output, word32 sz);
|
#endif
|
|
-#ifdef USE_WINDOWS_API
|
+#if 1 /*def USE_WINDOWS_API */
|
#include <immintrin.h>
|
#endif /* USE_WINDOWS_API */
|
#endif
|
@@ -1282,7 +1282,7 @@ int wc_FreeNetRandom(void)
|
|
#ifdef HAVE_INTEL_RDSEED
|
|
-#ifndef USE_WINDOWS_API
|
+#if 0/*ndef USE_WINDOWS_API*/
|
|
/* return 0 on success */
|
static WC_INLINE int IntelRDseed64(word64* seed)
|
@@ -1302,7 +1302,7 @@ int wc_FreeNetRandom(void)
|
{
|
int ok;
|
|
- ok = _rdseed64_step(seed);
|
+ ok = _rdseed64_step((unsigned long long*) seed);
|
return (ok) ? 0 : -1;
|
}
|
|
and another for InnoDB:
diff --git a/storage/innobase/ut/ut0crc32.cc b/storage/innobase/ut/ut0crc32.cc
|
index 4a6447c1dcf..58273e9058e 100644
|
--- a/storage/innobase/ut/ut0crc32.cc
|
+++ b/storage/innobase/ut/ut0crc32.cc
|
@@ -219,6 +219,8 @@ ut_crc32_8_hw(
|
{
|
#ifdef _MSC_VER
|
*crc = _mm_crc32_u8(*crc, (*data)[0]);
|
+#elif 1
|
+ *crc = __builtin_ia32_crc32qi(*crc, (*data)[0]);
|
#else
|
asm("crc32b %1, %0"
|
/* output operands */
|
@@ -251,6 +253,8 @@ ut_crc32_64_low_hw(
|
#else
|
#error Not Supported processors type.
|
#endif
|
+#elif 1
|
+ crc_64bit = __builtin_ia32_crc32di(crc_64bit, data);
|
#else
|
asm("crc32q %1, %0"
|
/* output operands */ |
Both these patches will require some compiler switches to enable the instructions to be emitted. For clang 8.0.1, -march=native did the trick for me, but that is obviously unacceptable. According to diagnostic messages from the compiler, the features might be called "rdseed" and "SSE 4.2".
Attachments
Issue Links
- is part of
-
MDEV-20377 Make WITH_MSAN more usable
- Closed
- relates to
-
MDEV-23663 HAVE_INTEL_RDRAND is not enabled in the bundled WolfSSL
- Closed
-
MDEV-24514 WITH_MSAN is disabling WOLFSSL_AESNI acceleration
- Closed
-
MDEV-23900 x86_32 fail to build on innodb crc32q
- Closed
- links to