]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Workaround false positive warning of MSAN in eng_rdrand.c
authorAntony Polukhin <antoshkka@gmail.com>
Tue, 6 Jun 2023 15:09:27 +0000 (18:09 +0300)
committerTomas Mraz <tomas@openssl.org>
Thu, 8 Jun 2023 09:29:02 +0000 (11:29 +0200)
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21136)

crypto/engine/eng_rdrand.c

index f46a5145974e62767d051d57c1b27133c191b01a..6245d68206be6cdc520518911b8cdbfa0f877edf 100644 (file)
 #include <openssl/err.h>
 #include <openssl/crypto.h>
 
+#if defined(__has_feature)
+# if __has_feature(memory_sanitizer)
+#  include <sanitizer/msan_interface.h>
+# endif
+#endif
+
 #if (defined(__i386)   || defined(__i386__)   || defined(_M_IX86) || \
      defined(__x86_64) || defined(__x86_64__) || \
      defined(_M_AMD64) || defined (_M_X64)) && defined(OPENSSL_CPUID_OBJ)
@@ -32,6 +38,16 @@ static int get_random_bytes(unsigned char *buf, int num)
         return 0;
     }
 
+# if defined(__has_feature)
+#  if __has_feature(memory_sanitizer)
+    /*
+     * MemorySanitizer fails to understand asm and produces false positive
+     * use-of-uninitialized-value warnings.
+     */
+    __msan_unpoison(buf, num);
+#  endif
+# endif
+
     return (size_t)num == OPENSSL_ia32_rdrand_bytes(buf, (size_t)num);
 }