fix(relinker): guard TLS instruction byte access at EOF #6401
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6401"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-15T14:05:14Z.
What
registerAddress()has established that the instruction contains it.Tested
ASAN_OPTIONS=detect_leaks=0 python3 core/relinker/relinker/tests/test_tls_function_coverage.py /tmp/AnyPS5-6391-build/core/relinker/relinker allpassed.python3 tools/check_conventions.py --base upstream/mainandgit diff --checkpassed.Checklist
main; no other open PR implements the same functions.mdfiles or images addedImported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-15T15:39:43Z.
I ran the
rejectedTLS coverage tests on Linux, GCC 16.2.1. The fix removes the 1-byte read past the end, but in a normal build the newsegment-prefix-at-eofcase passes with or without the fix; it fails only when the relinker is built with AddressSanitizer.Setup: head
2a65acd86merged into main at92e50418f(no conflicts; the PR's base is 59 commits behind), clean environment (env -iwith only HOME and PATH set; for ctest also VK_ICD_FILENAMES), 3 runs each. "Fix reverted" means core/relinker/elfpatcher/src/windows/WindowsTlsBuilder.cpp put back to main's version, with the PR's test changes kept.Default build (CMAKE_BUILD_TYPE empty),
ctest -R '^tls_function_coverage_'(31 tests):AddressSanitizer build (
-DANYPS5_ENABLE_ASAN=ON -DANYPS5_RELINKER_ONLY=ON), runningpython3 core/relinker/relinker/tests/test_tls_function_coverage.py <relinker> rejected(I configured it without BUILD_TESTING, so ctest found no tests and I ran the script directly):segment-prefix-at-eof, with "AddressSanitizer: heap-buffer-overflow", "READ of size 1" inElfpatcher::Windows::WindowsTlsBuilder::Build.No workflow in .github/workflows builds with AddressSanitizer, and the relinker job builds Release, so CI would not catch this if it returned. The extra byte is read but never used, so the result is the same with or without the fix; only a sanitizer (or a read that crosses into unmapped memory) shows it. Running the TLS coverage tests in an AddressSanitizer build would keep it from coming back.
I did not check Windows or macOS.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T15:59:25Z.
Thanks for testing the fix under AddressSanitizer and showing that reverting it produces a heap-buffer-overflow 3/3, while the normal Release test cannot distinguish the extra read. That is strong evidence for the bounds fix. The suggested ASan regression run is also useful: I will check how to cover this code path in the relinker validation workflow so the one-byte overread does not silently return.