diff --git a/compiler-rt/lib/dfsan/dfsan_custom.cpp b/compiler-rt/lib/dfsan/dfsan_custom.cpp --- a/compiler-rt/lib/dfsan/dfsan_custom.cpp +++ b/compiler-rt/lib/dfsan/dfsan_custom.cpp @@ -309,6 +309,12 @@ return ret; } +static void *dfsan_memmove(void *dest, const void *src, size_t n) { + dfsan_label *sdest = shadow_for(dest); + const dfsan_label *ssrc = shadow_for(src); + internal_memmove((void *)sdest, (const void *)ssrc, n * sizeof(dfsan_label)); + return internal_memmove(dest, src, n); +} static void *dfsan_memcpy(void *dest, const void *src, size_t n) { dfsan_label *sdest = shadow_for(dest); @@ -330,6 +336,14 @@ return dfsan_memcpy(dest, src, n); } +SANITIZER_INTERFACE_ATTRIBUTE +void *__dfsw_memmove(void *dest, const void *src, size_t n, + dfsan_label dest_label, dfsan_label src_label, + dfsan_label n_label, dfsan_label *ret_label) { + *ret_label = dest_label; + return dfsan_memmove(dest, src, n); +} + SANITIZER_INTERFACE_ATTRIBUTE void *__dfsw_memset(void *s, int c, size_t n, dfsan_label s_label, dfsan_label c_label, diff --git a/compiler-rt/lib/dfsan/done_abilist.txt b/compiler-rt/lib/dfsan/done_abilist.txt --- a/compiler-rt/lib/dfsan/done_abilist.txt +++ b/compiler-rt/lib/dfsan/done_abilist.txt @@ -214,6 +214,7 @@ fun:inet_pton=custom fun:localtime_r=custom fun:memcpy=custom +fun:memmove=custom fun:memset=custom fun:strcpy=custom fun:strdup=custom diff --git a/compiler-rt/test/dfsan/custom.cpp b/compiler-rt/test/dfsan/custom.cpp --- a/compiler-rt/test/dfsan/custom.cpp +++ b/compiler-rt/test/dfsan/custom.cpp @@ -118,6 +118,17 @@ ASSERT_LABEL(str2[3], i_label); } +void test_memmove() { + char str[] = "str1xx"; + dfsan_set_label(i_label, &str[3], 1); + + ASSERT_ZERO_LABEL(memmove(str + 2, str, 4)); + assert(0 == memcmp(str + 2, "str1", 4)); + for (int i = 0; i <= 4; ++i) + ASSERT_ZERO_LABEL(str[i]); + ASSERT_LABEL(str[5], i_label); +} + void test_memset() { char buf[8]; int j = 'a'; @@ -1299,6 +1310,7 @@ test_memchr(); test_memcmp(); test_memcpy(); + test_memmove(); test_memset(); test_nanosleep(); test_poll();