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

i#3324: Fixed use of uninitialised data caused by read_instruction. #3325

Merged
merged 2 commits into from
Jan 3, 2019

Conversation

johnfxgalea
Copy link
Contributor

Fixes #3324 by initialising opcode field of di in read_instruction.

Without this fix, a usage error is caused when inserting cmov instructions.

@johnfxgalea johnfxgalea changed the title Fixed read instr bug. i#3324: Fixed use of uninitialised data caused by read_instruction. Dec 22, 2018
@@ -1090,6 +1090,8 @@ read_instruction(byte *pc, byte *orig_pc, const instr_info_t **ret_info,
});
#endif

di->opcode = info->type;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the decision is to set di->opcode inside read_instruction, all its callers should be changed as well, as all but decode_eflags_usage are using info->type and setting di->opcode if necessary themselves.

Since all other callers of read_instruction are using info->type for the opcode, the alternative fix is to change decode_eflags_usage to use info->type. (Ideally we could then remove di->opcode -- except there's the call to opnd_create_immed_float_for_opcode and one use when encoding.) If going this route, read_instruction's docs should then say it does not initialize the opcode field and returns the opcode in info->type. IIRC a memset to 0 was too expensive which is why this is so fragile.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your comment. Do you mean something like the new push? LMK if it needs adjusting.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is one way to go. Adding a test to exercise this path would be good too but not going to hold this up for that.

@derekbruening
Copy link
Contributor

Travis failure looks like a known rare problem: fib-conflict #2641. Re-running that job.

@derekbruening derekbruening merged commit 03e8863 into DynamoRIO:master Jan 3, 2019
@johnfxgalea johnfxgalea deleted the cmovcc_fix branch January 3, 2019 15:36
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.

Decode bug resulting in invalid cmovcc opcode
2 participants