summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Calin Juravle <calin@google.com> 2016-02-23 19:06:45 +0000
committer Calin Juravle <calin@google.com> 2016-03-01 15:57:46 +0000
commitdb0326a56ed8cc1ba2ed5ec2810afe49bcd9a596 (patch)
tree93df970b73fe0cdb5cd323a5290eed2220edd525
parentc4e490047a7dd605fb087b71d3b97182e409985c (diff)
Return an error if try to profile guide compile to a public oat file
This makes sure that the oat file access is private to the app when using profiles. Bug: 27334750 Bug: 26080105 Change-Id: I9f5deec1a1068d0276928117134956eb233ce504
-rw-r--r--cmds/installd/commands.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/cmds/installd/commands.cpp b/cmds/installd/commands.cpp
index e31c6e20e1..589b9c7aa2 100644
--- a/cmds/installd/commands.cpp
+++ b/cmds/installd/commands.cpp
@@ -1276,12 +1276,20 @@ int dexopt(const char* apk_path, uid_t uid, const char* pkgname, const char* ins
char in_odex_path[PKG_PATH_MAX];
int res;
fd_t input_fd=-1, out_fd=-1, image_fd=-1, swap_fd=-1;
- bool is_public = (dexopt_flags & DEXOPT_PUBLIC) != 0;
+ bool is_public = ((dexopt_flags & DEXOPT_PUBLIC) != 0);
bool vm_safe_mode = (dexopt_flags & DEXOPT_SAFEMODE) != 0;
bool debuggable = (dexopt_flags & DEXOPT_DEBUGGABLE) != 0;
bool boot_complete = (dexopt_flags & DEXOPT_BOOTCOMPLETE) != 0;
bool extract_only = (dexopt_flags & DEXOPT_EXTRACTONLY) != 0;
fd_t reference_profile_fd = -1;
+
+ if (is_public && use_profiles) {
+ // We should not give public access to apks compiled with profile information.
+ // Log an error and return early if are asked to do so.
+ ALOGE("use_profiles should not be used with is_public.");
+ return -1;
+ }
+
if (use_profiles) {
if (analyse_profiles(uid, pkgname)) {
// Open again reference profile in read only mode as dex2oat does not get write