<div dir="ltr">Thanks!<div><br></div><div>Lorenzo</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Dec 19, 2013 at 10:02 AM, Evgeniy Stepanov <span dir="ltr"><<a href="mailto:eugeni.stepanov@gmail.com" target="_blank">eugeni.stepanov@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I've fixed it in r197665.<br>
<div class="HOEnZb"><div class="h5"><br>
On Thu, Dec 19, 2013 at 10:32 AM, Kostya Serebryany <<a href="mailto:kcc@google.com">kcc@google.com</a>> wrote:<br>
> I get this error now:<br>
><br>
> /home/kcc/llvm/projects/compiler-rt/lib/dfsan/dfsan_custom.cc:799:34: error:<br>
> sizeof on array function parameter will return size of 'int *' instead of<br>
> 'int [2]' [-Werror,-Wsizeof-array-argument]<br>
> dfsan_set_label(0, sv, sizeof(sv));<br>
> ^<br>
> /home/kcc/llvm/projects/compiler-rt/lib/dfsan/dfsan_custom.cc:792:59: note:<br>
> declared here<br>
> __dfsw_socketpair(int domain, int type, int protocol, int sv[2],<br>
> ^<br>
> 1 error generated.<br>
><br>
><br>
> On Wed, Dec 18, 2013 at 11:25 PM, Lorenzo Martignoni <<a href="mailto:martignlo@google.com">martignlo@google.com</a>><br>
> wrote:<br>
>><br>
>> Author: martignlo<br>
>> Date: Wed Dec 18 13:25:34 2013<br>
>> New Revision: 197601<br>
>><br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=197601&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=197601&view=rev</a><br>
>> Log:<br>
>> [DFSan] New custom wrappers<br>
>><br>
>> Added the following custom wrappers:<br>
>> strstr<br>
>> strrchr<br>
>> memchr<br>
>> nanosleep<br>
>> socketpair<br>
>><br>
>> Tweaked a couple of existing wrappers: if a wrapper returns a pointers<br>
>> derived<br>
>> from an input pointer, then return the label of the input pointer<br>
>><br>
>> Sorted tests invocation<br>
>><br>
>> Differential Revision: D2354<br>
>><br>
>> Modified:<br>
>> compiler-rt/trunk/lib/dfsan/dfsan_custom.cc<br>
>> compiler-rt/trunk/lib/dfsan/done_abilist.txt<br>
>> compiler-rt/trunk/lib/dfsan/lit_tests/custom.c<br>
>><br>
>> Modified: compiler-rt/trunk/lib/dfsan/dfsan_custom.cc<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/dfsan/dfsan_custom.cc?rev=197601&r1=197600&r2=197601&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/dfsan/dfsan_custom.cc?rev=197601&r1=197600&r2=197601&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- compiler-rt/trunk/lib/dfsan/dfsan_custom.cc (original)<br>
>> +++ compiler-rt/trunk/lib/dfsan/dfsan_custom.cc Wed Dec 18 13:25:34 2013<br>
>> @@ -70,7 +70,8 @@ SANITIZER_INTERFACE_ATTRIBUTE char *__df<br>
>> if (flags().strict_data_dependencies) {<br>
>> *ret_label = s_label;<br>
>> } else {<br>
>> - *ret_label = dfsan_union(dfsan_read_label(s, i + 1), c_label);<br>
>> + *ret_label = dfsan_union(dfsan_read_label(s, i + 1),<br>
>> + dfsan_union(s_label, c_label));<br>
>> }<br>
>> return s[i] == 0 ? 0 : const_cast<char *>(s+i);<br>
>> }<br>
>> @@ -258,7 +259,7 @@ __dfsw_strncpy(char *s1, const char *s2,<br>
>> dfsan_memcpy(s1, s2, n);<br>
>> }<br>
>><br>
>> - *ret_label = 0;<br>
>> + *ret_label = s1_label;<br>
>> return s1;<br>
>> }<br>
>><br>
>> @@ -720,4 +721,83 @@ int __dfsw_gettimeofday(struct timeval *<br>
>> *ret_label = 0;<br>
>> return ret;<br>
>> }<br>
>> +<br>
>> +SANITIZER_INTERFACE_ATTRIBUTE void *__dfsw_memchr(void *s, int c, size_t<br>
>> n,<br>
>> + dfsan_label s_label,<br>
>> + dfsan_label c_label,<br>
>> + dfsan_label n_label,<br>
>> + dfsan_label *ret_label)<br>
>> {<br>
>> + void *ret = memchr(s, c, n);<br>
>> + if (flags().strict_data_dependencies) {<br>
>> + *ret_label = ret ? s_label : 0;<br>
>> + } else {<br>
>> + size_t len =<br>
>> + ret ? reinterpret_cast<char *>(ret) - reinterpret_cast<char *>(s)<br>
>> + 1<br>
>> + : n;<br>
>> + *ret_label =<br>
>> + dfsan_union(dfsan_read_label(s, len), dfsan_union(s_label,<br>
>> c_label));<br>
>> + }<br>
>> + return ret;<br>
>> +}<br>
>> +<br>
>> +SANITIZER_INTERFACE_ATTRIBUTE char *__dfsw_strrchr(char *s, int c,<br>
>> + dfsan_label s_label,<br>
>> + dfsan_label c_label,<br>
>> + dfsan_label<br>
>> *ret_label) {<br>
>> + char *ret = strrchr(s, c);<br>
>> + if (flags().strict_data_dependencies) {<br>
>> + *ret_label = ret ? s_label : 0;<br>
>> + } else {<br>
>> + *ret_label =<br>
>> + dfsan_union(dfsan_read_label(s, strlen(s) + 1),<br>
>> + dfsan_union(s_label, c_label));<br>
>> + }<br>
>> +<br>
>> + return ret;<br>
>> +}<br>
>> +<br>
>> +SANITIZER_INTERFACE_ATTRIBUTE char *__dfsw_strstr(char *haystack, char<br>
>> *needle,<br>
>> + dfsan_label<br>
>> haystack_label,<br>
>> + dfsan_label<br>
>> needle_label,<br>
>> + dfsan_label *ret_label)<br>
>> {<br>
>> + char *ret = strstr(haystack, needle);<br>
>> + if (flags().strict_data_dependencies) {<br>
>> + *ret_label = ret ? haystack_label : 0;<br>
>> + } else {<br>
>> + size_t len = ret ? ret + strlen(needle) - haystack : strlen(haystack)<br>
>> + 1;<br>
>> + *ret_label =<br>
>> + dfsan_union(dfsan_read_label(haystack, len),<br>
>> + dfsan_union(dfsan_read_label(needle, strlen(needle) +<br>
>> 1),<br>
>> + dfsan_union(haystack_label,<br>
>> needle_label)));<br>
>> + }<br>
>> +<br>
>> + return ret;<br>
>> +}<br>
>> +<br>
>> +SANITIZER_INTERFACE_ATTRIBUTE int __dfsw_nanosleep(const struct timespec<br>
>> *req,<br>
>> + struct timespec *rem,<br>
>> + dfsan_label req_label,<br>
>> + dfsan_label rem_label,<br>
>> + dfsan_label<br>
>> *ret_label) {<br>
>> + int ret = nanosleep(req, rem);<br>
>> + *ret_label = 0;<br>
>> + if (ret == -1) {<br>
>> + // Interrupted by a signal, rem is filled with the remaining time.<br>
>> + dfsan_set_label(0, rem, sizeof(struct timespec));<br>
>> + }<br>
>> + return ret;<br>
>> +}<br>
>> +<br>
>> +SANITIZER_INTERFACE_ATTRIBUTE int<br>
>> +__dfsw_socketpair(int domain, int type, int protocol, int sv[2],<br>
>> + dfsan_label domain_label, dfsan_label type_label,<br>
>> + dfsan_label protocol_label, dfsan_label sv_label,<br>
>> + dfsan_label *ret_label) {<br>
>> + int ret = socketpair(domain, type, protocol, sv);<br>
>> + *ret_label = 0;<br>
>> + if (ret == 0) {<br>
>> + dfsan_set_label(0, sv, sizeof(sv));<br>
>> + }<br>
>> + return ret;<br>
>> +}<br>
>> }<br>
>><br>
>> Modified: compiler-rt/trunk/lib/dfsan/done_abilist.txt<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/dfsan/done_abilist.txt?rev=197601&r1=197600&r2=197601&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/dfsan/done_abilist.txt?rev=197601&r1=197600&r2=197601&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- compiler-rt/trunk/lib/dfsan/done_abilist.txt (original)<br>
>> +++ compiler-rt/trunk/lib/dfsan/done_abilist.txt Wed Dec 18 13:25:34 2013<br>
>> @@ -154,8 +154,10 @@ fun:get_current_dir_name=custom<br>
>> fun:gethostname=custom<br>
>> fun:getrlimit=custom<br>
>> fun:getrusage=custom<br>
>> +fun:nanosleep=custom<br>
>> fun:pread=custom<br>
>> fun:read=custom<br>
>> +fun:socketpair=custom<br>
>> fun:stat=custom<br>
>> fun:time=custom<br>
>><br>
>> @@ -177,6 +179,7 @@ fun:strtoull=custom<br>
>><br>
>> # Functions that produce an output that is computed from the input, but<br>
>> is not<br>
>> # necessarily data dependent.<br>
>> +fun:memchr=custom<br>
>> fun:memcmp=custom<br>
>> fun:strcasecmp=custom<br>
>> fun:strchr=custom<br>
>> @@ -184,6 +187,8 @@ fun:strcmp=custom<br>
>> fun:strlen=custom<br>
>> fun:strncasecmp=custom<br>
>> fun:strncmp=custom<br>
>> +fun:strrchr=custom<br>
>> +fun:strstr=custom<br>
>><br>
>> # Functions that take a callback (wrap the callback manually).<br>
>> fun:dl_iterate_phdr=custom<br>
>><br>
>> Modified: compiler-rt/trunk/lib/dfsan/lit_tests/custom.c<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/dfsan/lit_tests/custom.c?rev=197601&r1=197600&r2=197601&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/dfsan/lit_tests/custom.c?rev=197601&r1=197600&r2=197601&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- compiler-rt/trunk/lib/dfsan/lit_tests/custom.c (original)<br>
>> +++ compiler-rt/trunk/lib/dfsan/lit_tests/custom.c Wed Dec 18 13:25:34<br>
>> 2013<br>
>> @@ -605,6 +605,103 @@ void test_dl_iterate_phdr() {<br>
>> dl_iterate_phdr(dl_iterate_phdr_test_cb, (void *)3);<br>
>> }<br>
>><br>
>> +void test_strrchr() {<br>
>> + char str1[] = "str1str1";<br>
>> + dfsan_set_label(i_label, &str1[7], 1);<br>
>> +<br>
>> + char *rv = strrchr(str1, 'r');<br>
>> + assert(rv == &str1[6]);<br>
>> +#ifdef STRICT_DATA_DEPENDENCIES<br>
>> + ASSERT_ZERO_LABEL(rv);<br>
>> +#else<br>
>> + ASSERT_LABEL(rv, i_label);<br>
>> +#endif<br>
>> +}<br>
>> +<br>
>> +void test_strstr() {<br>
>> + char str1[] = "str1str1";<br>
>> + dfsan_set_label(i_label, &str1[3], 1);<br>
>> + dfsan_set_label(j_label, &str1[5], 1);<br>
>> +<br>
>> + char *rv = strstr(str1, "1s");<br>
>> + assert(rv == &str1[3]);<br>
>> +#ifdef STRICT_DATA_DEPENDENCIES<br>
>> + ASSERT_ZERO_LABEL(rv);<br>
>> +#else<br>
>> + ASSERT_LABEL(rv, i_label);<br>
>> +#endif<br>
>> +<br>
>> + rv = strstr(str1, "2s");<br>
>> + assert(rv == NULL);<br>
>> +#ifdef STRICT_DATA_DEPENDENCIES<br>
>> + ASSERT_ZERO_LABEL(rv);<br>
>> +#else<br>
>> + ASSERT_LABEL(rv, i_j_label);<br>
>> +#endif<br>
>> +}<br>
>> +<br>
>> +void test_memchr() {<br>
>> + char str1[] = "str1";<br>
>> + dfsan_set_label(i_label, &str1[3], 1);<br>
>> + dfsan_set_label(j_label, &str1[4], 1);<br>
>> +<br>
>> + char *crv = memchr(str1, 'r', sizeof(str1));<br>
>> + assert(crv == &str1[2]);<br>
>> + ASSERT_ZERO_LABEL(crv);<br>
>> +<br>
>> + crv = memchr(str1, '1', sizeof(str1));<br>
>> + assert(crv == &str1[3]);<br>
>> +#ifdef STRICT_DATA_DEPENDENCIES<br>
>> + ASSERT_ZERO_LABEL(crv);<br>
>> +#else<br>
>> + ASSERT_LABEL(crv, i_label);<br>
>> +#endif<br>
>> +<br>
>> + crv = memchr(str1, 'x', sizeof(str1));<br>
>> + assert(!crv);<br>
>> +#ifdef STRICT_DATA_DEPENDENCIES<br>
>> + ASSERT_ZERO_LABEL(crv);<br>
>> +#else<br>
>> + ASSERT_LABEL(crv, i_j_label);<br>
>> +#endif<br>
>> +}<br>
>> +<br>
>> +void alarm_handler(int unused) {<br>
>> + ;<br>
>> +}<br>
>> +<br>
>> +void test_nanosleep() {<br>
>> + struct timespec req, rem;<br>
>> + req.tv_sec = 1;<br>
>> + req.tv_nsec = 0;<br>
>> + dfsan_set_label(i_label, &rem, sizeof(rem));<br>
>> +<br>
>> + // non interrupted<br>
>> + int rv = nanosleep(&req, &rem);<br>
>> + assert(rv == 0);<br>
>> + ASSERT_ZERO_LABEL(rv);<br>
>> + ASSERT_READ_LABEL(&rem, 1, i_label);<br>
>> +<br>
>> + // interrupted by an alarm<br>
>> + signal(SIGALRM, alarm_handler);<br>
>> + req.tv_sec = 3;<br>
>> + alarm(1);<br>
>> + rv = nanosleep(&req, &rem);<br>
>> + assert(rv == -1);<br>
>> + ASSERT_ZERO_LABEL(rv);<br>
>> + ASSERT_READ_ZERO_LABEL(&rem, sizeof(rem));<br>
>> +}<br>
>> +<br>
>> +void test_socketpair() {<br>
>> + int fd[2];<br>
>> +<br>
>> + dfsan_set_label(i_label, fd, sizeof(fd));<br>
>> + int rv = socketpair(PF_LOCAL, SOCK_STREAM, 0, fd);<br>
>> + assert(rv == 0);<br>
>> + ASSERT_ZERO_LABEL(rv);<br>
>> + ASSERT_READ_ZERO_LABEL(fd, sizeof(fd));<br>
>> +}<br>
>> +<br>
>> int main(void) {<br>
>> i_label = dfsan_create_label("i", 0);<br>
>> j_label = dfsan_create_label("j", 0);<br>
>> @@ -612,47 +709,50 @@ int main(void) {<br>
>><br>
>> test_calloc();<br>
>> test_clock_gettime();<br>
>> + test_ctime_r();<br>
>> + test_dl_iterate_phdr();<br>
>> test_dlopen();<br>
>> + test_fgets();<br>
>> test_fstat();<br>
>> + test_get_current_dir_name();<br>
>> + test_getcwd();<br>
>> + test_gethostname();<br>
>> + test_getpwuid_r();<br>
>> + test_getrlimit();<br>
>> + test_getrusage();<br>
>> + test_gettimeofday();<br>
>> + test_inet_pton();<br>
>> + test_localtime_r();<br>
>> + test_memchr();<br>
>> test_memcmp();<br>
>> test_memcpy();<br>
>> test_memset();<br>
>> + test_nanosleep();<br>
>> + test_poll();<br>
>> test_pread();<br>
>> + test_pthread_create();<br>
>> test_read();<br>
>> + test_sched_getaffinity();<br>
>> + test_select();<br>
>> + test_sigaction();<br>
>> + test_sigemptyset();<br>
>> + test_socketpair();<br>
>> test_stat();<br>
>> test_strcasecmp();<br>
>> test_strchr();<br>
>> test_strcmp();<br>
>> + test_strcpy();<br>
>> test_strdup();<br>
>> test_strlen();<br>
>> test_strncasecmp();<br>
>> test_strncmp();<br>
>> test_strncpy();<br>
>> -<br>
>> - test_ctime_r();<br>
>> - test_fgets();<br>
>> - test_getcwd();<br>
>> - test_get_current_dir_name();<br>
>> - test_gethostname();<br>
>> - test_getrlimit();<br>
>> - test_getrusage();<br>
>> - test_strcpy();<br>
>> + test_strrchr();<br>
>> + test_strstr();<br>
>> + test_strtod();<br>
>> test_strtol();<br>
>> test_strtoll();<br>
>> - test_strtod();<br>
>> test_strtoul();<br>
>> test_strtoull();<br>
>> test_time();<br>
>> - test_inet_pton();<br>
>> - test_localtime_r();<br>
>> - test_getpwuid_r();<br>
>> - test_poll();<br>
>> - test_select();<br>
>> - test_sched_getaffinity();<br>
>> - test_sigemptyset();<br>
>> - test_sigaction();<br>
>> - test_gettimeofday();<br>
>> -<br>
>> - test_pthread_create();<br>
>> - test_dl_iterate_phdr();<br>
>> }<br>
>><br>
>><br>
>> _______________________________________________<br>
>> llvm-commits mailing list<br>
>> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
><br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
><br>
</div></div></blockquote></div><br></div>