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

Ghidra dependency resolve can report incorrect recursive type deps #147

Open
mahaloz opened this issue Feb 12, 2025 · 0 comments
Open

Ghidra dependency resolve can report incorrect recursive type deps #147

mahaloz opened this issue Feb 12, 2025 · 0 comments

Comments

@mahaloz
Copy link
Member

mahaloz commented Feb 12, 2025

This issue is related to #97, since the root bug is scopes in Ghidra.

This the fdupes binary inside the CI, the following can be observed:

[ins] In [10]: func = deci.functions[7526]

[ins] In [11]: func.args
Out[11]: {0: <FuncArg: char * filename; @0>, 1: <FuncArg: __off64_t max_read; @1>}

[ins] In [12]: for name, t in deci.typedefs.items():
          ...:     if "__off64_t" in name:
          ...:         print(t)
          ...: 
<TypeDef: DWARF/__off64_t=sqword>
<TypeDef: types.h/__off64_t=long>

[ins] In [13]: deci.get_dependencies(func)
Out[13]: 
[<TypeDef: DWARF/md5_word_t=uint>,
 <TypeDef: DWARF/__off64_t=sqword>,
 <Struct: DWARF/md5.h/md5_state_s membs=3 (0x58)>,
 <TypeDef: DWARF/md5_byte_t=uchar>,
 <TypeDef: DWARF/md5.h/md5_state_t=md5_state_s>,
 <GlobalVar: md5_byte_t[16] digest; @2122960 len=16>,
 <GlobalVar: md5_byte_t[8192] chunk; @2122976 len=8192>]

The issue here is the second arg of the function has type __off64_t, and there are two typedefs in Ghidra that define this type. Unfortunately, we choose the wrong one for this reference. We chose DWARF, but we should've chosen types.h. In #146 a temporary solution was chosen always to prioritize types.h, but this will not work into the future.

To solve this, we must encode scopes into the artifacts, which will require more time to develop.

mahaloz added a commit that referenced this issue Feb 12, 2025
mahaloz added a commit that referenced this issue Feb 12, 2025
* Fix a Ghidra bug where some types can become declarations

* Add the workaround for #147
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

1 participant