diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc index 507c181f0526103dba0602fa289d917bc7d30125..4ecd2ab000b03f0bb47639cba2840bbbbeac80e0 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -1370,7 +1370,9 @@ INTERCEPTOR(int, prctl, int option, unsigned long arg2, unsigned long arg3, static const int PR_SET_VMA = 0x53564d41; static const int PR_SCHED_CORE = 62; static const int PR_SCHED_CORE_GET = 0; - if (option == PR_SET_VMA && arg2 == 0UL) { + // OHOS_LOCAL + // The arg5 can be nullptr here, skip this check if so. + if (option == PR_SET_VMA && arg2 == 0UL && arg5) { char *name = (char *)arg5; COMMON_INTERCEPTOR_READ_RANGE(ctx, name, internal_strlen(name) + 1); } diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/prctl.cpp b/compiler-rt/test/sanitizer_common/TestCases/Linux/prctl.cpp index 581739500e7a9ee63b7210b6ec9be63817eb49f7..c02acdb380e29619eb7dafab744564c81df7db6c 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/Linux/prctl.cpp +++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/prctl.cpp @@ -58,6 +58,12 @@ int main() { if (res < 0) { assert(errno == EINVAL); } + + res = prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, (uintptr_t)p, 128, NULL); + if (res < 0) { + assert(errno == EINVAL); + } + munmap(p, 128); return 0;