Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] GEF cannot find stack mapping when using info sections #915

Closed
1 of 9 tasks
Grazfather opened this issue Nov 5, 2022 · 2 comments
Closed
1 of 9 tasks

[Bug] GEF cannot find stack mapping when using info sections #915

Grazfather opened this issue Nov 5, 2022 · 2 comments

Comments

@Grazfather
Copy link
Collaborator

Grazfather commented Nov 5, 2022

GEF+GDB version

dev 9edd73e1

Operating System

N/A

Describe the issue you encountered

When debugging a remote target whose maps I can't read from e.g. procfs, I elected to load the elf directly. This makes gef.mapping.maps use __parse_gdb_info_sections instead of __parse_procfs_maps. This is fine for most sections, but it leaves the stack unmapped since the stack is not specified in the ELF header.

This breaks the stack view of context.

────────────────────────────────────────────────────────────────────── stack ────│       0000000000000094  0000000000000002   A       5     0     2
[!] Unmapped target address: '0x20041fd8'
gef➤  x/20wx $sp
0x20041fd8:     0x00000005      0xd0000000      0x02000000      0x02000000
0x20041fe8:     0x00000000      0x1000039f      0x10000194      0x20041f01
0x20041ff8:     0x18000000      0x1000013f      0x00000000      0x00000000
0x20042008:     0x00000000      0x00000000      0x00000000      0x00000000
0x20042018:     0x00000000      0x00000000      0x00000000      0x00000000

We could maybe add a way to manually add sections?

gef➤  pi s = Section(page_start=0x20041800, page_end=0x20042000, offset=0, permission=Permission(0))
gef➤  pi gef.memory._GefMemoryManager__maps.append(s)
────────────────────────────────────────────────────────────────────── stack ────
0x20041fd8│+0x0000:              ← $sp
0x20041fdc│+0x0004: 0xd0000000
0x20041fe0│+0x0008: 0x02000000
0x20041fe4│+0x000c: 0x02000000
0x20041fe8│+0x0010: 0x00000000  →  0x20041f00
0x20041fec│+0x0014: 0x1000039f  →  <main+47> b.n 0x1000038e <main+30>
0x20041ff0│+0x0018: 0x10000194  →  <wait_for_vector+6> bx r0
0x20041ff4│+0x001c: 0x20041f01  →  0x214b2fb5

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.

Provide a step-by-step to reproduce your issue.

Minimalist test case

Use this field for a minimal code to compile and spot the issue:

// compile with gcc -fPIE -pic -o my_issue.out my_issue.c
int main(){ return 0; }

You can also provide a Dockerfile if you prefer

Additional context?

  • Screenshots
  • Callstack
  • Coredumps
  • If possible and useful, please upload the binary
@stale
Copy link

stale bot commented Jan 4, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. You can reopen it by adding a comment to this issue.

@stale stale bot added the stale label Jan 4, 2023
@stale
Copy link

stale bot commented Feb 4, 2023

This issue has been automatically closed because it has not had recent activity. If you are the owner of this issue, you can either re-open it and provide a more complete description; or create a new issue. Thank you for your contributions.

@stale stale bot closed this as completed Feb 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant