[compiler-rt] 231d3e5 - [HWASan] Delete the print-memory-usage-android.c test (#66550)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 15 14:25:51 PDT 2023


Author: Mitch Phillips
Date: 2023-09-15T14:25:46-07:00
New Revision: 231d3e50be32bdc37e46de7ea0cd3faf18ef7b1c

URL: https://github.com/llvm/llvm-project/commit/231d3e50be32bdc37e46de7ea0cd3faf18ef7b1c
DIFF: https://github.com/llvm/llvm-project/commit/231d3e50be32bdc37e46de7ea0cd3faf18ef7b1c.diff

LOG: [HWASan] Delete the print-memory-usage-android.c test (#66550)

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.

Added: 
    

Modified: 
    

Removed: 
    compiler-rt/test/hwasan/TestCases/print-memory-usage-android.c


################################################################################
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]*]]
-}


        


More information about the llvm-commits mailing list