Repository navigation
fix(relinker): validate every entry of the Linux run path - #10607
Conversation
LinuxElfPatcher wrote --rpath into DT_RUNPATH unchanged, so an empty entry (an empty value, a leading or trailing colon, or a double colon) reached the output, where glibc searches the working directory for it, while the macOS and Windows outputs reject empty run paths. The guest module rule that each entry is absolute or begins with $ORIGIN only looked at the start of the whole value, so "$ORIGIN/libs:" or "$ORIGIN:relative/libs" passed. The Linux patcher now rejects an empty entry with the message the macOS patcher uses, the guest rule checks every colon-separated entry, and USAGE.md says so.
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed head 5362dca. The Linux patcher rejects empty run-path components before writing output, and guest modules now validate every colon-separated component while preserving the accepted absolute and $ORIGIN forms. The added cases cover empty, leading, trailing, and interior components on default and lazy-binding Linux outputs, plus invalid guest lists. Eligibility, conventions, intake, labels, Linux/Windows/macOS relinker jobs, and relinker ASan pass; full product Linux/Windows jobs are skipped for this relinker-focused change. The described Ubuntu/glibc behavior and relinker-only CTest results are author-reported; I did not reproduce them locally.
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Tested head 5362dca merged onto main aeff26b (clean) on Windows 11 (Ryzen 5 9600X), WinLibs GCC 15.2.0, Release.
AI-assisted: yes (Claude Code); results above were run on this machine. |
What
Linux was the only target that wrote
--rpathinto the output without checking its entries.LinuxElfPatcher::Patchcopied the value intoDT_RUNPATHunchanged, so--rpath "",:$ORIGIN/libs,$ORIGIN/libs:or/opt/a::/opt/brelinked with exit 0. glibc treats an empty entry of a non-emptyDT_RUNPATHas the working directory, so such a program loads its libraries from wherever it is started, and it ignores an entirely emptyDT_RUNPATH, so--rpath ""produced a program that cannot findlibs/at all. The macOS patcher rejectsEmpty macOS run path component is not supported(MacOsMachOPatcher.cpp) and WindowsWindows run path must be a nonempty ASCII path(WindowsEntryStubBuilder.cpp). The Linux patcher now throwsEmpty Linux run path component is not supportedwith the other precondition checks at the start ofPatch, for the default (fixed-base) and--lazy-bindingoutputs, and leaves no output. Relative entries stay accepted for executables relinked with--skip-sce-module, as on macOS, where the patcher also rejects only empty components; the guest rule below is what requires absolute or$ORIGINentries.GuestModuleBuilder::Buildenforced the documented rule, absolute or beginning with$ORIGIN, only on the start of the whole value, so$ORIGIN/libs:,$ORIGIN::/opt/libs,$ORIGIN:relative/libsand/opt/libs:passed and the relative or empty entry reached every guest module'sDT_RUNPATH. The check now walks the colon-separated entries with the same message.$ORIGIN,$ORIGIN/...and absolute entries, alone or in lists, are accepted as before; the existing list cases oftest_guest_runpath.pyare unchanged. As before, the rule applies to Linux and macOS guest modules.--rpathrow ofUSAGE.mdchanges: on Linux every colon-separated entry must be nonempty, and with guest modules each must be absolute or begin with$ORIGIN.test_linux_dynamic_strings.pygains a two-entry run path that must be written as given and eight rejected runs (four values on the default and--lazy-bindingoutputs);test_guest_runpath.pygains the four invalid lists above. Against themainbinary both tests fail at the first new rejected case with exit 0 and an output file; with this change they pass.pr_overlap.pycannot compare this branch with feat(aot): consolidate native ARM64 compiler, runtime and consumers #5021, perf(agc): build the pipelines of a submission ahead on a compile pool #5925, fix(tools): recognize guest module identities in import audit #6171, perf(recompiler): keep runtime-specialized shader modules in the shader disk cache #6924, feat(agc): look up table images at run time through a device image table on the GPU heap (APS5_GPU_PATH) #7642, fix(shader): emit the fault record function without DontInline #7942, perf(agc): size the pipeline store to the title's working set #9401, feat(relinker): trace function imports on macOS #9408, perf(agc): GPU descriptor heap on VK_EXT_descriptor_heap (APS5_GPU_HEAP) #9508 and feat(agc): serve lane-keyed, pointer and run-time-address image table columns through the device image table #10193 (USAGE.md) or fix(relinker): mask embedded data tables in inter-FDE gaps #8076 (GuestModuleBuilder.cpp), because those do not merge withmain. Checked by hand: none of them edits the--rpathrow, and fix(relinker): mask embedded data tables in inter-FDE gaps #8076 leaves the run path check untouched.Tested
Ubuntu 24.04 x86_64, glibc 2.39, relinker-only Release build (
-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON); synthetic fixtures only, no title or homebrew.ctest --test-dir build-relinker -j4: 243/243 passed.linux_dynamic_stringsandguest_runpathfail against themainbinary (('', [], 0, ...)and('$ORIGIN/libs:', 0, ...), both with exit 0) and pass with this change.--rpath '$ORIGIN:relative/libs'and--rpath '$ORIGIN/libs:'relink with exit 0 onmainand now exit 2 withGuest Linux run path must be absolute or begin with $ORIGIN;--rpath '$ORIGIN:$ORIGIN/libs'still exits 0.RUNPATH [nonexist:]and[nonexist::x]findlibdata.soonly when the program is started inside the directory that holds it (exit 8 there,cannot open shared object fileelsewhere);RUNPATH []finds it in neither place.python3 tools/check_conventions.py --base upstream/mainwith this title and description passed.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)