Repository navigation
fix(android): avoid merging APK libraries with distant mappings - #2262
Merged
Merged
Conversation
Another mapping of an APK library's ELF header can lie anywhere in the address space. `is_duplicated_mapping()` accepted any mapping with the same inode and file offset, so without another module in between, the library merged into the earlier mapping, with a wrong `image_addr` and an `image_size` covering both. Accept such a mapping only within the module's `PT_LOAD` span. Share the program header walk with `get_code_id_from_program_header()` via `ELF_PROGRAM_HEADER_ITER`. Fixes: #2261
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #2262 +/- ##
=======================================
Coverage 75.63% 75.63%
=======================================
Files 103 103
Lines 28281 28277 -4
Branches 5199 5192 -7
=======================================
- Hits 21389 21386 -3
+ Misses 5547 5541 -6
- Partials 1345 1350 +5 🚀 New features to boost your workflow:
|
The test mapped the executable's ELF header again twice its file size below it, assuming its load range is smaller. Clang links the TSAN runtime statically, and its `.bss` makes the load range about four times the file size, so the mapping landed inside it, where it still merges by design. Size the gap from the executable's `PT_LOAD` segments instead.
mujacica
approved these changes
Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Another mapping of an APK library's ELF header can lie anywhere in the address space.
is_duplicated_mapping()accepted any mapping with the same inode and file offset, so without another module in between, the library merged into the earlier mapping, with a wrongimage_addrand animage_sizecovering both.Accept such a mapping only within the module's
PT_LOADspan. Share the program header walk withget_code_id_from_program_header()viaELF_PROGRAM_HEADER_ITER.Fixes: #2261