summaryrefslogtreecommitdiff
path: root/linker/linker.cpp
diff options
context:
space:
mode:
authorRyan Prichard <rprichard@google.com>2020-03-26 21:31:43 -0700
committerRyan Prichard <rprichard@google.com>2020-03-27 18:46:28 -0700
commit4fa6d9978a690fd4553279db0619093c22acf968 (patch)
tree6caf35077b807969e235878931187c73766048b7 /linker/linker.cpp
parent146620b6443f84d955697cae1c40b9f1b9bd3928 (diff)
Remove dangling soinfo* from elf_readers_map_
If ElfReader::Read fails, then it is hazardous to leave the invalid ElfReader in the soinfo*->ElfReader table, because a future soinfo object could happen to have the same address, then reuse the invalid ElfReader. I'm not sure whether this can break anything, because the linker would call ElfReader::Read on the invalid object and overwrite its previous value. Test: bionic unit tests Bug: none Change-Id: Ibabbf559443441b9caeacc34ca165feaafe5e3a7
Diffstat (limited to 'linker/linker.cpp')
-rw-r--r--linker/linker.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/linker/linker.cpp b/linker/linker.cpp
index ac83cae9a..090e7f04c 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -602,6 +602,11 @@ class LoadTask {
return start_from_;
}
+ void remove_cached_elf_reader() {
+ CHECK(si_ != nullptr);
+ (*elf_readers_map_).erase(si_);
+ }
+
const ElfReader& get_elf_reader() const {
CHECK(si_ != nullptr);
return (*elf_readers_map_)[si_];
@@ -1272,8 +1277,9 @@ static bool load_library(android_namespace_t* ns,
// Read the ELF header and some of the segments.
if (!task->read(realpath.c_str(), file_stat.st_size)) {
- soinfo_free(si);
+ task->remove_cached_elf_reader();
task->set_soinfo(nullptr);
+ soinfo_free(si);
return false;
}