x86-32 CALL rel16 zeroing out high bytes of EIP missing from instruction specification #7418
Labels
Feature: Processor/x86
Status: Triage
Information is being gathered
Type: Bug
Something isn't working
Describe the bug
In 32-bit x86 code, instruction
CALL rel16
(66 e8 cw
) zeroes out the high bytes of EIP[1], making it suitable only for calls to code in 0x00000000-0000ffff. However, patching a CALL instruction will suggest it even for destinations outside that range, creating faulty binaries that will most likely crash if executed. The disassembler will also erroneously display the intended destination as the instruction's target, making the bug nontrivial to identify.To Reproduce
66 e8 ####
will be suggested, which is incorrectExpected behavior
CALL rel16
is not suggested outside of its real target range, and usages are correctly disassembled to destinations within said range.Screenshots
![Image](https://private-user-images.githubusercontent.com/7451386/406747417-5da2757b-1ccf-42a9-bca1-398d0eb6c315.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyOTAxNjQsIm5iZiI6MTczOTI4OTg2NCwicGF0aCI6Ii83NDUxMzg2LzQwNjc0NzQxNy01ZGEyNzU3Yi0xY2NmLTQyYTktYmNhMS0zOThkMGViNmMzMTUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTFUMTYwNDI0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YWNiYTQ4ZWJlY2EyZDczNTg5M2U1ODBmNzY0OGQ2YTRmYzhhMGI3MTgzNDkxNTQyMTk3MGIyZGQ1ZjI5NzU0MCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.JjrN2jc0GIBNBuBAawYuI7qqk4J2dpE4c-azINOAY8Y)
Attachments
I was going to include a sample ELF, but not a valid attachment
Environment:
Additional context
[1]Intel® 64 and IA-32 Architectures Software Developer’s Manual, volume 2A, chapter 3, page 143:
IF near call THEN IF near relative call THEN [...] IF OperandSize = 16 THEN tempEIP := (EIP + DEST) AND 0000FFFFH; (* DEST is rel16 *) [...]
The text was updated successfully, but these errors were encountered: