diff options
author | Dimitry Ivanov <dimitry@google.com> | 2016-08-26 02:32:57 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-08-26 02:32:57 +0000 |
commit | 690c8ba6e7b1b8d1519d2ccf71a94faac86165e8 (patch) | |
tree | d3c5323c635bb8eed77168bc4fa63c169a77600e | |
parent | a6f3b63f33d888b9d9030a03e4270e208d97a604 (diff) | |
parent | 7da4bbbe87a7eca742c6c45a76aaf191aa70d948 (diff) | |
download | bionic-690c8ba6e7b1b8d1519d2ccf71a94faac86165e8.tar.gz |
Merge "linker: stat /proc/self/exe instead of executable_path" into nyc-mr1-dev
-rw-r--r-- | linker/linker.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/linker/linker.cpp b/linker/linker.cpp index 05b177b89..8b28d7537 100644 --- a/linker/linker.cpp +++ b/linker/linker.cpp @@ -4223,12 +4223,15 @@ static ElfW(Addr) __linker_init_post_relocation(KernelArgumentBlock& args, ElfW( } } - const char* executable_path = get_executable_path(); struct stat file_stat; - if (TEMP_FAILURE_RETRY(stat(executable_path, &file_stat)) != 0) { - __libc_fatal("unable to stat file for the executable \"%s\": %s", executable_path, strerror(errno)); + // Stat "/proc/self/exe" instead of executable_path because + // the executable could be unlinked by this point and it should + // not cause a crash (see http://b/31084669) + if (TEMP_FAILURE_RETRY(stat("/proc/self/exe", &file_stat)) != 0) { + __libc_fatal("unable to stat \"/proc/self/exe\": %s", strerror(errno)); } + const char* executable_path = get_executable_path(); soinfo* si = soinfo_alloc(&g_default_namespace, executable_path, &file_stat, 0, RTLD_GLOBAL); if (si == nullptr) { __libc_fatal("Couldn't allocate soinfo: out of memory?"); |