<div dir="ltr">Hi Peter,<div><br></div><div>Thanks so much for your help, again!</div><div><br></div><div class="gmail_extra"><div class="gmail_quote">On Mon, May 26, 2014 at 8:32 PM, Peter Collingbourne <span dir="ltr"><<a href="mailto:peter@pcc.me.uk" target="_blank">peter@pcc.me.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div>On Thu, May 22, 2014 at 05:45:55PM -0500, Frederico Araujo wrote:<br>
> Hi,<br>
><br>
> I've tried to compile Apache Httpd (and several other open source projects)<br>
> with clang using the dataflow sanitizer. I set the CC environment variable<br>
> to point to my clang installation and I specified the "-fsanitize=dataflow"<br>
> in the CFLAGS and/or LDFLAGS environment variables.<br>
<br>
</div>FWIW, I normally set CC to "clang -fsanitize=foo" when I want to use a<br>
sanitizer.<br>
<div><br>
> However, the configure script fails when running its C compiler tests (in<br>
> Apache's case, the first problem occurs for the APR library). The following<br>
> is an excerpt of the config.log output:<br>
><br>
> (...)<br>
> configure:5409: checking whether the C compiler works<br>
> configure:5431: /usr/local/llvm/build/Debug+Asserts/bin/clang<br>
> -fsanitize=dataflow conftest.c >&5<br>
<br>
</div>This path name would appear to indicate that you are building LLVM/Clang<br>
with the makefiles. As I mentioned before, this doesn't work well at the<br>
moment with dfsan (sorry). Can you please try building LLVM/Clang with CMake?<br>
<div><br></div></blockquote><div> </div><div>Thank you, I just figured out that I was mistakenly using my old version of compiler-rt (the one built with gnu configure/make). I think I got confused with my own tests and I'm deeply sorry for this. However, although I'm now able to compile nginx with dfsan, I still have a problem when compiling Apache httpd (specifically Apache APR, a library used by Apache httpd). Here is the error I got from running make:</div>
<div><br></div><div>clang -fsanitize=dataflow -lssl -lcrypto -lcrypt -lpthread \</div><div><span style="white-space:pre-wrap"> </span> -fsanitize=dataflow -o ab ab.lo /home/frederico/dev/tests/llvm/httpd-2.4.6/srclib/apr-util/<a href="http://libaprutil-1.la" target="_blank">libaprutil-1.la</a> /home/frederico/dev/tests/llvm/httpd-2.4.6/srclib/apr-util/xml/expat/<a href="http://libexpat.la" target="_blank">libexpat.la</a> /home/frederico/dev/tests/llvm/httpd-2.4.6/srclib/apr/<a href="http://libapr-1.la" target="_blank">libapr-1.la</a> -lcrypt -lpthread </div>
<div>ab.o: In function `main':</div><div>ab.c:(.text+0xa1): undefined reference to `dfs$SSLv23_client_method'</div><div>ab.c:(.text+0x2cb7): undefined reference to `dfs$SSLv23_client_method'</div><div>ab.c:(.text+0x2da1): undefined reference to `dfs$SSLv3_client_method'</div>
<div>ab.c:(.text+0x2e8b): undefined reference to `dfs$TLSv1_1_client_method'</div><div>ab.c:(.text+0x2f75): undefined reference to `dfs$TLSv1_2_client_method'</div><div>ab.c:(.text+0x305f): undefined reference to `dfs$TLSv1_client_method'</div>
<div>ab.c:(.text+0x45f9): undefined reference to `dfs$CRYPTO_set_mem_functions'</div><div>ab.c:(.text+0x4604): undefined reference to `dfs$SSL_load_error_strings'</div><div>ab.c:(.text+0x4609): undefined reference to `dfs$SSL_library_init'</div>
<div>ab.c:(.text+0x46d5): undefined reference to `dfs$BIO_new_fp'</div><div>ab.c:(.text+0x479c): undefined reference to `dfs$BIO_new_fp'</div><div>ab.c:(.text+0x47fa): undefined reference to `dfs$SSL_CTX_new'</div>
<div>ab.c:(.text+0x48af): undefined reference to `dfs$BIO_printf'</div><div>ab.c:(.text+0x4921): undefined reference to `dfs$ERR_print_errors'</div><div>ab.c:(.text+0x49d5): undefined reference to `dfs$SSL_CTX_ctrl'</div>
<div>ab.c:(.text+0x4a7c): undefined reference to `dfs$SSL_CTX_ctrl'</div><div>ab.c:(.text+0x4bcd): undefined reference to `dfs$SSL_CTX_set_cipher_list'</div><div>ab.c:(.text+0x4d10): undefined reference to `dfs$ERR_print_errors_fp'</div>
<div>ab.c:(.text+0x4df7): undefined reference to `dfs$SSL_CTX_set_info_callback'</div><div>ab.o: In function `dfs$ssl_state_cb':</div><div>ab.c:(.text+0xb74c): undefined reference to `dfs$SSL_alert_type_string_long'</div>
<div>ab.c:(.text+0xb766): undefined reference to `dfs$SSL_alert_desc_string_long'</div><div>ab.c:(.text+0xb795): undefined reference to `dfs$BIO_printf'</div><div>ab.c:(.text+0xb842): undefined reference to `dfs$SSL_state'</div>
<div>ab.c:(.text+0xb878): undefined reference to `dfs$SSL_state_string_long'</div><div>ab.c:(.text+0xb8b0): undefined reference to `dfs$BIO_printf'</div><div>ab.c:(.text+0xb98d): undefined reference to `dfs$SSL_state_string_long'</div>
<div>ab.c:(.text+0xb9c7): undefined reference to `dfs$BIO_printf'</div><div>(...) </div><div><br></div><div>This suggests to me that I also have to compile OpenSSL using dfsan. So, I tried to compile it with calng + dfsan, without success:</div>
<div><br></div><div><div>make[2]: Entering directory `/home/frederico/dev/tests/llvm/openssl/apps'</div><div>( :; LIBDEPS="${LIBDEPS:--L.. -lssl -L.. -lcrypto -ldl}"; LDCMD="${LDCMD:-clang -fsanitize=dataflow}"; LDFLAGS="${LDFLAGS:--DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -m64 -DL_ENDIAN -DTERMIO -O3 -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM}"; LIBPATH=`for x in $LIBDEPS; do echo $x; done | sed -e 's/^ *-L//;t' -e d | uniq`; LIBPATH=`echo $LIBPATH | sed -e 's/ /:/g'`; LD_LIBRARY_PATH=$LIBPATH:$LD_LIBRARY_PATH ${LDCMD} ${LDFLAGS} -o ${APPNAME:=openssl} openssl.o verify.o asn1pars.o req.o dgst.o dh.o dhparam.o enc.o passwd.o gendh.o errstr.o ca.o pkcs7.o crl2p7.o crl.o rsa.o rsautl.o dsa.o dsaparam.o ec.o ecparam.o x509.o genrsa.o gendsa.o genpkey.o s_server.o s_client.o speed.o s_time.o apps.o s_cb.o s_socket.o app_rand.o version.o sess_id.o ciphers.o nseq.o pkcs12.o pkcs8.o pkey.o pkeyparam.o pkeyutl.o spkac.o smime.o cms.o rand.o engine.o ocsp.o prime.o ts.o srp.o ${LIBDEPS} )</div>
<div>dgst.o: In function `dfs$dgst_main':</div><div>dgst.c:(.text+0x2ef5): undefined reference to `dfs$OPENSSL_cleanse'</div><div>enc.o: In function `dfs$enc_main':</div><div>enc.c:(.text+0x3539): undefined reference to `dfs$OPENSSL_cleanse'</div>
<div>ca.o: In function `dfs$ca_main':</div><div>ca.c:(.text+0x449d): undefined reference to `dfs$OPENSSL_cleanse'</div><div>s_server.o: In function `dfs$sv_body':</div><div>s_server.c:(.text+0x1033b): undefined reference to `dfs$OPENSSL_cleanse'</div>
<div>s_client.o: In function `dfs$s_client_main':</div><div>s_client.c:(.text+0xab2b): undefined reference to `dfs$OPENSSL_cleanse'</div><div>s_client.o:s_client.c:(.text+0xab59): more undefined references to `dfs$OPENSSL_cleanse' follow</div>
<div>speed.o: In function `dfs$speed_main':</div><div>speed.c:(.text+0x7f9d): undefined reference to `dfs$RC4'</div><div>speed.c:(.text+0x8ec7): undefined reference to `dfs$AES_cbc_encrypt'</div><div>speed.c:(.text+0x93d7): undefined reference to `dfs$AES_cbc_encrypt'</div>
<div>speed.c:(.text+0x98e7): undefined reference to `dfs$AES_cbc_encrypt'</div><div>speed.c:(.text+0xaa8e): undefined reference to `dfs$AES_encrypt'</div><div>speed.c:(.text+0xb297): undefined reference to `dfs$Camellia_cbc_encrypt'</div>
<div>speed.c:(.text+0xb7a7): undefined reference to `dfs$Camellia_cbc_encrypt'</div><div>speed.c:(.text+0xbcb7): undefined reference to `dfs$Camellia_cbc_encrypt'</div><div>speed.c:(.text+0x14d76): undefined reference to `dfs$RC4_options'</div>
<div>apps.o: In function `dfs$password_callback':</div><div>apps.c:(.text+0x1af6): undefined reference to `dfs$OPENSSL_cleanse'</div><div>apps.c:(.text+0x1bbf): undefined reference to `dfs$OPENSSL_cleanse'</div>
<div>apps.c:(.text+0x1c84): undefined reference to `dfs$OPENSSL_cleanse'</div><div>version.o: In function `dfs$version_main':</div><div>version.c:(.text+0x8a6): undefined reference to `dfs$RC4_options'</div><div>
../libssl.a(s2_lib.o): In function `dfs$ssl2_free':</div><div>s2_lib.c:(.text+0x75c): undefined reference to `dfs$OPENSSL_cleanse'</div><div>../libssl.a(s3_srvr.o): In function `dfs$ssl3_get_client_key_exchange':</div>
<div>s3_srvr.c:(.text+0x125be): undefined reference to `dfs$OPENSSL_cleanse'</div><div>s3_srvr.c:(.text+0x12b42): undefined reference to `dfs$OPENSSL_cleanse'</div><div>s3_srvr.c:(.text+0x12c98): undefined reference to `dfs$OPENSSL_cleanse'</div>
<div>s3_srvr.c:(.text+0x13c80): undefined reference to `dfs$OPENSSL_cleanse'</div><div>../libssl.a(s3_clnt.o):s3_clnt.c:(.text+0x12c6e): more undefined references to `dfs$OPENSSL_cleanse' follow</div><div>../libcrypto.a(cryptlib.o): In function `dfs$OPENSSL_cpuid_setup':</div>
<div>cryptlib.c:(.text+0x206d): undefined reference to `dfs$OPENSSL_ia32_cpuid'</div><div>cryptlib.c:(.text+0x20d5): undefined reference to `dfs$OPENSSL_ia32_cpuid'</div><div>../libcrypto.a(mem.o): In function `dfs$CRYPTO_realloc_clean':</div>
<div>mem.c:(.text+0x1e5a): undefined reference to `dfs$OPENSSL_cleanse'</div><div>../libcrypto.a(md5_dgst.o): In function `dfs$MD5_Update':</div><div>md5_dgst.c:(.text+0x2b6): undefined reference to `dfs$md5_block_asm_data_order'</div>
<div>md5_dgst.c:(.text+0x358): undefined reference to `dfs$md5_block_asm_data_order'</div><div>../libcrypto.a(md5_dgst.o): In function `dfs$MD5_Transform':</div><div>md5_dgst.c:(.text+0x676): undefined reference to `dfs$md5_block_asm_data_order'</div>
<div>../libcrypto.a(md5_dgst.o): In function `dfs$MD5_Final':</div><div>md5_dgst.c:(.text+0x784): undefined reference to `dfs$md5_block_asm_data_order'</div><div>md5_dgst.c:(.text+0x8a4): undefined reference to `dfs$md5_block_asm_data_order'</div>
<div>../libcrypto.a(sha1dgst.o): In function `dfs$SHA1_Update':</div><div>sha1dgst.c:(.text+0x2b6): undefined reference to `dfs$sha1_block_data_order'</div><div>sha1dgst.c:(.text+0x358): undefined reference to `dfs$sha1_block_data_order'</div>
<div>../libcrypto.a(sha1dgst.o): In function `dfs$SHA1_Transform':</div><div>sha1dgst.c:(.text+0x676): undefined reference to `dfs$sha1_block_data_order'</div><div>../libcrypto.a(sha1dgst.o): In function `dfs$SHA1_Final':</div>
<div>sha1dgst.c:(.text+0x784): undefined reference to `dfs$sha1_block_data_order'</div><div>sha1dgst.c:(.text+0x8ab): undefined reference to `dfs$sha1_block_data_order'</div><div>../libcrypto.a(sha1_one.o): In function `dfs$SHA1':</div>
<div>sha1_one.c:(.text+0xcb): undefined reference to `dfs$OPENSSL_cleanse'</div><div>../libcrypto.a(sha256.o): In function `dfs$SHA224':</div><div>sha256.c:(.text+0x423): undefined reference to `dfs$OPENSSL_cleanse'</div>
<div>../libcrypto.a(sha256.o): In function `dfs$SHA256_Update':</div><div>sha256.c:(.text+0x716): undefined reference to `dfs$sha256_block_data_order'</div><div>sha256.c:(.text+0x7b8): undefined reference to `dfs$sha256_block_data_order'</div>
<div>../libcrypto.a(sha256.o): In function `dfs$SHA256_Final':</div><div>sha256.c:(.text+0xbc1): undefined reference to `dfs$sha256_block_data_order'</div><div>sha256.c:(.text+0xce3): undefined reference to `dfs$sha256_block_data_order'</div>
<div>../libcrypto.a(sha256.o): In function `dfs$SHA256':</div><div>sha256.c:(.text+0x1693): undefined reference to `dfs$OPENSSL_cleanse'</div><div>../libcrypto.a(sha256.o): In function `dfs$SHA256_Transform':</div>
<div>sha256.c:(.text+0x1746): undefined reference to `dfs$sha256_block_data_order'</div><div>../libcrypto.a(sha512.o): In function `dfs$SHA512_Final':</div><div>sha512.c:(.text+0x465): undefined reference to `dfs$sha512_block_data_order'</div>
<div>sha512.c:(.text+0x6bb): undefined reference to `dfs$sha512_block_data_order'</div><div>../libcrypto.a(sha512.o): In function `dfs$SHA512_Update':</div><div>sha512.c:(.text+0x12ac): undefined reference to `dfs$sha512_block_data_order'</div>
<div>sha512.c:(.text+0x12f7): undefined reference to `dfs$sha512_block_data_order'</div><div>../libcrypto.a(sha512.o): In function `dfs$SHA512_Transform':</div><div>sha512.c:(.text+0x1506): undefined reference to `dfs$sha512_block_data_order'</div>
<div>../libcrypto.a(sha512.o): In function `dfs$SHA384':</div><div>sha512.c:(.text+0x1776): undefined reference to `dfs$OPENSSL_cleanse'</div><div>../libcrypto.a(sha512.o): In function `dfs$SHA512':</div><div>
sha512.c:(.text+0x1a16): undefined reference to `dfs$OPENSSL_cleanse'</div><div>../libcrypto.a(wp_dgst.o): In function `dfs$WHIRLPOOL_BitUpdate':</div><div>wp_dgst.c:(.text+0x5ac): undefined reference to `dfs$whirlpool_block'</div>
<div>wp_dgst.c:(.text+0x6c5): undefined reference to `dfs$whirlpool_block'</div><div>wp_dgst.c:(.text+0x7b7): undefined reference to `dfs$whirlpool_block'</div><div>wp_dgst.c:(.text+0xa66): undefined reference to `dfs$whirlpool_block'</div>
<div>wp_dgst.c:(.text+0xdd0): undefined reference to `dfs$whirlpool_block'</div><div>../libcrypto.a(wp_dgst.o):wp_dgst.c:(.text+0x11e0): more undefined references to `dfs$whirlpool_block' follow</div><div>../libcrypto.a(aes_misc.o): In function `dfs$AES_set_encrypt_key':</div>
<div>aes_misc.c:(.text+0x3b): undefined reference to `dfs$private_AES_set_encrypt_key'</div><div>../libcrypto.a(aes_misc.o): In function `dfs$AES_set_decrypt_key':</div><div>aes_misc.c:(.text+0x6b): undefined reference to `dfs$private_AES_set_decrypt_key'</div>
</div><div><br></div><div>(...)</div><div><br></div><div>Does this mean that I also have to manually compile the libraries that OpenSSL depends on? </div><div>I'm sure that there is a better way to do this, perhaps using the "Special Case List" mentioned in the dfsan documentation. I was wondering if it's possible to define the appropriate label propagation behavior of dfsan at the OpenSSL interface level (more or less like you do for glibc, without going deeper into the library internals). If this is possible, could you please point me to the right direction to do this? </div>
<div>Please correct me if I made any incorrect conclusions.<br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div>
> /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/Scrt1.o(.debug_info):<br>
> relocation 0 has invalid symbol index 11<br>
> /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/Scrt1.o(.debug_info):<br>
> relocation 1 has invalid symbol index 12<br>
> (...)<br>
> /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/Scrt1.o: In<br>
> function `_start':<br>
> (.text+0x20): undefined reference to `main'<br>
> /usr/local/llvm/build/Debug+Asserts/bin/../lib/clang/3.5.0/lib/linux/libclang_rt.dfsan-x86_64.a(dfsan_interceptors.o):<br>
> In function `InitializeInterceptors':<br>
> /usr/local/llvm/projects/compiler-rt/lib/dfsan/dfsan_interceptors.cc:40:<br>
> undefined reference to `__interception::GetRealFunctionAddress(char const*,<br>
> unsigned long*, unsigned long, unsigned long)'<br>
> /usr/local/llvm/projects/compiler-rt/lib/dfsan/dfsan_interceptors.cc:41:<br>
> undefined reference to `__interception::GetRealFunctionAddress(char const*,<br>
<br>
</div>I do not understand why this might be happening. The interception_linux.o<br>
file is supposed to provide the definition of this symbol. Can you please<br>
show us the output of:<br>
<br>
$ nm /usr/local/llvm/build/Debug+Asserts/bin/../lib/clang/3.5.0/lib/linux/libclang_rt.dfsan-x86_64.a<br>
<br>
?<br>
<div><br>
> unsigned long*, unsigned long, unsigned long)'<br>
> (...)(.data.rel.ro._ZTIN11__sanitizer17ThreadContextBaseE[_ZTIN11__sanitizer17ThreadContextBaseE]+0x0):<br>
> undefined reference to `vtable for __cxxabiv1::__class_type_info'<br>
<br>
</div>This is the same problem that you had before, which I believe is fixed now.<br>
Are you sure that you have updated compiler-rt?<br></blockquote><div><br></div><div>I had exported the wrong clang version to my PATH. </div><div>By the way, I'm exporting only the bin and libs folders to my PATH. Is that all I need?</div>
<div><br></div><div>Thanks so much for all your help :)</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
Thanks,<br>
<span><font color="#888888">--<br>
Peter<br>
</font></span></blockquote></div><br></div></div>