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

dmh cannot find gblic mapped in memory because glibc name contains no dash #19473

Closed
gordon-quad opened this issue Dec 5, 2021 · 3 comments
Closed

Comments

@gordon-quad
Copy link
Contributor

Environment

Sun  5 Dec 19:29:12 GMT 2021
radare2 5.3.1 0 @ linux-x86-64 git.5.3.1
commit: 5.3.1 build: 2021-12-05__18:49:14
Linux x86_64

Description

Seems that r_resolve_main_arena function relies upon fact that libc filename contains version number with dash in the middle, which is not true for some distros (e.g. Gentoo).
https://github.com/radareorg/radare2/blob/master/libr/core/linux_heap_glibc.c#L414

Test

$ r2 -d /bin/ls
Process with PID 21229 started...
= attach 21229 21229
bin.baddr 0x55a87bb72000
Using 0x55a87bb72000
asm.bits 64
Continue until 0x55a87bb783e0 using 1 bpsize
hit breakpoint at: 0x55a87bb783e0
 -- (gdb) ^D
[0x55a87bb783e0]> db main
[0x55a87bb783e0]> dc
hit breakpoint at: 0x55a87bb76720
[0x55a87bb76720]> dmh
Warning: Can't find glibc mapped in memory (see dm)
[0x55a87bb76720]> dm~libc:0[9]
/lib64/libc.so.6
@trufae
Copy link
Collaborator

trufae commented Dec 5, 2021

Press the pencil icon and make a pr with the fix if you know where is the issue

@gordon-quad
Copy link
Contributor Author

@trufae I know where the issue is and I would love to fix it, but I'm not really sure how should I approach it, since if I just remove the dash it may match with any library that starts with "libc", and checking for '-' or '.' sounds a bit too ad-hoc of a solution. Any clue if it is possible to determine where libc is in some other way? Or add some way of specifying which mapping is the libc to have at least a workaround for "weirder" distros?

@trufae
Copy link
Collaborator

trufae commented Dec 6, 2021

The current approach is already fuzzy iirc, as long as the library is linked to the binary we can get the name from rbin. But this will work only on local debugging, which is the main use case i guess.

But for an easier solution your proposal lgtm if added as fallback when the libc- cant be found.

gordon-quad added a commit to gordon-quad/radare2 that referenced this issue Dec 6, 2021
@trufae trufae closed this as completed in 2858090 Dec 6, 2021
aemmitt-ns pushed a commit to aemmitt-ns/radare2 that referenced this issue Jan 26, 2022
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

No branches or pull requests

2 participants