[compiler-rt] r190306 - [msan] Intercept fstatat / fstatat64.
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Mon Sep 9 06:40:41 PDT 2013
Author: eugenis
Date: Mon Sep 9 08:40:41 2013
New Revision: 190306
URL: http://llvm.org/viewvc/llvm-project?rev=190306&view=rev
Log:
[msan] Intercept fstatat / fstatat64.
Modified:
compiler-rt/trunk/lib/msan/msan_interceptors.cc
compiler-rt/trunk/lib/msan/tests/msan_test.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=190306&r1=190305&r2=190306&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/msan/msan_interceptors.cc Mon Sep 9 08:40:41 2013
@@ -602,6 +602,22 @@ INTERCEPTOR(int, __fxstat64, int magic,
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);
Modified: compiler-rt/trunk/lib/msan/tests/msan_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/tests/msan_test.cc?rev=190306&r1=190305&r2=190306&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/tests/msan_test.cc (original)
+++ compiler-rt/trunk/lib/msan/tests/msan_test.cc Mon Sep 9 08:40:41 2013
@@ -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);
More information about the llvm-commits
mailing list