[PATCH] D41637: Add MSan interceptor for fstat(2)
Kamil Rytarowski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 29 15:14:58 PST 2017
krytarowski created this revision.
krytarowski added reviewers: joerg, eugenis, vitalybuka.
krytarowski added a project: Sanitizers.
Add new MSan interceptor that corrects NetBSD's
specific handling of fstat(2).
NetBSD renames the call to __fstat50.
Sponsored by <The NetBSD Foundation>
Repository:
rL LLVM
https://reviews.llvm.org/D41637
Files:
lib/msan/msan_interceptors.cc
Index: lib/msan/msan_interceptors.cc
===================================================================
--- lib/msan/msan_interceptors.cc
+++ lib/msan/msan_interceptors.cc
@@ -37,6 +37,7 @@
#if SANITIZER_NETBSD
#define gettimeofday __gettimeofday50
#define getrusage __getrusage50
+#define fstat __fstat50
#endif
#include <stdarg.h>
@@ -688,6 +689,19 @@
return res;
}
+#if SANITIZER_NETBSD
+INTERCEPTOR(int, fstat, int fd, void *buf) {
+ ENSURE_MSAN_INITED();
+ int res = REAL(fstat)(fd, buf);
+ if (!res)
+ __msan_unpoison(buf, __sanitizer::struct_stat_sz);
+ return res;
+}
+#define MSAN_MAYBE_INTERCEPT_FSTAT INTERCEPT_FUNCTION(fstat)
+#else
+#define MSAN_MAYBE_INTERCEPT_FSTAT
+#endif
+
#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
INTERCEPTOR(int, __fxstat, int magic, int fd, void *buf) {
ENSURE_MSAN_INITED();
@@ -1633,6 +1647,7 @@
INTERCEPT_FUNCTION(putenv);
INTERCEPT_FUNCTION(gettimeofday);
MSAN_MAYBE_INTERCEPT_FCVT;
+ MSAN_MAYBE_INTERCEPT_FSTAT;
MSAN_MAYBE_INTERCEPT___FXSTAT;
MSAN_INTERCEPT_FSTATAT;
MSAN_MAYBE_INTERCEPT___FXSTAT64;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41637.128349.patch
Type: text/x-patch
Size: 1090 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171229/2b7d66d8/attachment.bin>
More information about the llvm-commits
mailing list