Skip to content

Commit 9d90ae2

Browse files
narayankandi34
authored andcommitted
Zygote: Additional whitelisting for legacy devices.
On M and below, we provide a blanket whitelist for all files under "/vendor/zygote_whitelist". This path is whitelisted purely to allow this patch to be applied easily on legacy devices and configurations. Note that this does not amount to a loosening of our security policy because whitelisted files are reopened anyway. Bug: 32691930 Test: manual (cherry-picked from commit 5e2f7c6229d7191183888d685b57a7d0a2835fce) Change-Id: I12a3f0d84e3b7454e77f917b71960cd81e2309e3
1 parent c113e5e commit 9d90ae2

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

vm/native/fd_utils-inl.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ class FileDescriptorInfo {
244244
is_sock(false) {
245245
}
246246

247+
static bool StartsWith(const std::string& str, const std::string& prefix) {
248+
return str.compare(0, prefix.size(), prefix) == 0;
249+
}
250+
247251
// Returns true iff. a given path is whitelisted. A path is whitelisted
248252
// if it belongs to the whitelist (see kPathWhitelist) or if it's a path
249253
// under /system/framework that ends with ".jar".
@@ -256,10 +260,18 @@ class FileDescriptorInfo {
256260

257261
static const std::string kFrameworksPrefix = "/system/framework/";
258262
static const std::string kJarSuffix = ".jar";
259-
if (path.compare(0, kFrameworksPrefix.size(), kFrameworksPrefix) == 0 &&
263+
if (StartsWith(path, kFrameworksPrefix) &&
260264
path.compare(path.size() - kJarSuffix.size(), kJarSuffix.size(), kJarSuffix) == 0) {
261265
return true;
262266
}
267+
268+
// All regular files that are placed under this path are whitelisted
269+
// automatically.
270+
static const std::string kZygoteWhitelistPath = "/vendor/zygote_whitelist/";
271+
if (StartsWith(path, kZygoteWhitelistPath) && path.find("/../") == std::string::npos) {
272+
return true;
273+
}
274+
263275
return false;
264276
}
265277

0 commit comments

Comments
 (0)