From eb1960c4812ca8ed4ef0e413f9b68178789c0f7a Mon Sep 17 00:00:00 2001 From: woruyu <1214539920@qq.com> Date: Tue, 30 Sep 2025 10:45:20 +0800 Subject: [PATCH] [sanitizer] Handle nullptr name in prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME) (#160824) ### Summary This PR resolves https://github.com/llvm/llvm-project/issues/160562 --- .../lib/sanitizer_common/sanitizer_common_interceptors.inc | 2 +- compiler-rt/test/sanitizer_common/TestCases/Linux/prctl.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc index a96d325d0898..b10ce7fa44af 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -1326,7 +1326,7 @@ PRCTL_INTERCEPTOR(int, prctl, int option, unsigned long arg2, static const int PR_SET_SECCOMP = 22; static const int SECCOMP_MODE_FILTER = 2; # endif - if (option == PR_SET_VMA && arg2 == 0UL) { + if (option == PR_SET_VMA && arg2 == 0UL && arg5 != 0UL) { 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 dab1d1b48f86..afce9dc03dad 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/Linux/prctl.cpp +++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/prctl.cpp @@ -88,5 +88,8 @@ int main() { res = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &pr); assert(res == -1); + unsigned long name = reinterpret_cast(nullptr); + prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, 0, nullptr, name); + return 0; }