From fa4971f3c366e4c29857228ce14208fbd3ddf47b Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Tue, 2 Apr 2019 09:58:00 +0900 Subject: [PATCH] Search rs namespace prior to vndk namespace With the recent change that removed get_exported_namespace out of libdl, the RenderScript SP-HAL stopped using android_dlopen_ext which it used to load libRS_internal.so in the "rs" namespace. Instead, it now falls back to the ordinary dlopen() call. The dlopen() call tries to load the lib in the current namespace (which is sphal) and then falls back to the linked namespaces: default, vndk, rs. The problem is that rs is listed as the last namespace and therefore the linker tries the namespace only when it failed to load the library in other namespaces: default and vndk. libRS_internal.so is accessible to both vndk and rs namespaces. So, the dlopen() call always goes into the vndk namespace and there is no chance for the lib to be loaded in the rs namespace. To fix the problem, the rs namespace is placed before vndk so that the namespace is tried first. Bug: 129550847 Test: runtest -x cts/tests/camera/src/android/hardware/ Change-Id: Idafc32f8a309dd12495768931d7ea17a2f791c50 --- rootdir/etc/ld.config.txt | 12 +++++++----- rootdir/etc/ld.config.vndk_lite.txt | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/rootdir/etc/ld.config.txt b/rootdir/etc/ld.config.txt index 2b0ef4cb6..84651fbc5 100644 --- a/rootdir/etc/ld.config.txt +++ b/rootdir/etc/ld.config.txt @@ -253,17 +253,19 @@ namespace.sphal.asan.permitted.paths += /data/asan/vendor/${LIB} namespace.sphal.asan.permitted.paths += /vendor/${LIB} # Once in this namespace, access to libraries in /system/lib is restricted. Only -# libs listed here can be used. -namespace.sphal.links = default,vndk,rs +# libs listed here can be used. Order is important here as the namespaces are +# tried in this order. rs should be before vndk because both are capable +# of loading libRS_internal.so +namespace.sphal.links = rs,default,vndk + +# Renderscript gets separate namespace +namespace.sphal.link.rs.shared_libs = libRS_internal.so namespace.sphal.link.default.shared_libs = %LLNDK_LIBRARIES% namespace.sphal.link.default.shared_libs += %SANITIZER_RUNTIME_LIBRARIES% namespace.sphal.link.vndk.shared_libs = %VNDK_SAMEPROCESS_LIBRARIES% -# Renderscript gets separate namespace -namespace.sphal.link.rs.shared_libs = libRS_internal.so - ############################################################################### # "rs" namespace # diff --git a/rootdir/etc/ld.config.vndk_lite.txt b/rootdir/etc/ld.config.vndk_lite.txt index c8312df39..272485f80 100644 --- a/rootdir/etc/ld.config.vndk_lite.txt +++ b/rootdir/etc/ld.config.vndk_lite.txt @@ -195,17 +195,19 @@ namespace.sphal.asan.permitted.paths += /data/asan/vendor/${LIB} namespace.sphal.asan.permitted.paths += /vendor/${LIB} # Once in this namespace, access to libraries in /system/lib is restricted. Only -# libs listed here can be used. -namespace.sphal.links = default,vndk,rs +# libs listed here can be used. Order is important here as the namespaces are +# tried in this order. rs should be before vndk because both are capable +# of loading libRS_internal.so +namespace.sphal.links = rs,default,vndk + +# Renderscript gets separate namespace +namespace.sphal.link.rs.shared_libs = libRS_internal.so namespace.sphal.link.default.shared_libs = %LLNDK_LIBRARIES% namespace.sphal.link.default.shared_libs += %SANITIZER_RUNTIME_LIBRARIES% namespace.sphal.link.vndk.shared_libs = %VNDK_SAMEPROCESS_LIBRARIES% -# Renderscript gets separate namespace -namespace.sphal.link.rs.shared_libs = libRS_internal.so - ############################################################################### # "rs" namespace #