Skip to content

[Bug] heap chunks commands not working with GLIBC_TUNABLES set #935

@clark-ja

Description

@clark-ja

GEF+GDB version

GEF: rev:174830a86db426da9e63adc21d98199a3e370c84 (Git - clean)
SHA256(gef.py): 3d890c78a4ebc7a223b3e081111faf55c3d05e441c1284290f4e39758e5a64c5
GDB: 9.2
GDB-Python: 3.8

Operating System

Ubuntu 20.04.5 LTS

Describe the issue you encountered

The heap chunks command does not work properly when setting GLIBC_TUNABLES, e.g., glibc.malloc.tcache_count or glibc.malloc.arena_max when symbols ARE available for the linked glibc (the command works if the symbols are not available).

The reason for this is that GefHeapManager.base_address uses mp_->sbrk_base if symbols are available in the glibc to find the base address of the heap. This value does not point to the beginning of the heap section when some GLIBC_TUNABLES are set.

Do you read the docs and look at previously closed issues/PRs for similar cases?

Yes

Architecture impacted

  • X86
  • X64
  • ARM
  • ARM64
  • MIPS
  • MIPS64
  • PPC
  • PPC64
  • RISCV

Describe your issue. Without a proper reproduction step-by-step, your issue will be ignored.

  1. start GEF/GDB with e.g. the /tmp/heap-non-main.out binary from the test suite
  2. set exec-wrapper env GLIBC_TUNABLES=glibc.malloc.tcache_count=0
  3. run
  4. p mp_->sbrk_base

The last returned value from the above commands does not correspond to the output of vmmap heap.

Minimalist test case

See heap-non-main.c from the test suite

Additional context?

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions