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

Only use os- and processor- specific enum values on the appropriate os and processor #175

Closed
rhelmot opened this issue Jan 5, 2018 · 5 comments · Fixed by #183
Closed

Comments

@rhelmot
Copy link
Contributor

rhelmot commented Jan 5, 2018

So this is the actual cause that was behind yesterday's issue, though that is probably still a problem.

If you look at how this project tries to load the file linked from this issue angr/cle#103 (comment) it crashes because it thinks the dynamic tag 0x6000000f is DT_SUNW_FILTER, and assumes that the corresponding d_val points to a string. However, this is not solaris, and 0x6000000f is not a filter here, so the pointer is not an index into a string table, and so the lookup crashes.

This seems like a very complicated and invasive change, and I don't know anything about the architecture of this project, so I'd appreciate a response other than "patches welcome".

@eliben
Copy link
Owner

eliben commented Jan 5, 2018

I think this is the same issue in #121 and #71, right?

These issues have some clues about possible solutions, but you're right that it's not trivial. It'd be great if someone found time to finally fix this, though :)

@eliben
Copy link
Owner

eliben commented Jan 18, 2018

In the past days 7371660 and 5fc2c25 landed to implement machine detection. I believe this is very similar to what's required here for OS detection

@eliben
Copy link
Owner

eliben commented Jan 18, 2018

Specifically, pyelftools already reads the EI_OSABI offset in e_ident and has a table of OS/ABI, which can be used to identify such fields.

Could you provide a minimal test file where this problem can be observed?

@rhelmot
Copy link
Contributor Author

rhelmot commented Feb 18, 2018

Here is a test file. It was provided to me by one of my users and I have no idea how to make it smaller, but the nature of the problem is evident.

libLLVM.so.gz

from elftools.elf import elffile                                                                         
                                                                                                         
e = elffile.ELFFile(open('/home/audrey/Downloads/libLLVM.so', 'rb'))                                     
dyn = e.get_section_by_name('.dynamic')                                                                  
soname = [ x.soname for x in list(dyn.iter_tags()) if x.entry.d_tag == 'DT_SONAME']                      
print soname 

I've looked over the commits you linked and yes, it's now basically within reach to do the same thing. The problem is... I don't know what sort of values of EI_OSABI actually correspond to DT_SUNW_* being valid. As far as I can tell that file is totally valid but none of its header values betray a deviation of the norm. My guess is that this is an android library and the correct values should come from here, but I have no idea how to detect that.

@rhelmot
Copy link
Contributor Author

rhelmot commented Feb 22, 2018

Found the relevant code in readelf. https://chromium.googlesource.com/native_client/nacl-binutils/+/upstream/master/binutils/readelf.c#1986

Pull request incoming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants