From 819d695fed23613b4ce5cbe698b37bbcfbf2f928 Mon Sep 17 00:00:00 2001 From: haotuo Date: Sun, 4 Jun 2023 19:42:00 +0800 Subject: [PATCH] [sanitizer] Fix arm asan app get segv because of 32bit time_t passed to time ISSUE:#I7AQT1 Test: IDE asan app startup and asan detect test Signed-off-by: haotuo Change-Id: Ie807bb0743611581c7e48d67980da6c6b6b05a2c --- .../sanitizer_common_interceptors.inc | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc index 4ecd2ab000b0..006d5a9f5d38 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -1393,12 +1393,12 @@ INTERCEPTOR(int, prctl, int option, unsigned long arg2, unsigned long arg3, #endif // SANITIZER_INTERCEPT_PRCTL #if SANITIZER_INTERCEPT_TIME -INTERCEPTOR(unsigned long, time, unsigned long *t) { +INTERCEPTOR(__sanitizer_time_t, time, __sanitizer_time_t *t) { // OHOS_LOCAL void *ctx; COMMON_INTERCEPTOR_ENTER(ctx, time, t); - unsigned long local_t; - unsigned long res = REAL(time)(&local_t); - if (t && res != (unsigned long)-1) { + __sanitizer_time_t local_t; // OHOS_LOCAL + __sanitizer_time_t res = REAL(time)(&local_t); // OHOS_LOCAL + if (t && res != -1) { COMMON_INTERCEPTOR_WRITE_RANGE(ctx, t, sizeof(*t)); *t = local_t; } @@ -1421,7 +1421,7 @@ static void unpoison_tm(void *ctx, __sanitizer_tm *tm) { } #endif } -INTERCEPTOR(__sanitizer_tm *, localtime, unsigned long *timep) { +INTERCEPTOR(__sanitizer_tm *, localtime, __sanitizer_time_t *timep) { // OHOS_LOCAL void *ctx; COMMON_INTERCEPTOR_ENTER(ctx, localtime, timep); __sanitizer_tm *res = REAL(localtime)(timep); @@ -1431,7 +1431,7 @@ INTERCEPTOR(__sanitizer_tm *, localtime, unsigned long *timep) { } return res; } -INTERCEPTOR(__sanitizer_tm *, localtime_r, unsigned long *timep, void *result) { +INTERCEPTOR(__sanitizer_tm *, localtime_r, __sanitizer_time_t *timep, void *result) { // OHOS_LOCAL void *ctx; COMMON_INTERCEPTOR_ENTER(ctx, localtime_r, timep, result); __sanitizer_tm *res = REAL(localtime_r)(timep, result); @@ -1441,7 +1441,7 @@ INTERCEPTOR(__sanitizer_tm *, localtime_r, unsigned long *timep, void *result) { } return res; } -INTERCEPTOR(__sanitizer_tm *, gmtime, unsigned long *timep) { +INTERCEPTOR(__sanitizer_tm *, gmtime, __sanitizer_time_t *timep) { // OHOS_LOCAL void *ctx; COMMON_INTERCEPTOR_ENTER(ctx, gmtime, timep); __sanitizer_tm *res = REAL(gmtime)(timep); @@ -1451,7 +1451,7 @@ INTERCEPTOR(__sanitizer_tm *, gmtime, unsigned long *timep) { } return res; } -INTERCEPTOR(__sanitizer_tm *, gmtime_r, unsigned long *timep, void *result) { +INTERCEPTOR(__sanitizer_tm *, gmtime_r, __sanitizer_time_t *timep, void *result) { // OHOS_LOCAL void *ctx; COMMON_INTERCEPTOR_ENTER(ctx, gmtime_r, timep, result); __sanitizer_tm *res = REAL(gmtime_r)(timep, result); @@ -1461,7 +1461,7 @@ INTERCEPTOR(__sanitizer_tm *, gmtime_r, unsigned long *timep, void *result) { } return res; } -INTERCEPTOR(char *, ctime, unsigned long *timep) { +INTERCEPTOR(char *, ctime, __sanitizer_time_t *timep) { // OHOS_LOCAL void *ctx; COMMON_INTERCEPTOR_ENTER(ctx, ctime, timep); // FIXME: under ASan the call below may write to freed memory and corrupt @@ -1474,7 +1474,7 @@ INTERCEPTOR(char *, ctime, unsigned long *timep) { } return res; } -INTERCEPTOR(char *, ctime_r, unsigned long *timep, char *result) { +INTERCEPTOR(char *, ctime_r, __sanitizer_time_t *timep, char *result) { // OHOS_LOCAL void *ctx; COMMON_INTERCEPTOR_ENTER(ctx, ctime_r, timep, result); // FIXME: under ASan the call below may write to freed memory and corrupt @@ -1513,7 +1513,7 @@ INTERCEPTOR(char *, asctime_r, __sanitizer_tm *tm, char *result) { } return res; } -INTERCEPTOR(long, mktime, __sanitizer_tm *tm) { +INTERCEPTOR(__sanitizer_time_t, mktime, __sanitizer_tm *tm) { // OHOS_LOCAL void *ctx; COMMON_INTERCEPTOR_ENTER(ctx, mktime, tm); COMMON_INTERCEPTOR_READ_RANGE(ctx, &tm->tm_sec, sizeof(tm->tm_sec)); @@ -1523,8 +1523,8 @@ INTERCEPTOR(long, mktime, __sanitizer_tm *tm) { COMMON_INTERCEPTOR_READ_RANGE(ctx, &tm->tm_mon, sizeof(tm->tm_mon)); COMMON_INTERCEPTOR_READ_RANGE(ctx, &tm->tm_year, sizeof(tm->tm_year)); COMMON_INTERCEPTOR_READ_RANGE(ctx, &tm->tm_isdst, sizeof(tm->tm_isdst)); - long res = REAL(mktime)(tm); - if (res != -1) unpoison_tm(ctx, tm); + __sanitizer_time_t res = REAL(mktime)(tm); // OHOS_LOCAL + if (res != (__sanitizer_time_t)-1) unpoison_tm(ctx, tm); // OHOS_LOCAL return res; } #define INIT_LOCALTIME_AND_FRIENDS \ -- Gitee