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

Fix segfault on variable rename #15721

Closed
wants to merge 1 commit into from
Closed

Fix segfault on variable rename #15721

wants to merge 1 commit into from

Conversation

DoITCreative
Copy link

Fix for issue #15691

@radare
Copy link
Collaborator

radare commented Dec 29, 2019

I don’t think this change fixes the actual root cause of the segfault. The last bytes of the address are computed in the way its there.

The ranalop loop below is not checking for the return value so if it analyzes wrongly it keeps doing which may cause bad things. Can u try this? Also, if the value is starting with 0x maybe we can just use the whole value instead of part of it

@radare radare added this to the 4.2.0 (Arctic World Archive) milestone Dec 29, 2019
@radare
Copy link
Collaborator

radare commented Dec 30, 2019

i fixed the ranalop thing pls retry

@DoITCreative
Copy link
Author

Tried on:

radare2 4.2.0-git 23434 @ linux-x86-64 git.4.1.1-40-g265e0d1f6
commit: 265e0d1f6672f0023a3d63e45407cd4945d2d910 build: 2019-12-30__16:16:38

Still segfaults inside r_anal_op(...) on line 4065. This happens, because incorrect address is passed in try_off variable. I had specified last hex digits of the variable in dv command like so dv 820be84. So try_off should contain number 0x0820be84, but it has 0x1820be84 instead. That leads to the segfault on pointer dereference further. try_off depends on start_off variable, which is calculated incorrectly at line 4059.

Variables before calculation:

off = 0x0820be94
mask = 0x0fffffff
incr = 0x10000000
N = 0x0820be84

Correct formula looks like start_off = (off & ~mask) ^ N; but we go to the else branch of if case and calculate start_off like so: start_off = ((off & ~mask) ^ incr) ^ N; which is leading to incorrect result. Maybe if statement should check for (off & ~mask) <= N instead of (off & mask) <= N?
It works in my case.
Anyways, the segfault check is not working. If incorrect value is passed in dv - command like so dv 0x0820be94 then we still have segfault.
I found the way to catch segfaults though. With it and with if statement fix everything works correctly. I will make pr soon.

@radare
Copy link
Collaborator

radare commented Dec 30, 2019 via email

@DoITCreative
Copy link
Author

How to get asan crashlog?

@radare
Copy link
Collaborator

radare commented Dec 30, 2019 via email

@DoITCreative
Copy link
Author

There is no such script in sys/

@DoITCreative
Copy link
Author

I have created pr #15732 with working fix, I'm closing this pr.

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

Successfully merging this pull request may close these issues.

2 participants