Disable RTLD_DEEPBIND under memory sanitizer
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 28 Jun 2019 16:15:38 +0000 (18:15 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 1 Jul 2019 07:37:34 +0000 (09:37 +0200)
This was already done for address sanitizer.

Zend/zend_cpuinfo.h
Zend/zend_portability.h

index 009944e7129d97d9626e81d4f9520e2b9fbaca69..c0949e363862dcb8131c614c1654cf8b9d57fd24 100644 (file)
@@ -103,9 +103,6 @@ ZEND_API int zend_cpu_supports(zend_cpu_feature feature);
 #ifndef __has_attribute
 # define __has_attribute(x) 0
 #endif
-#ifndef __has_feature
-# define __has_feature(x) 0
-#endif
 
 /* Address sanitizer is incompatible with ifunc resolvers, so exclude the
  * CPU support helpers from asan.
index 9416a362e3636a1f27d30473bd234bcc58b1d400..89173642d2250f997c56732164abc426576c3ff5 100644 (file)
@@ -86,6 +86,9 @@
 #ifndef __has_builtin
 # define __has_builtin(x) 0
 #endif
+#ifndef __has_feature
+# define __has_feature(x) 0
+#endif
 
 #if defined(ZEND_WIN32) && !defined(__clang__)
 # define ZEND_ASSUME(c)        __assume(c)
 
 #if defined(HAVE_LIBDL) && !defined(ZEND_WIN32)
 
-# if defined(__has_feature)
-#  if __has_feature(address_sanitizer)
-#   define __SANITIZE_ADDRESS__
-#  endif
+# if __has_feature(address_sanitizer)
+#  define __SANITIZE_ADDRESS__
 # endif
 
 # ifndef RTLD_LAZY
 
 # if defined(RTLD_GROUP) && defined(RTLD_WORLD) && defined(RTLD_PARENT)
 #  define DL_LOAD(libname)                     dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_GROUP | RTLD_WORLD | RTLD_PARENT)
-# elif defined(RTLD_DEEPBIND) && !defined(__SANITIZE_ADDRESS__)
+# elif defined(RTLD_DEEPBIND) && !defined(__SANITIZE_ADDRESS__) && !__has_feature(memory_sanitizer)
 #  define DL_LOAD(libname)                     dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_DEEPBIND)
 # else
 #  define DL_LOAD(libname)                     dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL)
@@ -526,10 +527,8 @@ static zend_always_inline double _zend_get_nan(void) /* {{{ */
 
 /* Memory sanitizer is incompatible with ifunc resolvers. Even if the resolver
  * is marked as no_sanitize("memory") it will still be instrumented and crash. */
-#if defined(__has_feature)
-# if __has_feature(memory_sanitizer)
-#  undef HAVE_FUNC_ATTRIBUTE_IFUNC
-# endif
+#if __has_feature(memory_sanitizer)
+# undef HAVE_FUNC_ATTRIBUTE_IFUNC
 #endif
 
 #if defined(HAVE_FUNC_ATTRIBUTE_IFUNC) && defined(HAVE_FUNC_ATTRIBUTE_TARGET)