Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1edb92a3 authored by Zim's avatar Zim
Browse files

Fix installd mount paths with FUSE

When parsing mounts from procfs in installd, we should match against
/mnt/pass_through/0/ instead of /mnt/pass_through as the former is
guaranteed to always be mounted even when multiple users are running.

Additionally we can remove the hack added in
Iaeb9ea3db373d358251644a95b3390cfa2b8f24a to work around the fact that
the pass_through mount may not be mounted in some cases and so
fallback on the lower filesystem path. This fallback caused the linked
test to fail because sdcardfs cache got out of sync when we
deleted directories from the lower fileysystem and bypassed sdcardfs.

Bug: 135341433
Test: atest android.appsecurity.cts.StorageHostTest#testCache
Change-Id: I77ee304fc2e6c3a619d94ca66cd664df7f1743d6
parent 828a3e2b
Loading
Loading
Loading
Loading
+4 −15
Original line number Original line Diff line number Diff line
@@ -108,6 +108,8 @@ static constexpr const char* kFuseProp = "persist.sys.fuse";
 * Property to control if app data isolation is enabled.
 * Property to control if app data isolation is enabled.
 */
 */
static constexpr const char* kAppDataIsolationEnabledProperty = "persist.zygote.app_data_isolation";
static constexpr const char* kAppDataIsolationEnabledProperty = "persist.zygote.app_data_isolation";
static constexpr const char* kMntSdcardfs = "/mnt/runtime/default/";
static constexpr const char* kMntFuse = "/mnt/pass_through/0/";


static std::atomic<bool> sAppDataIsolationEnabled(false);
static std::atomic<bool> sAppDataIsolationEnabled(false);


@@ -2686,15 +2688,13 @@ binder::Status InstalldNativeService::invalidateMounts() {
        std::getline(in, ignored);
        std::getline(in, ignored);


        if (android::base::GetBoolProperty(kFuseProp, false)) {
        if (android::base::GetBoolProperty(kFuseProp, false)) {
            // TODO(b/146139106): Use sdcardfs mounts on devices running sdcardfs so we don't bypass
            if (target.find(kMntFuse) == 0) {
            // it's VFS cache
            if (target.compare(0, 17, "/mnt/pass_through") == 0) {
                LOG(DEBUG) << "Found storage mount " << source << " at " << target;
                LOG(DEBUG) << "Found storage mount " << source << " at " << target;
                mStorageMounts[source] = target;
                mStorageMounts[source] = target;
            }
            }
        } else {
        } else {
#if !BYPASS_SDCARDFS
#if !BYPASS_SDCARDFS
            if (target.compare(0, 21, "/mnt/runtime/default/") == 0) {
            if (target.find(kMntSdcardfs) == 0) {
                LOG(DEBUG) << "Found storage mount " << source << " at " << target;
                LOG(DEBUG) << "Found storage mount " << source << " at " << target;
                mStorageMounts[source] = target;
                mStorageMounts[source] = target;
            }
            }
@@ -2792,17 +2792,6 @@ std::string InstalldNativeService::findDataMediaPath(
    std::lock_guard<std::recursive_mutex> lock(mMountsLock);
    std::lock_guard<std::recursive_mutex> lock(mMountsLock);
    const char* uuid_ = uuid ? uuid->c_str() : nullptr;
    const char* uuid_ = uuid ? uuid->c_str() : nullptr;
    auto path = StringPrintf("%s/media", create_data_path(uuid_).c_str());
    auto path = StringPrintf("%s/media", create_data_path(uuid_).c_str());
    if (android::base::GetBoolProperty(kFuseProp, false)) {
        // TODO(b/146139106): This is only safe on devices not running sdcardfs where there is no
        // risk of bypassing the sdcardfs VFS cache

        // Always use the lower filesystem path on FUSE enabled devices not running sdcardfs
        // The upper filesystem path, /mnt/pass_through/<userid>/<vol>/ which was a bind mount
        // to the lower filesytem may have been unmounted already when a user is
        // removed and the path will now be pointing to a tmpfs without content
        return StringPrintf("%s/%u", path.c_str(), userid);
    }

    auto resolved = mStorageMounts[path];
    auto resolved = mStorageMounts[path];
    if (resolved.empty()) {
    if (resolved.empty()) {
        LOG(WARNING) << "Failed to find storage mount for " << path;
        LOG(WARNING) << "Failed to find storage mount for " << path;