[PATCH] D65245: [profile] In Android, do not mkdir() dirs in GCOV_PREFIX
Pirama Arumuga Nainar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 24 15:14:10 PDT 2019
pirama created this revision.
pirama added reviewers: srhines, davidxl.
Herald added subscribers: Sanitizers, krytarowski.
Herald added projects: Sanitizers, LLVM.
In Android, attempting to mkdir() or even stat() top-level directories
like /data causes noisy selinux denials. During whole-system coverage
instrumentation, this causes a deluge of noisy messages that drown out
legitimate selinux denials, that should be audited and fixed.
To avoid this, skip creating any directory in GCOV_PREFIX (thereby
assuming that it exists).
- Android platform ensures that the GCOV_PREFIX used in Android is
created and read/writable by all processes.
- This only affects the Android platform (by checking against
__ANDROID_API_FUTURE__) and for apps built with Clang coverage, the
runtime will still create any non-existent parent directories for the
coverage files.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D65245
Files:
compiler-rt/lib/profile/InstrProfilingUtil.c
Index: compiler-rt/lib/profile/InstrProfilingUtil.c
===================================================================
--- compiler-rt/lib/profile/InstrProfilingUtil.c
+++ compiler-rt/lib/profile/InstrProfilingUtil.c
@@ -44,6 +44,17 @@
char save = path[i];
if (!IS_DIR_SEPARATOR(path[i]))
continue;
+
+#if defined(__ANDROID__) && defined(__ANDROID_API__) && \
+ defined(__ANDROID_API_FUTURE__) && __ANDROID_API__==__ANDROID_API_FUTURE__
+ // Avoid spammy selinux denial messages in Android by not attempting to
+ // create directories in GCOV_PREFIX. These denials occur when creating (or
+ // even attempting to stat()) top-level directories like "/data".
+ const char *gcov_prefix = getenv("GCOV_PREFIX");
+ if (gcov_prefix != NULL && strncmp(path, gcov_prefix, i) == 0)
+ continue;
+#endif
+
path[i] = '\0';
#ifdef _WIN32
_mkdir(path);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65245.211608.patch
Type: text/x-patch
Size: 892 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190724/5d8eb9d6/attachment.bin>
More information about the llvm-commits
mailing list