From a229d3e23ec5988424f3023c4e9becd80bf2c720 Mon Sep 17 00:00:00 2001 From: Jayant Chowdhary Date: Mon, 11 Mar 2019 08:26:22 -0700 Subject: [PATCH] Special case init for android_is_in_vendor_process. Init is executed without ld.config..txt loaded (since sysprop service isn't up in order for it to read ro.vndk.version and know ). It uses the hard-coded namespaces in the linker and therefore, does not know about the vndk namespace. That does not mean it is not a system process. Bug: 124128212 Test: Boot up device with selinux enforced, use camera to take pictures/ record videos (sanity) Test: Watch movies on youtube (sanity) Change-Id: If8701af2ee5dfa3bb36d0ce0a17a23808d184d9f Signed-off-by: Jayant Chowdhary --- libvndksupport/linker.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libvndksupport/linker.c b/libvndksupport/linker.c index 821940ac4..84c21324f 100644 --- a/libvndksupport/linker.c +++ b/libvndksupport/linker.c @@ -20,6 +20,8 @@ #define LOG_TAG "vndksupport" #include +#include +#include __attribute__((weak)) extern struct android_namespace_t* android_get_exported_namespace(const char*); __attribute__((weak)) extern void* android_dlopen_ext(const char*, int, const android_dlextinfo*); @@ -46,6 +48,11 @@ static struct android_namespace_t* get_vendor_namespace() { } int android_is_in_vendor_process() { + // Special case init, since when init runs, ld.config..txt hasn't been + // loaded (sysprop service isn't up for init to know ). + if (getpid() == 1) { + return 0; + } if (android_get_exported_namespace == NULL) { ALOGD("android_get_exported_namespace() not available. Assuming system process."); return 0;