[openssh-commits] [openssh] 01/02: fix false positives when compiled with msan

git+noreply at mindrot.org git+noreply at mindrot.org
Tue Aug 16 13:37:29 AEST 2016


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit 74433a19bb6f4cef607680fa4d1d7d81ca3826aa
Author: Damien Miller <djm at mindrot.org>
Date:   Tue Aug 16 13:28:23 2016 +1000

    fix false positives when compiled with msan
    
    Our explicit_bzero successfully confused clang -fsanitize-memory
    in to thinking that memset is never called to initialise memory.
    Ensure that it is called in a way that the compiler recognises.
---
 openbsd-compat/explicit_bzero.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/openbsd-compat/explicit_bzero.c b/openbsd-compat/explicit_bzero.c
index 3c85a48..5078134 100644
--- a/openbsd-compat/explicit_bzero.c
+++ b/openbsd-compat/explicit_bzero.c
@@ -7,6 +7,8 @@
 
 #include "includes.h"
 
+#include <string.h>
+
 /*
  * explicit_bzero - don't let the compiler optimize away bzero
  */
@@ -32,6 +34,17 @@ static void (* volatile ssh_bzero)(void *, size_t) = bzero;
 void
 explicit_bzero(void *p, size_t n)
 {
+	/*
+	 * clang -fsanitize=memory needs to intercept memset-like functions
+	 * to correctly detect memory initialisation. Make sure one is called
+	 * directly since our indirection trick above sucessfully confuses it.
+	 */
+#if defined(__has_feature)
+# if __has_feature(memory_sanitizer)
+	memset(p, 0, n);
+# endif
+#endif
+
 	ssh_bzero(p, n);
 }
 

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list