summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_common_interceptors.inc
diff options
context:
space:
mode:
authorDavid Carlier <devnexen@gmail.com>2018-12-27 21:25:24 +0000
committerDavid Carlier <devnexen@gmail.com>2018-12-27 21:25:24 +0000
commit3bc9b9b710d85baf898e783f691e844366d5e745 (patch)
tree18f6e95be40c07d511b2ea0089c5315e7239d41d /lib/sanitizer_common/sanitizer_common_interceptors.inc
parent69aff42f0207e1d3eddc34eee82ef91202673c25 (diff)
downloadcompiler-rt-3bc9b9b710d85baf898e783f691e844366d5e745.tar.gz
[Sanitizer] Add fstab api to FreeBSD/Linux
Interception of /etc/fstab function parsers. Reviewers: krytarowski, vitalybuka Reviewed By: krytarowski Differential Revision: https://reviews.llvm.org/D56099 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@350099 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_common_interceptors.inc')
-rw-r--r--lib/sanitizer_common/sanitizer_common_interceptors.inc40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/sanitizer_common/sanitizer_common_interceptors.inc b/lib/sanitizer_common/sanitizer_common_interceptors.inc
index 1f446feba..c80498a1b 100644
--- a/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -9045,6 +9045,45 @@ INTERCEPTOR(void, cdbw_close, struct __sanitizer_cdbw *cdbw) {
#define INIT_CDB
#endif
+#if SANITIZER_INTERCEPT_GETFSENT
+INTERCEPTOR(void *, getfsent) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, getfsent);
+ void *ret = REAL(getfsent)();
+ if (ret)
+ COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, struct_fstab_sz);
+ return ret;
+}
+
+INTERCEPTOR(void *, getfsspec, const char *spec) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, getfsspec, spec);
+ if (spec)
+ COMMON_INTERCEPTOR_READ_RANGE(ctx, spec, REAL(strlen)(spec) + 1);
+ void *ret = REAL(getfsspec)(spec);
+ if (ret)
+ COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, struct_fstab_sz);
+ return ret;
+}
+
+INTERCEPTOR(void *, getfsfile, const char *file) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, getfsfile, file);
+ if (file)
+ COMMON_INTERCEPTOR_READ_RANGE(ctx, file, REAL(strlen)(file) + 1);
+ void *ret = REAL(getfsfile)(file);
+ if (ret)
+ COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, struct_fstab_sz);
+ return ret;
+}
+
+#define INIT_GETFSENT \
+ COMMON_INTERCEPT_FUNCTION(getfsent); \
+ COMMON_INTERCEPT_FUNCTION(getfsspec); \
+ COMMON_INTERCEPT_FUNCTION(getfsfile);
+#else
+#define INIT_GETFSENT
+#endif
static void InitializeCommonInterceptors() {
static u64 metadata_mem[sizeof(MetadataHashMap) / sizeof(u64) + 1];
interceptor_metadata_map =
@@ -9325,6 +9364,7 @@ static void InitializeCommonInterceptors() {
INIT_SHA2;
INIT_VIS;
INIT_CDB;
+ INIT_GETFSENT;
INIT___PRINTF_CHK;
}