-
Notifications
You must be signed in to change notification settings - Fork 116
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
Cannot partially lift basic blocks containing invalid instructions #425
Comments
It seems to me that we can gracefully handle cases where A stopgap solution that you may use for now is limiting the max number of instructions that you lift each time - try limiting it to 1 to start with. |
I'm transferring this issue to angr/pyvex since we should be able to fix it without touching VEX itself. |
Thanks for the super fast response! fwiw, I worry that Since the IRSB is a return value of |
It's entirely possible! That's what I referred to as "plus whatever necessary fixups required" in my original reply. Upon a closer look, I think a better solution is doing an automatic re-lifting in PyVEX with an instruction limit when the first lifting fails after decoding N instructions. We can get N from |
Yeah, that's what I was thinking as well. It looks like fwiw, here is the quick hack I did in angr to work around this - the first part of the patch wouldn't be necessary with the fix that we discussed, but the second part fixes a related SMC bug where instructions that could not be disassembled/lifted would not be correctly checked against the dirty address set:
|
Thanks for the patch. Do you want to submit a fix (and ideally, a test case as well) as a PR to angr? I'll look into patching pyvex when my time allows. |
Sure thing, I sent a PR for the dirty address check at angr/angr#4935 - thanks! |
Description
VEX panics on certain invalid instructions, which results in
lift()
outputting nothing for the entire basic block (not even IR for instructions prior to the invalid one). Ideally, it would return a partial lifted block instead. This breaks angr's handling of self-modifying code containing these instructions (which can be worked around by single-stepping, but that comes with a performance penalty).Steps to reproduce the bug
Example:
Environment
No response
Additional context
While VEX's disassembler could be fixed to handle this specific failure gracefully, I worry (though I have not verified) that there may be enough other reachable panics strewn around that it would take a fair amount of effort to fix up all of the error handling. Perhaps an easier, if somewhat hacky solution would be to have
bb_to_IR
update alifted_upto
variable inVexTranslateResult
after every successfully lifted instruction so that pyvex can retry lifting withmax_bytes
to obtain a partial lift.The text was updated successfully, but these errors were encountered: