- Notifications
You must be signed in to change notification settings - Fork 15.3k
[HWASan] Delete the print-memory-usage-android.c test #66550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This test asserts that HWASan memory usage can be gathered from /proc/$PID/maps. This worked because the old Android-specific versions of the anonymous mmap patches functioned by providing a userland cstring pointer to the kernel, and the underlying cstring was collected from that pointer address dynamically when /proc/$PID/maps was being decorated. This had some obvious flaws, you had to keep the string around for the lifetime of the program. Now, the official kernel implementation of this is to copy the string into a kernel struct at prctl()-time. Thus, the name that you give at prctl()-time sticks around and can't be changed by userspace outside of another prctl call. This breaks the feature, but this is fine, it's not like anyone's really relying on it anyway. So, let's make sure we don't continue failing the test on new versions of Android where the kernel has the upstream version of the named-anonymous-mappings work.
| @llvm/pr-subscribers-compiler-rt-sanitizer ChangesThis test asserts that HWASan memory usage can be gathered from Now, the official kernel implementation of this is to copy the string Full diff: https://github.com/llvm/llvm-project/pull/66550.diff 1 Files Affected:
diff --git a/compiler-rt/test/hwasan/TestCases/print-memory-usage-android.c b/compiler-rt/test/hwasan/TestCases/print-memory-usage-android.c deleted file mode 100644 index 5a057928ba7521c..000000000000000 --- a/compiler-rt/test/hwasan/TestCases/print-memory-usage-android.c +++ /dev/null @@ -1,21 +0,0 @@ -// Tests __hwasan_print_memory_usage through /proc/$PID/maps. -// RUN: %clang_hwasan %s -o %t && %env_hwasan_opts=export_memory_stats=1 %run %t 2>&1 | FileCheck %s -// REQUIRES: android - -#include <sys/types.h> -#include <unistd.h> -#include <stdlib.h> -#include <stdio.h> - -// The function needs to be unsanitized in order for &cmd to be untagged. This -// address is passed to system() and then to execve() syscall. The tests need to -// run on unpatched linux kernel, which at this time does not accept tagged -// pointers in system call arguments (but there is hope: see -// https://lore.kernel.org/patchwork/cover/979328). -__attribute__((no_sanitize("hwaddress"))) -int main() { - char cmd[1024]; - snprintf(cmd, sizeof(cmd), "cat /proc/%d/maps", getpid()); - system(cmd); - // CHECK: HWASAN pid: [[PID:[0-9]*]] rss: {{.*}} threads: 1 stacks: [[STACKS:[0-9]*]] thr_aux: {{.*}} stack_depot: {{.*}} uniq_stacks: [[UNIQ_STACKS:[0-9]*]] heap: [[HEAP:[0-9]*]] -} |
This test asserts that HWASan memory usage can be gathered from /proc/$PID/maps. This worked because the old Android-specific versions of the anonymous mmap patches functioned by providing a userland cstring pointer to the kernel, and the underlying cstring was collected from that pointer address dynamically when /proc/$PID/maps was being decorated. This had some obvious flaws, you had to keep the string around for the lifetime of the program. Now, the official kernel implementation of this is to copy the string into a kernel struct at prctl()-time. Thus, the name that you give at prctl()-time sticks around and can't be changed by userspace outside of another prctl call. This breaks the feature, but this is fine, it's not like anyone's really relying on it anyway. So, let's make sure we don't continue failing the test on new versions of Android where the kernel has the upstream version of the named-anonymous-mappings work.
This test asserts that HWASan memory usage can be gathered from /proc/$PID/maps. This worked because the old Android-specific versions of the anonymous mmap patches functioned by providing a userland cstring pointer to the kernel, and the underlying cstring was collected from that pointer address dynamically when /proc/$PID/maps was being decorated. This had some obvious flaws, you had to keep the string around for the lifetime of the program. Now, the official kernel implementation of this is to copy the string into a kernel struct at prctl()-time. Thus, the name that you give at prctl()-time sticks around and can't be changed by userspace outside of another prctl call. This breaks the feature, but this is fine, it's not like anyone's really relying on it anyway. So, let's make sure we don't continue failing the test on new versions of Android where the kernel has the upstream version of the named-anonymous-mappings work.
This test asserts that HWASan memory usage can be gathered from /proc/$PID/maps. This worked because the old Android-specific versions of the anonymous mmap patches functioned by providing a userland cstring pointer to the kernel, and the underlying cstring was collected from that pointer address dynamically when /proc/$PID/maps was being decorated. This had some obvious flaws, you had to keep the string around for the lifetime of the program. Now, the official kernel implementation of this is to copy the string into a kernel struct at prctl()-time. Thus, the name that you give at prctl()-time sticks around and can't be changed by userspace outside of another prctl call. This breaks the feature, but this is fine, it's not like anyone's really relying on it anyway. So, let's make sure we don't continue failing the test on new versions of Android where the kernel has the upstream version of the named-anonymous-mappings work.
This test asserts that HWASan memory usage can be gathered from
/proc/$PID/maps. This worked because the old Android-specific versions
of the anonymous mmap patches functioned by providing a userland cstring
pointer to the kernel, and the underlying cstring was collected from
that pointer address dynamically when /proc/$PID/maps was being
decorated. This had some obvious flaws, you had to keep the string
around for the lifetime of the program.
Now, the official kernel implementation of this is to copy the string
into a kernel struct at prctl()-time. Thus, the name that you give at
prctl()-time sticks around and can't be changed by userspace outside of
another prctl call. This breaks the feature, but this is fine, it's not
like anyone's really relying on it anyway. So, let's make sure we don't
continue failing the test on new versions of Android where the kernel
has the upstream version of the named-anonymous-mappings work.