Repository navigation
Description
A survey of F3/F2-prefixed x86_64 instructions found several decoder problems in InstructionDecoder_x86 / common/src/arch-x86.C. These are what remains after #2617 (prefix leak + tzcnt/lzcnt) and the follow-up that applies REP/REPNZ effects only to string instructions.
How we found it
The survey put F3 or F2 in front of every one-byte, 0F, 0F 38 and 0F 3A opcode, with 24 ModRM variants each (47,472 byte strings). Each string was decoded with objdump 2.40 and with Dyninst master (64964e6). We also decoded one sample of every F3/F2-prefixed instruction found in .text of RHEL 8 libc, ld.so and libstdc++ and of TensorFlow 2.20's libtensorflow_framework.so.2. Counts below are occurrences in those binaries.
Problems
-
CET shadow-stack instructions (in libc and ld.so)
bytes instruction Dyninst decodes f3 48 0f ae ebincsspq %rbx(libc 5, ld.so 1)lfencef3 0f 01 6e f8rstorssp -0x8(%rsi)(libc 4)invalid f3 0f 01 easaveprevssp(libc 4)invalid f3 48 0f 1e c8rdsspq %rax(libc 12, ld.so 2)REP nop %raxAn invalid decode inside a function ends parsing there.
-
Other instructions whose F3/F2 selects the instruction, with no table entry
Each one is decoded as the instruction without the prefix:
pause(f3 90) decodes asnop;wbnoinvd(f3 0f 09) decodes aswbinvd;senduipi(f3 0f c7 /6, register) decodes asrdrand;vmxon(f3 0f c7 /6, memory) decodes asrdrandwith a memory operand;mcommit(f3 0f 01 fa) decodes asinvlpg;- the MPX
bndcl/bndcu/bndcn/bndmk(f3/f20f 1a/0f 1b) are not decoded as such either.
-
crc32operands.f2 0f 38 f1 ca(crc32 %edx,%ecx, 34 in libtensorflow_framework) decodes ascrc32 %xmm2,%xmm1, with XMM registers instead of general-purpose registers. -
popcntflags.popcntis listed inget_read_flags(instructionAPI/src/Operation.C) with all six flags. It reads no flags and writes all six (zf from the source, the others cleared), so it should be inget_written_flags. There are 320popcntin libtensorflow_framework. -
Assertion abort.
f3 0f 38 f3 3fandf2 0f 38 f3 3fabort the process inia32_decode_opcodewithAssertion '!"Entered VEX SSE MULT table when no VEX present."' failed. Any tool that decodes these bytes, for example while parsing data as code, terminates. -
Register-only instructions accepted with a memory operand.
movq2dq(f3 0f d6),movdq2q(f2 0f d6) andinsertq(f2 0f 78) with mod != 11 are invalid (objdump:(bad)). Dyninst decodes them with a memory operand and a longer length. -
Undefined encodings decoded as instructions. 144 prefix/opcode/ModRM combinations that objdump reports as
(bad)are decoded by Dyninst as instructions. This has low priority; the list is in the survey data.
Not covered by the survey
- F3/F2 combined with
lock(xacquire/xrelease); - VEX/EVEX encodings;
- instructions with more than one of these prefixes;
- 32-bit mode.
The survey scripts and per-case results are kept locally and can be attached on request.
🤖 Generated with Claude Code
Activity