Skip to content

fix(relinker): reject x64 instructions longer than 15 bytes - #1942

Closed
Zinebyte wants to merge 1 commit into
boykopovar:mainfrom
Zinebyte:fix/x64-instruction-length-limit
Closed

Zinebyte wants to merge 1 commit into
boykopovar:mainfrom
Zinebyte:fix/x64-instruction-length-limit

Conversation

@Zinebyte

@Zinebyte Zinebyte commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

What

The x64 decoder accepts instructions longer than 15 bytes and can let an overlong MOVNTSS reach Intel conversion. Reject overlong prefix streams and both decoded-length return paths while retaining existing shorter decoding, operand bytes and file-offset diagnostics. The limit follows Intel's SDM, Volume 2A §2.2.1.

Tested

The isolated decoder/converter regression fails against base f145139 and passes with this patch. The independent reviewer passed 84 integration cases covering 15/16-byte legacy, VEX2/VEX3, EVEX, immediate, displacement, branch and MOVNTSS forms across Linux/Windows output; malformed bytes were not executed. Zorin OS 18.1 x86-64, GCC 13.3.0, Python 3.12 and CMake 3.28.3, relinker-only Release/static, one build job. Author validation of the composed four patches passed all 39 configured CTest registrations in 6.06 s, including progress_report and import_audit; exact-base baseline passed 38/38 in 5.93 s. A separate independent review rebuilt the composed revision and passed 39/39 in 6.03 s. Focused baseline and patched checks use small synthetic inputs. Existing assertions are retained; no real game, firmware, private asset or GPU input was used.

Native Windows/macOS runtime, real titles, sanitizers and cold shared-CI timing remain unverified. Existing approximate opcode semantics remain outside this architectural length bound.

Open #1552 adds separate DecoderLengthTests.cpp/DecoderLengthCases.hpp tests and does not change this test file or implement this guard. #1756 adds narrower RDPRU/MCOMMIT matcher-length guards and shares the converter test file. The cross-segment branch fix also adds tests there; the reviewed patches compose. No cross-PR runtime validation is claimed.

Checklist

  • Based on current main f145139; open-work audit found no equivalent implementation
  • One topic per PR
  • No new code comments
  • Invalid input throws; existing shorter decoding behavior retained
  • No investigation files or dependencies added to the repository
  • General behavior with synthetic input
  • Depends on: none
  • AI-assisted: yes, OpenAI Codex

@Zinebyte
Zinebyte marked this pull request as ready for review October 9, 2026 02:19

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed the complete diff against current main. Prefix scanning stops at the architectural 15-byte limit, and both decoded-length return paths reject instructions that extend past it; the added cases cover exact 15-byte instructions, overlong prefix streams, scanner offsets, and MOVNTSS conversion. This head is based directly on current main. On Linux/GCC 12.2, the full relinker-only build passed, all 38 registered relinker CTests passed, and Conventions plus diff whitespace checks passed. GitHub reports no upstream checks for this head, so this approval records the local evidence only.

@rmz-24

rmz-24 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Windows run, since the description notes it wasn't tested there: Windows 11 Pro 25H2 (10.0.26200.9457), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, full build with BUILD_TESTING=ON. 28d2fe4 cherry-picked onto current main d70b899 (applies cleanly).

  • amd64_only_converter passes.
  • Full ctest: 510/510, including the Windows PE execution tests.

AI-assisted: yes

@Zinebyte

Zinebyte commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Could a maintainer rerun the failed Windows job? At head 28d2fe49, Build attempt 2 reports only agc_shader_disk_cache timing out after 120 seconds; amd64_only_converter passed. Linux, the Linux/Windows/macOS relinker jobs, and Conventions passed. This account has no upstream Actions rerun permission.

Thanks rmz-24 for the Windows validation: Windows 11 Pro 25H2 / MinGW-w64 GCC 15.2, Release, full CTest 510/510 including Windows PE execution, with 28d2fe49 cherry-picked onto d70b8998. That is useful separate evidence; the CI timeout's cause remains unproven.

AI-assisted review and reply.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Closing: an instruction longer than 15 bytes faults on the console, so no title executes one, and nothing here shows a conversion that goes wrong on main because of it. If a title's relink trips over one, please reopen with that title.

@Zinebyte

Zinebyte commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Understood. The synthetic decoder cases do not demonstrate a title whose conversion fails on main. I have no such title evidence and accept keeping this closed. The earlier CI rerun request is no longer needed for this closed PR.

AI-assisted review and reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants