From 7eacdf8e532839b75dd464b8f64a29845f8cb221 Mon Sep 17 00:00:00 2001 From: Martin Stjernholm Date: Tue, 13 Sep 2022 18:18:04 +0100 Subject: Allow the vendor partition to be in /system/vendor. With the changed logic in https://r.android.com/2211602 it would otherwise be treated as a system APK and given full access to system libraries, which would be unfortunate. /vendor must be a separate partition starting in U, but this is necessary for the module on S and T. A note on tests: It's difficult to set up fixtures to test /system/{product,vendor} paths if the device has them as symlinks to /{product,vendor}, because it would require moving the mount points and symlink in the other direction. Test: atest libnativeloader_e2e_tests Bug: 237577392 Change-Id: I9267c008db644ebe38f6215d3b692b98dd88ee34 --- libnativeloader/library_namespaces.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'libnativeloader/library_namespaces.cpp') diff --git a/libnativeloader/library_namespaces.cpp b/libnativeloader/library_namespaces.cpp index fd21f168ab..d49420f313 100644 --- a/libnativeloader/library_namespaces.cpp +++ b/libnativeloader/library_namespaces.cpp @@ -82,19 +82,22 @@ constexpr const char* kSharedNamespaceSuffix = "-shared"; constexpr const char* kAlwaysPermittedDirectories = "/data:/mnt/expand"; constexpr const char* kVendorLibPath = "/vendor/" LIB; +// TODO(mast): It's unlikely that both paths are necessary for kProductLibPath +// below, because they can't be two separate directories - either one has to be +// a symlink to the other. constexpr const char* kProductLibPath = "/product/" LIB ":/system/product/" LIB; constexpr const char* kSystemLibPath = "/system/" LIB ":/system_ext/" LIB; -const std::regex kVendorDexPathRegex("(^|:)/vendor/"); +const std::regex kVendorDexPathRegex("(^|:)(/system)?/vendor/"); const std::regex kProductDexPathRegex("(^|:)(/system)?/product/"); const std::regex kSystemDexPathRegex("(^|:)/system(_ext)?/"); // MUST be tested last. // Define origin partition of APK using ApkOrigin = enum { APK_ORIGIN_DEFAULT = 0, - APK_ORIGIN_VENDOR = 1, + APK_ORIGIN_VENDOR = 1, // Includes both /vendor and /system/vendor APK_ORIGIN_PRODUCT = 2, // Includes both /product and /system/product - APK_ORIGIN_SYSTEM = 3, // Includes both /system and /system_ext but not /system/product + APK_ORIGIN_SYSTEM = 3, // Includes both /system and /system_ext but not /system/{vendor,product} }; jobject GetParentClassLoader(JNIEnv* env, jobject class_loader) { -- cgit v1.2.3-59-g8ed1b