[sanitizer_common] Intercept timespec_get except for hwasan (#117080)
Intercept timespec_get for all sanitizers except for hwasan
This commit is contained in:
@@ -209,6 +209,9 @@
|
||||
#undef SANITIZER_INTERCEPT_TIME
|
||||
#define SANITIZER_INTERCEPT_TIME 0
|
||||
|
||||
#undef SANITIZER_INTERCEPT_TIMESPEC_GET
|
||||
#define SANITIZER_INTERCEPT_TIMESPEC_GET 0
|
||||
|
||||
#undef SANITIZER_INTERCEPT_GLOB
|
||||
#define SANITIZER_INTERCEPT_GLOB 0
|
||||
|
||||
|
||||
@@ -2389,6 +2389,25 @@ INTERCEPTOR(int, setitimer, int which, const void *new_value, void *old_value) {
|
||||
#define INIT_GETITIMER
|
||||
#endif
|
||||
|
||||
#if SANITIZER_INTERCEPT_TIMESPEC_GET
|
||||
INTERCEPTOR(int, timespec_get, struct __sanitizer_timespec *ts, int base) {
|
||||
void *ctx;
|
||||
COMMON_INTERCEPTOR_ENTER(ctx, timespec_get, ts, base);
|
||||
// We don't yet know if ts is addressable, so we use our own scratch buffer
|
||||
struct __sanitizer_timespec ts_local;
|
||||
int res = REAL(timespec_get)(&ts_local, base);
|
||||
if (res) {
|
||||
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ts,
|
||||
sizeof(struct __sanitizer_timespec));
|
||||
internal_memcpy(ts, &ts_local, sizeof(struct __sanitizer_timespec));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
# define INIT_TIMESPEC_GET COMMON_INTERCEPT_FUNCTION(timespec_get);
|
||||
#else
|
||||
# define INIT_TIMESPEC_GET
|
||||
#endif
|
||||
|
||||
#if SANITIZER_INTERCEPT_GLOB
|
||||
static void unpoison_glob_t(void *ctx, __sanitizer_glob_t *pglob) {
|
||||
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, pglob, sizeof(*pglob));
|
||||
@@ -10324,6 +10343,7 @@ static void InitializeCommonInterceptors() {
|
||||
INIT_TIMER_CREATE;
|
||||
INIT_GETITIMER;
|
||||
INIT_TIME;
|
||||
INIT_TIMESPEC_GET;
|
||||
INIT_GLOB;
|
||||
INIT_GLOB64;
|
||||
INIT___B64_TO;
|
||||
|
||||
@@ -263,6 +263,7 @@ SANITIZER_WEAK_IMPORT void *aligned_alloc(__sanitizer::usize __alignment,
|
||||
#define SANITIZER_INTERCEPT_TIMER_CREATE SI_GLIBC
|
||||
#define SANITIZER_INTERCEPT_GETITIMER SI_POSIX
|
||||
#define SANITIZER_INTERCEPT_TIME SI_POSIX
|
||||
#define SANITIZER_INTERCEPT_TIMESPEC_GET SI_LINUX
|
||||
#define SANITIZER_INTERCEPT_GLOB (SI_GLIBC || SI_SOLARIS)
|
||||
#define SANITIZER_INTERCEPT_GLOB64 SI_GLIBC
|
||||
#define SANITIZER_INTERCEPT___B64_TO SI_LINUX_NOT_ANDROID
|
||||
|
||||
Reference in New Issue
Block a user