Skip to content

Parsing process maps in FreeBSD debug module #5221

Description

@well-mannered-goat

Work environment

Questions Answers
OS/arch/bits (mandatory) FreeBSD x86_64
File format of the file you reverse (mandatory) ELF
Architecture/bits of the file (mandatory) x86/64
rizin -v full output, not truncated (mandatory) rizin 0.9.0 @ freebsd-x86-64 (from VM)

Expected behavior

In FreeBSD systems, debug maps are fetched using sysctl first. If this fails they are parsed from /proc/pid/map and stored in RzDebugMap. But this map parsing fails due to different map format.

checkout librz/debug/p/native/kfbsd.c: rz_debug_native_map_get.

Also procfs is not mounted by default inside /proc by default in FreeBSD.

# rizin -d test/bins/elf/calculate-freebsd-x64
[0xc099def2e90]> dm~calculate-freebsd-x64
0x0000000000200000 - 0x0000000000201000 - usr     4K s r-- /root/rizin/test/bins/elf/calculate-freebsd-x64 /root/rizin/test/bins/elf/calculate-freebsd-x64 ; root_rizin_test_bins_elf_calculate_freebsd_x64.r
0x0000000000201000 - 0x0000000000202000 - usr     4K s r-x /root/rizin/test/bins/elf/calculate-freebsd-x64 /root/rizin/test/bins/elf/calculate-freebsd-x64 ; root_rizin_test_bins_elf_calculate_freebsd_x64.r_x
0x0000000000202000 - 0x0000000000203000 - usr     4K s rwx /root/rizin/test/bins/elf/calculate-freebsd-x64 /root/rizin/test/bins/elf/calculate-freebsd-x64 ; root_rizin_test_bins_elf_calculate_freebsd_x64.rwx

Actual behavior

# rizin -d rizin/test/bins/elf/calculate-freebsd-x64
[0x2ee334071e90]> dm
rz_debug_native_map_get: Unable to parse "/proc/949/map"

Steps to reproduce the behavior

  • Binary used: rizin-testbins/elf/calculate-freebsd-x64
  • Comment out the fetching of debug map list using sysctl

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions