Skip to content

Upgrade to Frida 17.16.1 and elf modulemap writer fixes - #245

Merged
s1341 merged 10 commits into
frida:mainfrom
kkuehl:pr/elf-modulemap-writer-fixes
Jul 20, 2026
Merged

Upgrade to Frida 17.16.1 and elf modulemap writer fixes#245
s1341 merged 10 commits into
frida:mainfrom
kkuehl:pr/elf-modulemap-writer-fixes

Conversation

@kkuehl

@kkuehl kkuehl commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Add ElfModule API, fix soundness issues, and upgrade to Frida 17.15.4

This PR adds the ElfModule wrapper for Linux/Android/FreeBSD, fixes two soundness bugs in existing code, and bumps to Frida 17.15.4.

ElfModule API (Linux/Android/FreeBSD only)

Complete wrapper for Frida 17.15.0 ELF binary parsing:

  • from_file / from_memory constructors
  • Property accessors: pointer_size, byte_order, os_abi_version, mapped_size, base_address, preferred_address, entrypoint, interpreter, source_path
  • enumerate_dynamic_entries / dynamic_entries for iterating ELF .dynamic section
  • Platform-gated with cfg(any(target_os = "linux", target_os = "android", target_os = "freebsd"))

Use case: Parse ELF headers and dynamic sections for binary analysis on Linux-based systems.

Soundness Fixes

ModuleMap::new_with_filter use-after-free
The filter closure was passed as a temporary Box with no GDestroyNotify, but Frida retains and re-invokes it on every ModuleMap::update.

Fixed by:

  • Taking ownership with Box::into_raw and transferring to Frida
  • Registering GDestroyNotify callback to properly free the box when the map is finalized
  • Removing unnecessary 'static bound - lifetime is now explicitly managed

Also fixes new_from_names to capture owned copies of names instead of borrowing the caller's slice, since the filter outlives the call.

Writer return type correctness
Instruction writer wrappers for void C functions were fabricating -> bool { ...; true }, giving callers a meaningless success signal.

Changed to return () to match the C ABI semantics:

  • aarch64: put_call_address_with_arguments
  • x86_64: put_leave, put_ret, put_ret_imm, put_jmp_short_label, put_jmp_near_label, put_mov_reg_address, put_mov_reg_ptr_u32, put_mov_reg_ptr_reg, put_mov_reg_reg_ptr, put_push_u32, put_nop, put_pushfx, put_popfx, put_pushax, put_popax

The InstructionWriter trait methods still return bool as required by the trait (arm/arm64 underlying C functions actually return gboolean).

Version Bump

  • FRIDA_VERSION: 17.15.3 → 17.15.4

kkuehl added 4 commits July 7, 2026 08:25
Add complete ElfModule wrapper for Frida 17.15.0 ELF binary parsing:
- from_file/from_memory constructors
- Property accessors: pointer_size, byte_order, os_abi_version, mapped_size,
  base/preferred addresses, entrypoint, interpreter, source_path
- enumerate_dynamic_entries for iterating ELF .dynamic section

Platform-gated: only Linux/Android/FreeBSD (~200 lines)
Tested: cargo build --features=auto-download
The filter closure was passed as a temporary Box with no GDestroyNotify,
but Frida retains and re-invokes it on every ModuleMap::update.

Now owns the closure by value with proper destroy callback:
- Box::into_raw to transfer ownership to Frida
- GDestroyNotify callback drops the box when map is finalized
- No 'static bound needed - lifetime managed explicitly

Also fixes new_from_names to capture owned copies of names instead of
borrowing the caller's slice, since the filter outlives the call.
Instruction writer wrappers for void C functions were fabricating
-> bool { ...; true }, giving callers a meaningless success signal.

Changed to return () to match the C ABI:
- aarch64: put_call_address_with_arguments
- x86_64: put_leave, put_ret, put_ret_imm, put_jmp_short_label,
  put_jmp_near_label, put_mov_reg_address, put_mov_reg_ptr_u32,
  put_mov_reg_ptr_reg, put_mov_reg_reg_ptr, put_push_u32,
  put_nop, put_pushfx, put_popfx, put_pushax, put_popax

The InstructionWriter trait methods still return bool as required by
the trait (arm/arm64 underlying C functions return gboolean).
@kkuehl kkuehl changed the title Pr/elf modulemap writer fixes Upgrade to Frida 17.15.4 and elf modulemap writer fixes Jul 7, 2026
@kkuehl kkuehl changed the title Upgrade to Frida 17.15.4 and elf modulemap writer fixes Upgrade to Frida 17.16.1 and elf modulemap writer fixes Jul 19, 2026
@kkuehl

kkuehl commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

@s1341 Could we start with this one and I will bring in several much easier to digest PRs. Thanks!

@s1341
s1341 merged commit 7fc8243 into frida:main Jul 20, 2026
16 checks passed
@s1341

s1341 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

merged. Thanks!

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.

2 participants