diff options
-rw-r--r-- | compiler-rt/lib/msan/msan_interceptors.cc | 18 | ||||
-rw-r--r-- | compiler-rt/lib/msan/tests/msan_test.cc | 12 |
2 files changed, 30 insertions, 0 deletions
diff --git a/compiler-rt/lib/msan/msan_interceptors.cc b/compiler-rt/lib/msan/msan_interceptors.cc index 078e6d4..002c41c 100644 --- a/compiler-rt/lib/msan/msan_interceptors.cc +++ b/compiler-rt/lib/msan/msan_interceptors.cc @@ -602,6 +602,22 @@ INTERCEPTOR(int, __fxstat64, int magic, int fd, void *buf) { return res; } +INTERCEPTOR(int, __fxstatat, int magic, int fd, char *pathname, void *buf, + int flags) { + ENSURE_MSAN_INITED(); + int res = REAL(__fxstatat)(magic, fd, pathname, buf, flags); + if (!res) __msan_unpoison(buf, __sanitizer::struct_stat_sz); + return res; +} + +INTERCEPTOR(int, __fxstatat64, int magic, int fd, char *pathname, void *buf, + int flags) { + ENSURE_MSAN_INITED(); + int res = REAL(__fxstatat64)(magic, fd, pathname, buf, flags); + if (!res) __msan_unpoison(buf, __sanitizer::struct_stat64_sz); + return res; +} + INTERCEPTOR(int, __xstat, int magic, char *path, void *buf) { ENSURE_MSAN_INITED(); int res = REAL(__xstat)(magic, path, buf); @@ -1274,9 +1290,11 @@ void InitializeInterceptors() { INTERCEPT_FUNCTION(gettimeofday); INTERCEPT_FUNCTION(fcvt); INTERCEPT_FUNCTION(__fxstat); + INTERCEPT_FUNCTION(__fxstatat); INTERCEPT_FUNCTION(__xstat); INTERCEPT_FUNCTION(__lxstat); INTERCEPT_FUNCTION(__fxstat64); + INTERCEPT_FUNCTION(__fxstatat64); INTERCEPT_FUNCTION(__xstat64); INTERCEPT_FUNCTION(__lxstat64); INTERCEPT_FUNCTION(pipe); diff --git a/compiler-rt/lib/msan/tests/msan_test.cc b/compiler-rt/lib/msan/tests/msan_test.cc index 64fe4b5..d907fe7 100644 --- a/compiler-rt/lib/msan/tests/msan_test.cc +++ b/compiler-rt/lib/msan/tests/msan_test.cc @@ -672,6 +672,18 @@ TEST(MemorySanitizer, stat) { EXPECT_NOT_POISONED(st->st_size); } +TEST(MemorySanitizer, fstatat) { + struct stat* st = new struct stat; + int dirfd = open("/proc/self", O_RDONLY); + assert(dirfd > 0); + int res = fstatat(dirfd, "stat", st, 0); + assert(!res); + EXPECT_NOT_POISONED(st->st_dev); + EXPECT_NOT_POISONED(st->st_mode); + EXPECT_NOT_POISONED(st->st_size); + close(dirfd); +} + TEST(MemorySanitizer, statfs) { struct statfs* st = new struct statfs; int res = statfs("/", st); |