[compiler-rt] 3f568e1 - [dfsan] Wrap memmove
Jianzhou Zhao via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 2 21:16:53 PST 2021
Author: Jianzhou Zhao
Date: 2021-02-03T05:15:56Z
New Revision: 3f568e1fbb4163cd7ddba3d0e9fff0d7415c38b2
URL: https://github.com/llvm/llvm-project/commit/3f568e1fbb4163cd7ddba3d0e9fff0d7415c38b2
DIFF: https://github.com/llvm/llvm-project/commit/3f568e1fbb4163cd7ddba3d0e9fff0d7415c38b2.diff
LOG: [dfsan] Wrap memmove
Reviewed-by: morehouse
Differential Revision: https://reviews.llvm.org/D95883
Added:
Modified:
compiler-rt/lib/dfsan/dfsan_custom.cpp
compiler-rt/lib/dfsan/done_abilist.txt
compiler-rt/test/dfsan/custom.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/dfsan/dfsan_custom.cpp b/compiler-rt/lib/dfsan/dfsan_custom.cpp
index eddb077cc4e7..5ecd5698a215 100644
--- a/compiler-rt/lib/dfsan/dfsan_custom.cpp
+++ b/compiler-rt/lib/dfsan/dfsan_custom.cpp
@@ -309,6 +309,12 @@ __dfsw_strlen(const char *s, dfsan_label s_label, dfsan_label *ret_label) {
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 @@ void *__dfsw_memcpy(void *dest, const void *src, size_t n,
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
index e90dbc17a3cd..6db03b4817c3 100644
--- a/compiler-rt/lib/dfsan/done_abilist.txt
+++ b/compiler-rt/lib/dfsan/done_abilist.txt
@@ -214,6 +214,7 @@ fun:ctime_r=custom
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
index 7c37406f8775..48fc9d004218 100644
--- a/compiler-rt/test/dfsan/custom.cpp
+++ b/compiler-rt/test/dfsan/custom.cpp
@@ -118,6 +118,17 @@ void test_memcpy() {
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 @@ int main(void) {
test_memchr();
test_memcmp();
test_memcpy();
+ test_memmove();
test_memset();
test_nanosleep();
test_poll();
More information about the llvm-commits
mailing list