aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-04-03 18:15:56 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-04-03 18:15:56 +0000
commita90866094bb62d66bc395a0639b00147dc878ec4 (patch)
treee78d2deae6e745afdac4df9b6b5b13fc64aada13
parentea4682dac891ad45f7c2c10e0119a8d01c2d97b1 (diff)
parent79ba700870a5d9d2e2dd0d1c9c977d9772207f21 (diff)
downloadbionic-android14-qpr3-s2-release.tar.gz
Change-Id: Ib0189f7e644ed6eae0821ba3cef1721b8521cf23
-rw-r--r--linker/linker_phdr.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/linker/linker_phdr.cpp b/linker/linker_phdr.cpp
index 82b37a44d..38c7e1569 100644
--- a/linker/linker_phdr.cpp
+++ b/linker/linker_phdr.cpp
@@ -724,6 +724,16 @@ bool ElfReader::ReadPadSegmentNote() {
continue;
}
+ // If the PT_NOTE extends beyond the file. The ELF is doing something
+ // strange -- obfuscation, embedding hidden loaders, ...
+ //
+ // It doesn't contain the pad_segment note. Skip it to avoid SIGBUS
+ // by accesses beyond the file.
+ off64_t note_end_off = file_offset_ + phdr->p_offset + phdr->p_filesz;
+ if (note_end_off > file_size_) {
+ continue;
+ }
+
// note_fragment is scoped to within the loop so that there is
// at most 1 PT_NOTE mapped at anytime during this search.
MappedFileFragment note_fragment;