[compiler-rt] r182466 - [msan] getaddrinfo & nested interceptor support.

Matt Beaumont-Gay matthewbg at google.com
Thu May 30 15:04:27 PDT 2013


On Wed, May 22, 2013 at 5:50 AM, Evgeniy Stepanov
<eugeni.stepanov at gmail.com> wrote:
> Author: eugenis
> Date: Wed May 22 07:50:26 2013
> New Revision: 182466
>
> URL: http://llvm.org/viewvc/llvm-project?rev=182466&view=rev
> Log:
> [msan] getaddrinfo & nested interceptor support.
>
> Multiple connected changes:
> - Ignore reads from nested interceptors.
> - Check shadow on reads from common interceptors.
> - getaddrinfo interceptor.
>
>
> Added:
>     compiler-rt/trunk/lib/msan/lit_tests/getaddrinfo-positive.cc   (with props)
>     compiler-rt/trunk/lib/msan/lit_tests/getaddrinfo.cc   (with props)
> Modified:
>     compiler-rt/trunk/lib/msan/msan_interceptors.cc
>     compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
>     compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h
>     compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
>     compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h
>     compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc
>     compiler-rt/trunk/lib/tsan/rtl/tsan_stat.h

> Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.cc?rev=182466&r1=182465&r2=182466&view=diff
> ==============================================================================
> --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.cc (original)
> +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.cc Wed May 22 07:50:26 2013
> @@ -29,9 +29,11 @@
>  #include <sys/utsname.h>
>  #include <sys/types.h>
>  #include <sys/stat.h>
> +#include <sys/socket.h>
>  #include <sys/time.h>
>  #include <sys/resource.h>
>  #include <sys/socket.h>
> +#include <netdb.h>
>  #include <time.h>
>
>  #if !SANITIZER_ANDROID
> @@ -56,6 +58,7 @@ namespace __sanitizer {
>    unsigned struct_sigaction_sz = sizeof(struct sigaction);
>    unsigned struct_itimerval_sz = sizeof(struct itimerval);
>    unsigned pthread_t_sz = sizeof(pthread_t);
> +  unsigned struct_sockaddr_sz = sizeof(struct sockaddr);
>
>  #if !SANITIZER_ANDROID
>    unsigned ucontext_t_sz = sizeof(ucontext_t);
> @@ -133,4 +136,12 @@ COMPILER_CHECK(offsetof(struct __sanitiz
>                 offsetof(struct dl_phdr_info, dlpi_phnum));
>  #endif
>
> +COMPILER_CHECK(sizeof(struct __sanitizer_addrinfo) == sizeof(struct addrinfo));
> +COMPILER_CHECK(offsetof(struct __sanitizer_addrinfo, ai_addr) ==
> +               offsetof(struct addrinfo, ai_addr));
> +COMPILER_CHECK(offsetof(struct __sanitizer_addrinfo, ai_canonname) ==
> +               offsetof(struct addrinfo, ai_canonname));
> +COMPILER_CHECK(offsetof(struct __sanitizer_addrinfo, ai_next) ==
> +               offsetof(struct addrinfo, ai_next));

There's a missing check here: sizeof(__sanitizer_addrinfo::ai_addrlen)
== sizeof(addrinfo::ai_addrlen). When the real ai_addrlen is only 32
bits and ASan's is 64 bits, after r182852, we read the (uninitialized)
padding bits as part of the size.



More information about the llvm-commits mailing list