[compiler-rt] r245345 - [msan] Intercept openpty and forkpty.

Evgenii Stepanov via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 18 23:23:52 PDT 2015


Thanks, I will take a look. I'd appreciate the instructions.


On Tue, Aug 18, 2015 at 11:12 PM, Daniel Jasper <djasper at google.com> wrote:
> The test with -Wl,-as-needed breaks in several places. I have removed that
> in r245417. Could you look into what is happening? Happy to provide more
> instructions for a reproduction.
>
> On Tue, Aug 18, 2015 at 10:36 PM, Evgeniy Stepanov via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
>>
>> Author: eugenis
>> Date: Tue Aug 18 15:36:48 2015
>> New Revision: 245345
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=245345&view=rev
>> Log:
>> [msan] Intercept openpty and forkpty.
>>
>> Added:
>>     compiler-rt/trunk/test/msan/Linux/forkpty.cc
>> Modified:
>>     compiler-rt/trunk/lib/msan/msan_interceptors.cc
>>
>> Modified: compiler-rt/trunk/lib/msan/msan_interceptors.cc
>> URL:
>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_interceptors.cc?rev=245345&r1=245344&r2=245345&view=diff
>>
>> ==============================================================================
>> --- compiler-rt/trunk/lib/msan/msan_interceptors.cc (original)
>> +++ compiler-rt/trunk/lib/msan/msan_interceptors.cc Tue Aug 18 15:36:48
>> 2015
>> @@ -1335,6 +1335,28 @@ INTERCEPTOR(int, fork, void) {
>>    return pid;
>>  }
>>
>> +INTERCEPTOR(int, openpty, int *amaster, int *aslave, char *name,
>> +            const void *termp, const void *winp) {
>> +  ENSURE_MSAN_INITED();
>> +  InterceptorScope interceptor_scope;
>> +  int res = REAL(openpty)(amaster, aslave, name, termp, winp);
>> +  if (!res) {
>> +    __msan_unpoison(amaster, sizeof(*amaster));
>> +    __msan_unpoison(aslave, sizeof(*aslave));
>> +  }
>> +  return res;
>> +}
>> +
>> +INTERCEPTOR(int, forkpty, int *amaster, char *name, const void *termp,
>> +            const void *winp) {
>> +  ENSURE_MSAN_INITED();
>> +  InterceptorScope interceptor_scope;
>> +  int res = REAL(forkpty)(amaster, name, termp, winp);
>> +  if (res != -1)
>> +    __msan_unpoison(amaster, sizeof(*amaster));
>> +  return res;
>> +}
>> +
>>  struct MSanInterceptorContext {
>>    bool in_interceptor_scope;
>>  };
>> @@ -1599,6 +1621,8 @@ void InitializeInterceptors() {
>>    INTERCEPT_FUNCTION(__cxa_atexit);
>>    INTERCEPT_FUNCTION(shmat);
>>    INTERCEPT_FUNCTION(fork);
>> +  INTERCEPT_FUNCTION(openpty);
>> +  INTERCEPT_FUNCTION(forkpty);
>>
>>    inited = 1;
>>  }
>>
>> Added: compiler-rt/trunk/test/msan/Linux/forkpty.cc
>> URL:
>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/msan/Linux/forkpty.cc?rev=245345&view=auto
>>
>> ==============================================================================
>> --- compiler-rt/trunk/test/msan/Linux/forkpty.cc (added)
>> +++ compiler-rt/trunk/test/msan/Linux/forkpty.cc Tue Aug 18 15:36:48 2015
>> @@ -0,0 +1,19 @@
>> +// RUN: %clangxx_msan -O0 -g %s -lutil -o %t && %run %t
>> +// RUN: %clangxx_msan -O0 -g %s -Wl,-as-needed -lutil -o %t && %run %t
>> +#include <assert.h>
>> +#include <pty.h>
>> +
>> +#include <sanitizer/msan_interface.h>
>> +
>> +int
>> +main (int argc, char** argv)
>> +{
>> +  int master, slave;
>> +  openpty(&master, &slave, NULL, NULL, NULL);
>> +  assert(__msan_test_shadow(&master, sizeof(master)) == -1);
>> +  assert(__msan_test_shadow(&slave, sizeof(slave)) == -1);
>> +
>> +  int master2;
>> +  forkpty(&master2, NULL, NULL, NULL);
>> +  assert(__msan_test_shadow(&master2, sizeof(master2)) == -1);
>> +}
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
>


More information about the llvm-commits mailing list