Merge "Don't include inaccessible data dirs in library paths." into rvc-qpr-dev am: 56dc3f4122
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12248782 Change-Id: Ifa14d8729ce4b0a34fd8cf3657c19e405fa0a5be
This commit is contained in:
@@ -802,12 +802,9 @@ public final class LoadedApk {
|
|||||||
|
|
||||||
makePaths(mActivityThread, isBundledApp, mApplicationInfo, zipPaths, libPaths);
|
makePaths(mActivityThread, isBundledApp, mApplicationInfo, zipPaths, libPaths);
|
||||||
|
|
||||||
String libraryPermittedPath = mDataDir;
|
// Including an inaccessible dir in libraryPermittedPath would cause SELinux denials
|
||||||
if (mActivityThread == null) {
|
// when the loader attempts to canonicalise the path. so we don't.
|
||||||
// In a zygote context where mActivityThread is null we can't access the app data dir
|
String libraryPermittedPath = canAccessDataDir() ? mDataDir : "";
|
||||||
// and including this in libraryPermittedPath would cause SELinux denials.
|
|
||||||
libraryPermittedPath = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isBundledApp) {
|
if (isBundledApp) {
|
||||||
// For bundled apps, add the base directory of the app (e.g.,
|
// For bundled apps, add the base directory of the app (e.g.,
|
||||||
@@ -951,6 +948,33 @@ public final class LoadedApk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return whether we can access the package's private data directory in order to be able to
|
||||||
|
* load code from it.
|
||||||
|
*/
|
||||||
|
private boolean canAccessDataDir() {
|
||||||
|
// In a zygote context where mActivityThread is null we can't access the app data dir.
|
||||||
|
if (mActivityThread == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A package can access its own data directory (the common case, so short-circuit it).
|
||||||
|
if (Objects.equals(mPackageName, ActivityThread.currentPackageName())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Temporarily disable logging of disk reads on the Looper thread as this is necessary -
|
||||||
|
// and the loader will access the directory anyway if we don't check it.
|
||||||
|
StrictMode.ThreadPolicy oldPolicy = allowThreadDiskReads();
|
||||||
|
try {
|
||||||
|
// We are constructing a classloader for a different package. It is likely,
|
||||||
|
// but not certain, that we can't acccess its app data dir - so check.
|
||||||
|
return new File(mDataDir).canExecute();
|
||||||
|
} finally {
|
||||||
|
setThreadPolicy(oldPolicy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
public ClassLoader getClassLoader() {
|
public ClassLoader getClassLoader() {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
|
|||||||
Reference in New Issue
Block a user