Repository navigation
fix(libkernel): safely probe the symbol name of dlsym - #20622
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
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.
|
|
Windows result for head Host: Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release,
AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine. |
|
Thanks @maskym for the Windows run. I've added it to the Tested section, linked to your comment. |
|
Tested head Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7, Release,
Whole batch: the full This is one combined tree, not a run of this PR alone. AI-assisted: yes (Claude Code) |
|
Thanks @kiwe147 for including this one in the batch. The |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
Nothing blocks this change; the inspected implementation copies the guest symbol name before lookup and handles unreadable and empty names through dlerror.
What I ran
Reviewed head 2a769e48751102b44b4c585a539eba7920fb785f using the prepared diff and repo_read.py. No commands or tests were run.
Results
| Check | Result | Note |
|---|---|---|
| Diff and targeted source review | passed | Three changed files read |
| Tests | not run | Results in the description are author supplied |
Findings
Blocking
None.
Non-blocking
None.
Not verified
I did not run tests or independently verify the reported platform runs. All changed files listed in the manifest were read: core/libs/prx/libkernel/Module/src/DynamicLoader.cpp, core/libs/tests/GuestDynamicLoader.cpp, and docs/dev/debt/changes/fix-kernel-probe-dlsym-name.md. Also read targeted context in core/libs/prx/libc/src/General.cpp. No changed files were excluded according to the manifest.
To get this to a good state
Nothing is required.
|
Windows run at 2a769e4875, merged onto main 4e86679b36. The fix works on Windows:
The survivor shows that the test cannot tell an unreadable name from an empty one. A one-line pin closes that. Existing runs There are two Windows runs at 2a769e4, and both only report passes. maskym ran the PR alone ( Code
Tests The focused set is
Mutations Each mutation rebuilds the merge with one change at
In M4, Probe This pin replaces test line 170: const char* unreadable = dlerror_nid_postfix();
Require(unreadable != nullptr && std::strstr(unreadable, "unreadable") != nullptr);With the pin, the merge passes (1/1, 0.65 s) and M4 is caught (abort, Checks
Host
AI-assisted: yes |
An unreadable name and an empty name both return null and set a dlerror message, so the test could not tell them apart. Check that the message for an unreadable name says so. From Helldiverr's Windows mutation run on boykopovar#20622. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @Helldiverr for the Windows run and the mutations. |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
The reviewed change safely copies the guest symbol name before lookup and adds coverage for unreadable and empty names; no defect was found in the files read.
What I ran
Reviewed head 09131a8ceb3d55e58b24a545496bef7ac0f1f88d using repo_read.py to inspect the prepared diff and relevant source ranges. No tests were run.
Results
| Check | Result | Note |
|---|---|---|
| Diff and targeted code review | passed | Changed behavior and relevant helper inspected |
| Tests | not run | Reported runs are author supplied |
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests were run independently. The review bundle and all changed files were read: DynamicLoader.cpp, GuestDynamicLoader.cpp, and fix-kernel-probe-dlsym-name.md. No changed files were excluded. Reported Linux and Windows runs were not independently verified.
To get this to a good state
Nothing is required.
What
dlsymchecked*nameand then handed the guest pointer to the module lookups, the hostdlsymfallbacks andNid::ComputeNid, which all read the string in place. A non-null name pointing at unmapped memory faulted the host.The name is now copied into a host string with
CopyGuestString_nid_no_patchfirst, and every lookup uses the copy. The cap is 64 KiB, far above any real symbol name. An unreadable name returns null and sets adlerrormessage ("dlsym: unreadable symbol name"), the same failure channeldlsymuses for an empty name or a missing symbol. The lookup order, the default-scope and-2handle cases, the NID and#guestfallbacks and the results for valid names are unchanged.dlsymruns when a title resolves symbols, not per frame, so the copy costs nothing that matters. The debt entry goes in a fragment underdocs/dev/debt/changes/and records this as unmeasured.Tested
Linux (Ubuntu 26.04.1), GCC 15.2, Release.
guest_dynamic_loader:dlsymwith an unmapped name (0x10) returns null and leaves adlerrormessage. New valid-pointer case: an empty name also returns null with a message. The existing lookup, scope, missing-symbol,dlerrorthreading and reload cases still pass.guest_dynamic_loader_fixed_baseandguest_dynamic_loader_variant_namesstill pass.DynamicLoader.cppfrommainand these tests,guest_dynamic_loadersegfaults.2a769e4875merged alone intomain33cbb0b388(Windows 11, i7-12700K, WinLibs GCC 15.2.0, Release):guest_dynamic_loaderpasses 3 of 3 runs.git merge-treeagainst the open PRs that touchDynamicLoader.cppor the test (fix(libkernel): read the module image through dlinfo and never own the program's own handle #16922, feat(relinker): support VEX guest GS memory accesses #11698, feat(relinker): support SSE guest GS memory accesses #11689, feat(relinker): support short scalar guest GS instructions #11661): no new conflicts (the three relinker PRs already conflict withmain).tools/check_conventions.pypasses on the branch and this body;tools/debt_fold.py --checkpasses with the fragment applied tomain.2a769e4875, applied with other PRs ontomainfd4aeed483(one combined tree, not this PR alone), Windows 11, WinLibs GCC 15.2.0 r7, Release, no validation layer:guest_dynamic_loaderandguest_dynamic_loader_variant_namespass on an NVIDIA GeForce RTX 3080 (driver 621.24).11-24,
09131a8ceb: test pin from Helldiverr's run. Helldiverr's Windows run (Ryzen 9 9950X3D, Windows 11 Pro 26300, WinLibs GCC 15.2, this head's parent2a769e4875merged ontomain4e86679b36):guest_dynamic_loaderpasses in 3 of 3 runs, with the source reverted it segfaults on the unmapped name, and 3 of 4 mutations are caught. The survivor: an unreadable name and an empty name both return null with adlerrormessage, so ignoring a failed copy still passed.09131a8cebadds their pin: the message after the unmapped name must sayunreadable. Linux (Ubuntu 26.04.1, GCC 15.2, Release), the head merged ontomainadacf0bd83:guest_dynamic_loaderpasses in 3 of 3 runs, and with a failed copy ignored it aborts.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)