Skip to content

fix(android): avoid merging APK libraries with distant mappings - #2262

Merged
jpnurmi merged 4 commits into
masterfrom
jpnurmi/fix/android-modules
Oct 29, 2026
Merged

jpnurmi merged 4 commits into
masterfrom
jpnurmi/fix/android-modules

Conversation

@jpnurmi

@jpnurmi jpnurmi commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

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

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
@jpnurmi
jpnurmi added this pull request to stack #2264 October 28, 2026 09:55
@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.84848% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.63%. Comparing base (a4c7507) to head (3292341).
⚠️ Report is 2 commits behind head on master.

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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.
@jpnurmi
jpnurmi merged commit 5a6b661 into master Oct 29, 2026
71 checks passed
@jpnurmi
jpnurmi deleted the jpnurmi/fix/android-modules branch October 29, 2026 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android: module list merges an APK-loaded library with a neighbouring mapping (wrong image_addr, inflated image_size)

2 participants