-
Notifications
You must be signed in to change notification settings - Fork 567
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
ARM unallocated encodings are not handled transparently #2491
Comments
I think that might be a general problem, as new instructions get added to X86 too, e.g. the recent AVX-512 extension. |
I don't know what is happening with the ARM crash, but the current code is already doing this for the most part. As you can see, bb_process_invalid_instr() copies and runs the unknown (likely invalid) instruction as a single-instr bb and executes it to get the processor to generate the invalid instruction fault if there's going to be one. Handling unknown encodings is challenging on x86 as they are variable-length. In some cases we have to give up as continuing on without knowing instruction boundaries is riskier and worse than just failing and requiring an up-to-date decoder. We often do get the length right if it's an instruction of a certain class. Xref #57. |
That's interesting. Is bb_process_invalid_instr() not getting invoked because we don't have separate slow and fast decoders on ARM, perhaps? Does the suspicious unrecognised instruction have to be in its own basic block for the SIGILL to be handled correctly? |
It looks like it terminates the basic block after the undecoded instruction, then calls |
Anyone know how this is supposed to work? |
I have a possible fix for this, coming soon. |
In check_encode_decode_consistency(), do not try to reencode an OP_UNDECODED instruction. In instr_encode_arch(), use instr->opcode, not instr_get_opcode(instr), as the latter can call the decoder, which is unhelpful when we are trying to encode. Fixes #2491 Change-Id: I66c42dc87268f1722eae4600b364026896796fc8
Xref #1685 |
Test program:
Native output:
DynamoRIO with debug:
DynamoRIO without debug:
When DynamoRIO thinks it has encountered an unallocated encoding there are several things that might have happened:
The app was supposed to do this.
The app has gone wrong, perhaps because of an unrelated bug or limitation in DynamoRIO, or perhaps the app is just buggy.
There is a bug or omission in DynamoRIO's decoder.
An instruction has been added to the architecture and DynamoRIO is out of date.
Therefore, probably the right thing for DynamoRIO to do is:
With DEBUG, print a warning that an unallocated encoding has been encountered, giving the address and the encoding (but not if it is an officially undefined UDF instruction).
Assume optimistically that the instruction is not a branch and does not use the stolen register so it can be safely copied into the fragment cache and executed. It may or may not cause a SIGILL.
To implement this behaviour we could use some new opcodes (
OP_unknown_a32
,OP_unknown_t32n
,OP_unknown_t32w
; or justOP_unknown
) that work a bit like AArch64'sOP_xx
(which should probably be renamed at some point).The text was updated successfully, but these errors were encountered: