forked from OSchip/llvm-project
[sanitizer] Intercept pthread_getschedparam.
llvm-svn: 182353
This commit is contained in:
parent
b1333fe831
commit
970be35808
|
@ -1217,3 +1217,14 @@ TEST(AddressSanitizer, LongDoubleNegativeTest) {
|
|||
memcpy(Ident(&a), Ident(&b), sizeof(long double));
|
||||
memcpy(Ident(&c), Ident(&b), sizeof(long double));
|
||||
}
|
||||
|
||||
TEST(AddressSanitizer, pthread_getschedparam) {
|
||||
int policy;
|
||||
struct sched_param param;
|
||||
EXPECT_DEATH(pthread_getschedparam(pthread_self(), &policy, Ident(¶m) + 2),
|
||||
"AddressSanitizer: stack-buffer-overflow");
|
||||
EXPECT_DEATH(pthread_getschedparam(pthread_self(), Ident(&policy) - 1, ¶m),
|
||||
"AddressSanitizer: stack-buffer-overflow");
|
||||
int res = pthread_getschedparam(pthread_self(), &policy, ¶m);
|
||||
ASSERT_EQ(0, res);
|
||||
}
|
||||
|
|
|
@ -1656,6 +1656,15 @@ TEST(MemorySanitizer, PreAllocatedStackThread) {
|
|||
ASSERT_EQ(0, res);
|
||||
}
|
||||
|
||||
TEST(MemorySanitizer, pthread_getschedparam) {
|
||||
int policy;
|
||||
struct sched_param param;
|
||||
int res = pthread_getschedparam(pthread_self(), &policy, ¶m);
|
||||
ASSERT_EQ(0, res);
|
||||
EXPECT_NOT_POISONED(policy);
|
||||
EXPECT_NOT_POISONED(param.sched_priority);
|
||||
}
|
||||
|
||||
TEST(MemorySanitizer, posix_memalign) {
|
||||
void *p;
|
||||
EXPECT_POISONED(p);
|
||||
|
|
|
@ -731,26 +731,42 @@ INTERCEPTOR(int, inet_pton, int af, const char *src, void *dst) {
|
|||
#define INIT_INET
|
||||
#endif
|
||||
|
||||
#if SANITIZER_INTERCEPT_PTHREAD_GETSCHEDPARAM
|
||||
INTERCEPTOR(int, pthread_getschedparam, uptr thread, int *policy, int *param) {
|
||||
void *ctx;
|
||||
COMMON_INTERCEPTOR_ENTER(ctx, pthread_getschedparam, thread, policy, param);
|
||||
int res = REAL(pthread_getschedparam)(thread, policy, param);
|
||||
if (res == 0) {
|
||||
if (policy) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, policy, sizeof(*policy));
|
||||
if (param) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, param, sizeof(*param));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
#define INIT_PTHREAD_GETSCHEDPARAM INTERCEPT_FUNCTION(pthread_getschedparam);
|
||||
#else
|
||||
#define INIT_PTHREAD_GETSCHEDPARAM
|
||||
#endif
|
||||
|
||||
#define SANITIZER_COMMON_INTERCEPTORS_INIT \
|
||||
INIT_STRCASECMP; \
|
||||
INIT_STRNCASECMP; \
|
||||
INIT_READ; \
|
||||
INIT_PREAD; \
|
||||
INIT_PREAD64; \
|
||||
INIT_PRCTL; \
|
||||
INIT_WRITE; \
|
||||
INIT_PWRITE; \
|
||||
INIT_PWRITE64; \
|
||||
INIT_LOCALTIME_AND_FRIENDS; \
|
||||
INIT_SCANF; \
|
||||
INIT_FREXP; \
|
||||
INIT_FREXPF_FREXPL; \
|
||||
INIT_GETPWNAM_AND_FRIENDS; \
|
||||
INIT_GETPWNAM_R_AND_FRIENDS; \
|
||||
INIT_CLOCK_GETTIME; \
|
||||
INIT_GETITIMER; \
|
||||
INIT_TIME; \
|
||||
INIT_GLOB; \
|
||||
INIT_WAIT; \
|
||||
INIT_INET;
|
||||
#define SANITIZER_COMMON_INTERCEPTORS_INIT \
|
||||
INIT_STRCASECMP; \
|
||||
INIT_STRNCASECMP; \
|
||||
INIT_READ; \
|
||||
INIT_PREAD; \
|
||||
INIT_PREAD64; \
|
||||
INIT_PRCTL; \
|
||||
INIT_WRITE; \
|
||||
INIT_PWRITE; \
|
||||
INIT_PWRITE64; \
|
||||
INIT_LOCALTIME_AND_FRIENDS; \
|
||||
INIT_SCANF; \
|
||||
INIT_FREXP; \
|
||||
INIT_FREXPF_FREXPL; \
|
||||
INIT_GETPWNAM_AND_FRIENDS; \
|
||||
INIT_GETPWNAM_R_AND_FRIENDS; \
|
||||
INIT_CLOCK_GETTIME; \
|
||||
INIT_GETITIMER; \
|
||||
INIT_TIME; \
|
||||
INIT_GLOB; \
|
||||
INIT_WAIT; \
|
||||
INIT_INET; \
|
||||
INIT_PTHREAD_GETSCHEDPARAM;
|
||||
|
|
|
@ -69,5 +69,7 @@
|
|||
# define SANITIZER_INTERCEPT_GLOB SI_LINUX_NOT_ANDROID
|
||||
# define SANITIZER_INTERCEPT_WAIT SI_NOT_WINDOWS
|
||||
# define SANITIZER_INTERCEPT_INET SI_NOT_WINDOWS
|
||||
# define SANITIZER_INTERCEPT_PTHREAD_GETSCHEDPARAM \
|
||||
SI_MAC || SI_LINUX_NOT_ANDROID
|
||||
|
||||
#endif // #ifndef SANITIZER_PLATFORM_INTERCEPTORS_H
|
||||
|
|
|
@ -179,6 +179,7 @@ void StatOutput(u64 *stat) {
|
|||
name[StatInt_pthread_barrier_destroy] = " pthread_barrier_destroy ";
|
||||
name[StatInt_pthread_barrier_wait] = " pthread_barrier_wait ";
|
||||
name[StatInt_pthread_once] = " pthread_once ";
|
||||
name[StatInt_pthread_getschedparam] = " pthread_getschedparam ";
|
||||
name[StatInt_sem_init] = " sem_init ";
|
||||
name[StatInt_sem_destroy] = " sem_destroy ";
|
||||
name[StatInt_sem_wait] = " sem_wait ";
|
||||
|
|
|
@ -174,6 +174,7 @@ enum StatType {
|
|||
StatInt_pthread_barrier_destroy,
|
||||
StatInt_pthread_barrier_wait,
|
||||
StatInt_pthread_once,
|
||||
StatInt_pthread_getschedparam,
|
||||
StatInt_sem_init,
|
||||
StatInt_sem_destroy,
|
||||
StatInt_sem_wait,
|
||||
|
|
Loading…
Reference in New Issue