diff options
| author | 2017-11-22 23:09:23 -0800 | |
|---|---|---|
| committer | 2018-07-20 17:12:53 +0000 | |
| commit | 98df1b8ef2f8b904e1b032fff42e46b9b627b14e (patch) | |
| tree | e348c9e327f20a209dd73b5854ce64e7671f02f5 | |
| parent | 86e94acfa4aa643f8715e0d454ba2b63a73805ad (diff) | |
Check for /dev/memcg/system/tasks before writing to it
Fixes the following errors in the logs on devices without /dev/memcg
mounted:
09-08 10:07:22.991 732 732 E Zygote : couldn't write 1124 to
/dev/memcg/system/tasks
09-08 10:07:22.986 732 732 W main : type=1400 audit(0.0:8):
avc: denied { create } for name="tasks" scontext=u:r:zygote:s0
tcontext=u:object_r:cgroup:s0 tclass=file permissive=0
Bug: 67860826
Test: boot Taimen, no more error/denial in the logs.
Change-Id: I37f481fa4e9e9116688cca4f090aa26f96f602c9
Merged-In: I37f481fa4e9e9116688cca4f090aa26f96f602c9
(cherry picked from commit 6bdc3a28e75bdb936e7c172bc8d305b2c30c9f06)
| -rw-r--r-- | core/jni/com_android_internal_os_Zygote.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp index 8d6a2800a45d..c2582203afde 100644 --- a/core/jni/com_android_internal_os_Zygote.cpp +++ b/core/jni/com_android_internal_os_Zygote.cpp @@ -908,7 +908,10 @@ static jint com_android_internal_os_Zygote_nativeForkSystemServer( } // Assign system_server to the correct memory cgroup. - if (!WriteStringToFile(StringPrintf("%d", pid), "/dev/memcg/system/tasks")) { + // Not all devices mount /dev/memcg so check for the file first + // to avoid unnecessarily printing errors and denials in the logs. + if (!access("/dev/memcg/system/tasks", F_OK) && + !WriteStringToFile(StringPrintf("%d", pid), "/dev/memcg/system/tasks")) { ALOGE("couldn't write %d to /dev/memcg/system/tasks", pid); } } |