Convert paths to lower filesystem paths during setupAppDir

Making FUSE request from vold is risky because the FUSE daemon may be
down and vold could get wedged.

Additionally, the FUSE daemon only responds to requests with matching
user id paths, i.e requests on /mnt/user/0/emulated/10 will fail.
So if vold (running as user 0) makes a request on
/storage/emulated/10, it really means /mnt/user/0/emulated/10
which will fail if it gets to the FUSE daemon.

TODO: Fix the lower filesystem paths to support devices without
sdcardfs

Bug: 141540368
Change-Id: I90d698f6aecd114d75b6d578ad08620988da7d7d
atest: atest android.appsecurity.cts.ExternalStorageHostTest#testMediaSandboxedFull
gugelfrei
Zim 5 years ago
parent e3102990ca
commit c59d774149

@ -815,13 +815,21 @@ int VolumeManager::setupAppDir(const std::string& path, const std::string& appDi
return -EINVAL;
}
// Convert paths to lower filesystem paths to avoid making FUSE requests for these reasons:
// 1. A FUSE request from vold puts vold at risk of hanging if the FUSE daemon is down
// 2. The FUSE daemon prevents requests on /mnt/user/0/emulated/<userid != 0> and a request
// on /storage/emulated/10 means /mnt/user/0/emulated/10
// TODO(b/146419093): Use lower filesystem paths that don't depend on sdcardfs
const std::string lowerPath = "/mnt/runtime/default/" + path.substr(9);
const std::string lowerAppDirRoot = "/mnt/runtime/default/" + appDirRoot.substr(9);
// First create the root which holds app dirs, if needed.
int ret = PrepareDirsFromRoot(appDirRoot, "/storage/", 0771, AID_MEDIA_RW, AID_MEDIA_RW);
int ret = PrepareDirsFromRoot(lowerAppDirRoot, "/mnt/runtime/default/", 0771, AID_MEDIA_RW, AID_MEDIA_RW);
if (ret != 0) {
return ret;
}
// Then, create app-specific dirs with the correct UID/GID
return PrepareDirsFromRoot(path, appDirRoot, 0770, appUid, AID_MEDIA_RW);
return PrepareDirsFromRoot(lowerPath, lowerAppDirRoot, 0770, appUid, AID_MEDIA_RW);
}
int VolumeManager::createObb(const std::string& sourcePath, const std::string& sourceKey,

Loading…
Cancel
Save