Repository navigation
fix(libSceHttp): read and write sceHttpUriParse and sceHttpUriCopy guest data through guest copies - #20858
Merged
oneandonlydean merged 10 commits intoNov 15, 2026
Conversation
…pies sceHttpUriParse measured and copied the source URL with direct string access, so an unmapped URL faulted the host. The URL is now read page by page with GuestCopyIn, without a length limit, as the direct access did, and errno is preserved across each copy. An unreadable URL returns ERROR_INVALID_URL, the code the same function already returns for a null URL. A readable URL is parsed from the same bytes as before.
sceHttpUriParse must return ERROR_INVALID_URL and keep errno when the source URL cannot be read. A readable URL longer than one page must still parse, so the page-by-page copy is pinned against readable input.
…tCopyOut sceHttpUriParse stored the required size by writing through the caller's pointer, so an unmapped output faulted the host. The size is now written with GuestCopyOut, errno preserved, and an unwritable pointer returns ERROR_INVALID_VALUE, the code this library returns for an invalid output value. A writable pointer receives the same value as before.
An unwritable required-size pointer must return ERROR_INVALID_VALUE and keep errno.
sceHttpUriParse wrote the pool strings and the output element by dereferencing the caller's pointers, so an unmapped pool or output faulted the host. Each string is now written with its terminating NUL through GuestCopyOut, in the same order as before, and the element is written once with GuestCopyOut. Only the bytes the function wrote before are written, so padding in the pool is left as it was. An unwritable pool or output returns ERROR_INVALID_VALUE.
An unwritable output element or pool must return ERROR_INVALID_VALUE and keep errno. A writable call must still fill the element and its hostname.
… copies sceHttpUriCopy read the source element and its strings by dereferencing the caller's pointers, so an unmapped source faulted the host. The element is now copied in with GuestCopyIn and each string is read with the page-by-page guest copy, without a length limit, as before. The output and pool are cleared first, as before, so an output that aliases the source still sees the cleared element. An unreadable source or string returns ERROR_INVALID_URL, the code the function already returns for a null source. Readable input copies the same bytes as before.
An unreadable source element must return ERROR_INVALID_URL and keep errno. A readable source must copy its hostname and port, and an unreadable string inside a readable source must also return ERROR_INVALID_URL.
sceHttpUriCopy cleared the output and pool, wrote the strings and the output element, and stored the required size, all by dereferencing the caller's pointers, so an unmapped output or pool faulted the host. The output and pool are cleared first, in the same order as before, with a 256-byte zero copy for the pool and a guest copy for the element. Each string is then written with its terminating NUL through GuestCopyOut, and the element and the required size are written with GuestCopyOut. The bytes written are the same as before. An unwritable output, pool or required-size pointer returns ERROR_INVALID_VALUE.
Unwritable output, pool or required-size pointers must return ERROR_INVALID_VALUE and keep errno. A size-only call must still report the required size of the readable source: the hostname and four empty fields, each with its terminator, 16 bytes.
MarcZX10
force-pushed
the
fix/libsceHttp-uri-parse-copy-guest
branch
from
November 15, 2026 17:46
be89ded to
0892125
Compare
12 tasks done
oneandonlydean
added a commit
that referenced
this pull request
Nov 16, 2026
Collaborator
|
@MarcZX10 after this merged, the Linux |
oneandonlydean
pushed a commit
that referenced
this pull request
Nov 17, 2026
… copies This reverts 3c9ddc9 (#21158), which reverted #20858 because guest_http aborted on Linux on every run. The cause, found on #21158, is the padding of the SceHttpUriElement the two calls build on the host stack and write to the guest whole; the next commit zeroes it. Co-authored-by: MarcZX10 <67475268+MarcZX10@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
sceHttpUriParseandsceHttpUriCopyread and wrote guest memory by dereferencing the caller's pointers: the source URL, the source element and its strings, the output element, the pool and the required size. An unmapped pointer faulted the host.GuestCopyIn, without a length limit, as the direct string access did. The required size, the pool strings (each with its terminating NUL) and the output element are written withGuestCopyOut, in the same order and with the same bytes as before. An unreadable URL returnsERROR_INVALID_URL, the code the function already returns for a null URL. An unwritable pool, output or required-size pointer returnsERROR_INVALID_VALUE(0x804311FE), the code this library already uses for invalid output values.GuestCopyInand each string is read the same way. The output and pool are cleared first, as before, so an output that aliases the source still sees the cleared element, and the existing test that pins that case keeps passing. Unreadable input returnsERROR_INVALID_URL. The output, pool and required size are written with guest copies, with the same order and bytes as before.sceHttpUriBuild,sceHttpUriEscapeandsceHttpUriMergeare not changed here (PR fix(libSceHttp): safely probe the outputs of the URI builders #20805 covers their outputs).Commits: one
fixand onetestper function, ten in total. The firstfixcommit compiles on its own; its test target comes with the second commit.No external source is needed: the change only copies guest memory, and the error codes are the ones these functions already return.
Tested
Host: Linux, kernel 6.1, x86_64. Throwaway archive build of the tree, with the CPU startup gate patched in that build only (no change to HostCpu.cpp in this branch).
f5cc88c1e5(rebased), then again at the final headbe89ded5a5(rebased onto03dc6b3020):guest_http_uri_guest_pointers(new),guest_http,guest_http_uri_localeandguest_http_cookiesall Passed.upstream/main'sUri.cppand this branch's tests,guest_http_uri_guest_pointersaborts. With the fix it passes.fixcommit was built withguest_http_tests; the new test target does not exist at that commit.process_vm_readv/process_vm_writevon the own process. Callers that pass host memory (see below) still work, since those copies accept any readable or writable address in the process.pr_overlap.pyfailed closed on feat(libSceHttp): add synchronous HTTP request transport #9834, fix(http): trust the system CA list for HTTPS requests #11134 and fix(libSceHttp): copy guest outputs through GuestCopy #19769, all inCMakeLists.txt. Compared by hand: feat(libSceHttp): add synchronous HTTP request transport #9834 and fix(http): trust the system CA list for HTTPS requests #11134 addRequest.cppandResolver.cppcode that callssceHttpUriParsewith host strings and a host pool; they do not changeUri.cpp, and the calls keep working with these copies. fix(libSceHttp): copy guest outputs through GuestCopy #19769 changes the cookie and CA-list outputs, not the URI functions. The new CMake block is placed afterguest_http_dates, so the hunks may need a trivial merge.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)