[compiler-rt] [asan] NPD calling prctl with PR_SET_VMA PR_SET_VMA_ANON_NAME and nullptr for name (PR #160824)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 29 00:26:50 PDT 2025
https://github.com/woruyu updated https://github.com/llvm/llvm-project/pull/160824
>From ef65f38e2a14a7ff9bbfdad418dfc37e779410e4 Mon Sep 17 00:00:00 2001
From: woruyu <1214539920 at qq.com>
Date: Thu, 25 Sep 2025 22:47:14 -0900
Subject: [PATCH 1/3] [asan] NPD calling prctl with PR_SET_VMA
PR_SET_VMA_ANON_NAME and nullptr for name
---
.../lib/sanitizer_common/sanitizer_common_interceptors.inc | 2 +-
compiler-rt/test/sanitizer_common/TestCases/Linux/prctl.cpp | 4 ++++
2 files changed, 5 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 a96d325d08983..b10ce7fa44afc 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 dab1d1b48f868..a3bbeac15e906 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Linux/prctl.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/prctl.cpp
@@ -88,5 +88,9 @@ int main() {
res = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &pr);
assert(res == -1);
+ unsigned long name = reinterpret_cast<unsigned long>(nullptr);
+ res = prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, 0, 0, nullptr, name);
+ assert(res == 0);
+
return 0;
}
>From 2d445bf5c01d525eb8f58b8f374b697a960a4542 Mon Sep 17 00:00:00 2001
From: woruyu <1214539920 at qq.com>
Date: Thu, 25 Sep 2025 23:16:57 -0900
Subject: [PATCH 2/3] fix: details
---
compiler-rt/test/sanitizer_common/TestCases/Linux/prctl.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/prctl.cpp b/compiler-rt/test/sanitizer_common/TestCases/Linux/prctl.cpp
index a3bbeac15e906..dc7d330630aff 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Linux/prctl.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/prctl.cpp
@@ -89,7 +89,7 @@ int main() {
assert(res == -1);
unsigned long name = reinterpret_cast<unsigned long>(nullptr);
- res = prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, 0, 0, nullptr, name);
+ res = prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, 0, nullptr, name);
assert(res == 0);
return 0;
>From 60cbd49c8d3dfd883bc4170974a27d02ebee6bb2 Mon Sep 17 00:00:00 2001
From: woruyu <1214539920 at qq.com>
Date: Sun, 28 Sep 2025 22:26:09 -0900
Subject: [PATCH 3/3] fix: review
---
compiler-rt/test/sanitizer_common/TestCases/Linux/prctl.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/prctl.cpp b/compiler-rt/test/sanitizer_common/TestCases/Linux/prctl.cpp
index dc7d330630aff..afce9dc03dada 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Linux/prctl.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/prctl.cpp
@@ -89,8 +89,7 @@ int main() {
assert(res == -1);
unsigned long name = reinterpret_cast<unsigned long>(nullptr);
- res = prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, 0, nullptr, name);
- assert(res == 0);
+ prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, 0, nullptr, name);
return 0;
}
More information about the llvm-commits
mailing list