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

Commit 14e084d3 authored by neo.chae's avatar neo.chae Committed by Andreas Gampe
Browse files

Installd: Disallow relocation for decryption



When decrypting a device, a tmpfs is temporarily mounted as /data,
the size of which is usually small. When the zygote, system server
and necessary apps are brought up, they will be compiled into the
tmpfs.

If the system image contains prebuilts, they will be relocated instead
of compiled. This is unnecessary. In this special situation it is
acceptable to run out of the prebuilt oat files without relocation,
which can save space in the tmpfs.

This patch ensures that apps are not being relocated.

Change-Id: I42bfb7e3039574b7e4f2772e0d395f093d59ed1b
Signed-off-by: default avatarHyangseok Chae <neo.chae@lge.com>
parent 033f7e8e
Loading
Loading
Loading
Loading
+24 −15
Original line number Diff line number Diff line
@@ -640,7 +640,7 @@ static int split_count(const char *str)
  return count;
}

static int split(char *buf, char **argv)
static int split(char *buf, const char **argv)
{
  char *ctx;
  int count = 0;
@@ -732,6 +732,9 @@ static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name,
    bool have_dex2oat_isa_variant = property_get(dex2oat_isa_variant_key,
                                                 dex2oat_isa_variant, NULL) > 0;

    const char *dex2oat_norelocation = "-Xnorelocate";
    bool have_dex2oat_relocation_skip_flag = false;

    char dex2oat_flags[PROPERTY_VALUE_MAX];
    int dex2oat_flags_count = property_get("dalvik.vm.dex2oat-flags",
                                 dex2oat_flags, NULL) <= 0 ? 0 : split_count(dex2oat_flags);
@@ -804,6 +807,7 @@ static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name,
    if (skip_compilation) {
        strcpy(dex2oat_compiler_filter_arg, "--compiler-filter=verify-none");
        have_dex2oat_compiler_filter_flag = true;
        have_dex2oat_relocation_skip_flag = true;
    } else if (vm_safe_mode) {
        strcpy(dex2oat_compiler_filter_arg, "--compiler-filter=interpret-only");
        have_dex2oat_compiler_filter_flag = true;
@@ -813,7 +817,7 @@ static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name,

    ALOGV("Running %s in=%s out=%s\n", DEX2OAT_BIN, input_file_name, output_file_name);

    char* argv[7  // program name, mandatory arguments and the final NULL
    const char* argv[7  // program name, mandatory arguments and the final NULL
                     + (have_dex2oat_isa_variant ? 1 : 0)
                     + (have_dex2oat_isa_features ? 1 : 0)
                     + (have_profile_file ? 1 : 0)
@@ -822,9 +826,10 @@ static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name,
                     + (have_dex2oat_Xmx_flag ? 2 : 0)
                     + (have_dex2oat_compiler_filter_flag ? 1 : 0)
                     + (have_dex2oat_swap_fd ? 1 : 0)
                     + (have_dex2oat_relocation_skip_flag ? 2 : 0)
                     + dex2oat_flags_count];
    int i = 0;
    argv[i++] = (char*)DEX2OAT_BIN;
    argv[i++] = DEX2OAT_BIN;
    argv[i++] = zip_fd_arg;
    argv[i++] = zip_location_arg;
    argv[i++] = oat_fd_arg;
@@ -843,11 +848,11 @@ static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name,
        argv[i++] = top_k_profile_threshold_arg;
    }
    if (have_dex2oat_Xms_flag) {
        argv[i++] = (char*)RUNTIME_ARG;
        argv[i++] = RUNTIME_ARG;
        argv[i++] = dex2oat_Xms_arg;
    }
    if (have_dex2oat_Xmx_flag) {
        argv[i++] = (char*)RUNTIME_ARG;
        argv[i++] = RUNTIME_ARG;
        argv[i++] = dex2oat_Xmx_arg;
    }
    if (have_dex2oat_compiler_filter_flag) {
@@ -859,6 +864,10 @@ static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name,
    if (dex2oat_flags_count) {
        i += split(dex2oat_flags, argv + i);
    }
    if (have_dex2oat_relocation_skip_flag) {
        argv[i++] = RUNTIME_ARG;
        argv[i++] = dex2oat_norelocation;
    }
    // Do not add after dex2oat_flags, they should override others for debugging.
    argv[i] = NULL;