[sanitizer] Intercept initgroups.

llvm-svn: 193158
This commit is contained in:
Evgeniy Stepanov 2013-10-22 12:24:48 +00:00
parent eb68d9d985
commit 0229c09d43
5 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,11 @@
// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t
#include <sys/types.h>
#include <grp.h>
int main(void) {
initgroups("root", 0);
// The above fails unless you are root. Does not matter, MSan false positive
// (which we are testing for) happens anyway.
return 0;
}

View File

@ -2408,6 +2408,19 @@ INTERCEPTOR(int, fstatvfs64, int fd, void *buf) {
#define INIT_STATVFS64
#endif
#if SANITIZER_INTERCEPT_INITGROUPS
INTERCEPTOR(int, initgroups, char *user, u32 group) {
void *ctx;
COMMON_INTERCEPTOR_ENTER(ctx, initgroups, user, group);
if (user) COMMON_INTERCEPTOR_READ_RANGE(ctx, user, REAL(strlen)(user) + 1);
int res = REAL(initgroups)(user, group);
return res;
}
#define INIT_INITGROUPS INTERCEPT_FUNCTION(initgroups);
#else
#define INIT_INITGROUPS
#endif
#define SANITIZER_COMMON_INTERCEPTORS_INIT \
INIT_STRCMP; \
INIT_STRNCMP; \
@ -2498,4 +2511,5 @@ INTERCEPTOR(int, fstatvfs64, int fd, void *buf) {
INIT_STATFS64; \
INIT_STATVFS; \
INIT_STATVFS64; \
INIT_INITGROUPS; \
/**/

View File

@ -132,6 +132,7 @@
# define SANITIZER_INTERCEPT_STATFS64 SI_MAC || SI_LINUX_NOT_ANDROID
# define SANITIZER_INTERCEPT_STATVFS SI_LINUX_NOT_ANDROID
# define SANITIZER_INTERCEPT_STATVFS64 SI_LINUX_NOT_ANDROID
# define SANITIZER_INTERCEPT_INITGROUPS SI_NOT_WINDOWS
# define SANITIZER_INTERCEPT__EXIT SI_LINUX

View File

@ -384,6 +384,7 @@ void StatOutput(u64 *stat) {
name[StatInt_statvfs64] = " statvfs64 ";
name[StatInt_fstatvfs] = " fstatvfs ";
name[StatInt_fstatvfs64] = " fstatvfs64 ";
name[StatInt_initgroups] = " initgroups ";
name[StatAnnotation] = "Dynamic annotations ";
name[StatAnnotateHappensBefore] = " HappensBefore ";

View File

@ -379,6 +379,7 @@ enum StatType {
StatInt_statvfs64,
StatInt_fstatvfs,
StatInt_fstatvfs64,
StatInt_initgroups,
// Dynamic annotations.
StatAnnotation,