[MDEV-20388] Allegedly uninitialized values left by MyCTX_nopad Created: 2019-08-19  Updated: 2023-06-12  Resolved: 2020-03-25

Status: Closed
Project: MariaDB Server
Component/s: Compiling
Affects Version/s: 10.4, 10.5
Fix Version/s: 10.4.13, 10.5.2

Type: Bug Priority: Major
Reporter: Marko Mäkelä Assignee: Vladislav Vaintroub
Resolution: Fixed Votes: 0
Labels: MSAN

Issue Links:
PartOf
is part of MDEV-20377 Make WITH_MSAN more usable Closed
Relates

 Description   

As noted in MDEV-20377, MyCTX_nopad is causing MemorySanitizer to report some uninitialized values. The following patch silences the errors, but I am not sure if that is safe to do, or if the buffer should actually be initialized:

diff --git a/mysys_ssl/my_crypt.cc b/mysys_ssl/my_crypt.cc
index 02770644259..cb9e60e4dc7 100644
--- a/mysys_ssl/my_crypt.cc
+++ b/mysys_ssl/my_crypt.cc
@@ -94,6 +94,8 @@ class MyCTX
   }
 };
 
+#include <sanitizer/msan_interface.h>
+
 class MyCTX_nopad : public MyCTX
 {
 public:
@@ -143,6 +145,7 @@ class MyCTX_nopad : public MyCTX
         of this class too.
       */
       uchar mask[MY_AES_BLOCK_SIZE];
+      __msan_unpoison(mask, sizeof mask);
       uint mlen;
 
       int rc= my_aes_crypt(MY_AES_ECB, ENCRYPTION_FLAG_ENCRYPT | ENCRYPTION_FLAG_NOPAD,

I used cmake -DWITH_SSL=bundled, which is WolfSSL starting with 10.4.
Note: this might affect earlier versions as well. I did not check it. I would like to be able to use MSAN starting with 10.2.



 Comments   
Comment by Vladislav Vaintroub [ 2020-03-25 ]

I disabled use of Intel assembly in WolfSSL when WITH_MSAN is used.

Generated at Thu Feb 08 08:59:05 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.