Fix: vendor public libraries are accessible via System.loadLibrary
This CL fixes the problem that vendor public libraries (libs that are listed in /vendor/etc/public.libraries.txt) are not loadable via System.loadLibrary(). (Note that the libs were accessible via dlopen() though.) The problem was happening because when System.loadLibary() is called, the classloader first checks whether the lib is found and accessible in its own native lib search paths. The native lib search paths basically come from the java.library.path property, which in turn is from namespace.default.search.path in /system/etc/ld.config.txt. When VNDK is enforced starting from P, namespace.default.search.path does not have paths other than /system/lib because otherwise system process can have unlimited access to libs in vendor partition. The linker namespace is dynamically configured by the libnativeloader so that only the public vendor libs are accessible. However, as a side effect of removing /vendor/lib from namespace.default.search.path, the classloader always fails to find any lib under /vendor/lib even if the lib is a public one. In order to solve the problem, while keeping rest of the non-public vendor libs from apps, /vendor/lib (and /odm/lib and /product/lib as well) is added to the classloader AFTER native loader is created for the classloader. Bug: 93333337 Test: m -j Test: System.loadLibrary("adsprpc") is successful in Pixel (because libadsprpc.so is in Pixel's vendor public lib list) Test: atest cts/tests/tests/jni Change-Id: Iac12384548cbdd51234568082d02eeba466c160c
Loading
Please register or sign in to comment