From 788935ae8ddb824e9996618f2516e5fdb6b703b1 Mon Sep 17 00:00:00 2001 From: michalbednarski Date: Sun, 20 Mar 2016 12:18:58 +0100 Subject: [PATCH] proot: Properly handle relocated embedded loader The _binary_loader_exe_size variable can be relocated by Android linker which makes it unusable, rely instead on end-start which can be relocated Also don't reject binaries with linker having it's own DT_INTERP section (like /system/bin/linker on ARM Android) --- .../proot/src-execve-enter.c.patch | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 disabled-packages/proot/src-execve-enter.c.patch diff --git a/disabled-packages/proot/src-execve-enter.c.patch b/disabled-packages/proot/src-execve-enter.c.patch new file mode 100644 index 000000000..6b77fc817 --- /dev/null +++ b/disabled-packages/proot/src-execve-enter.c.patch @@ -0,0 +1,42 @@ +--- PRoot-5.1.0/src/execve/enter.c 2014-12-15 15:18:11.000000000 +0100 ++++ src/src/execve/enter.c 2016-03-20 12:05:08.013426156 +0100 +@@ -454,10 +454,10 @@ + } + + extern unsigned char _binary_loader_exe_start; +-extern unsigned char _binary_loader_exe_size; ++extern unsigned char _binary_loader_exe_end; + + extern unsigned char WEAK _binary_loader_m32_exe_start; +-extern unsigned char WEAK _binary_loader_m32_exe_size; ++extern unsigned char WEAK _binary_loader_m32_exe_end; + + /** + * Extract the built-in loader. This function returns NULL if an +@@ -483,11 +483,11 @@ + + if (wants_32bit_version) { + start = (void *) &_binary_loader_m32_exe_start; +- size = (size_t) &_binary_loader_m32_exe_size; ++ size = (size_t) (&_binary_loader_m32_exe_end - &_binary_loader_m32_exe_start); + } + else { + start = (void *) &_binary_loader_exe_start; +- size = (size_t) &_binary_loader_exe_size; ++ size = (size_t) (&_binary_loader_exe_end - &_binary_loader_exe_start); + } + + status2 = write(fd, start, size); +@@ -645,8 +645,10 @@ + + /* An ELF interpreter is supposed to be + * standalone. */ +- if (tracee->load_info->interp->interp != NULL) +- return -EINVAL; ++ if (tracee->load_info->interp->interp != NULL) { ++ TALLOC_FREE(tracee->load_info->interp->interp); ++ // TODO: Print warning? ++ } + } + + compute_load_addresses(tracee);