forked from OSchip/llvm-project
[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 llvm-svn: 350099
This commit is contained in:
parent
4009724151
commit
774f7e83c3
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -545,5 +545,6 @@
|
|||
#define SANITIZER_INTERCEPT_SHA2 SI_NETBSD
|
||||
#define SANITIZER_INTERCEPT_CDB SI_NETBSD
|
||||
#define SANITIZER_INTERCEPT_VIS (SI_NETBSD || SI_FREEBSD)
|
||||
#define SANITIZER_INTERCEPT_GETFSENT (SI_FREEBSD || SI_NETBSD)
|
||||
|
||||
#endif // #ifndef SANITIZER_PLATFORM_INTERCEPTORS_H
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <arpa/inet.h>
|
||||
#include <dirent.h>
|
||||
#include <fts.h>
|
||||
#include <fstab.h>
|
||||
#include <grp.h>
|
||||
#include <limits.h>
|
||||
#include <net/if.h>
|
||||
|
@ -129,6 +130,7 @@ namespace __sanitizer {
|
|||
unsigned struct_shm_info_sz = sizeof(struct shm_info);
|
||||
unsigned struct_regmatch_sz = sizeof(regmatch_t);
|
||||
unsigned struct_regex_sz = sizeof(regex_t);
|
||||
unsigned struct_fstab_sz = sizeof(struct fstab);
|
||||
unsigned struct_FTS_sz = sizeof(FTS);
|
||||
unsigned struct_FTSENT_sz = sizeof(FTSENT);
|
||||
|
||||
|
|
|
@ -628,6 +628,8 @@ namespace __sanitizer {
|
|||
|
||||
typedef struct __sanitizer_cap_rights __sanitizer_cap_rights_t;
|
||||
extern unsigned struct_cap_rights_sz;
|
||||
|
||||
extern unsigned struct_fstab_sz;
|
||||
} // namespace __sanitizer
|
||||
|
||||
#define CHECK_TYPE_SIZE(TYPE) \
|
||||
|
|
|
@ -218,6 +218,7 @@
|
|||
#include <ttyent.h>
|
||||
#include <fts.h>
|
||||
#include <regex.h>
|
||||
#include <fstab.h>
|
||||
// clang-format on
|
||||
|
||||
// Include these after system headers to avoid name clashes and ambiguities.
|
||||
|
@ -257,6 +258,7 @@ unsigned struct_FTS_sz = sizeof(FTS);
|
|||
unsigned struct_FTSENT_sz = sizeof(FTSENT);
|
||||
unsigned struct_regex_sz = sizeof(regex_t);
|
||||
unsigned struct_regmatch_sz = sizeof(regmatch_t);
|
||||
unsigned struct_fstab_sz = sizeof(struct fstab);
|
||||
unsigned struct_utimbuf_sz = sizeof(struct utimbuf);
|
||||
unsigned struct_itimerspec_sz = sizeof(struct itimerspec);
|
||||
unsigned struct_timex_sz = sizeof(struct timex);
|
||||
|
|
|
@ -66,6 +66,8 @@ extern unsigned struct_FTSENT_sz;
|
|||
extern unsigned struct_regex_sz;
|
||||
extern unsigned struct_regmatch_sz;
|
||||
|
||||
extern unsigned struct_fstab_sz;
|
||||
|
||||
struct __sanitizer_regmatch {
|
||||
OFF_T rm_so;
|
||||
OFF_T rm_eo;
|
||||
|
|
Loading…
Reference in New Issue