fix(libSceAppContent): safely probe guest initialization and query pointers #18954
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18954"
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 pushkarreddyy on 2026-11-12T15:56:46Z.
What
In
core/libs/prx/libSceAppContent/Export.cpp, several exports directly dereferenced guest pointers or passed them to host operations without safe copying, causing host crashes on unmapped memory:sceAppContentInitialize: Safely probeinitParamandbootParamviaGuestCopyIn_nid_no_patchbefore checking reserved fields, zerobootParamviaGuestCopyOut_nid_no_patch, and preserve callererrnoacross copy failures.sceAppContentGetPftFlag: Write the output flag viaGuestCopyOut_nid_no_patchpreserving callererrno.sceAppContentGetAddcontInfoListByIroTag: WritehitNumviaGuestCopyOut_nid_no_patchpreserving callererrno.sceAppContentTemporaryDataGetAvailableSpaceKb: Safely probemountPointviaGuestCopyIn_nid_no_patchbefore inspecting mount path prefixes, probe and writeavailableSpaceKbviaGuestCopyOut_nid_no_patch, and preserve callererrno.core/libs/tests/GuestAppContent.cppcovering unmapped pointers and errno preservation across initialization and queries.docs/dev/debt/libSceAppContent.md.Tested
core/libs/tests/GuestAppContent.cppverifying unmapped pointer refusal (ErrorParameter) anderrnopreservation acrosssceAppContentInitialize,sceAppContentGetPftFlag,sceAppContentGetAddcontInfoListByIroTag, andsceAppContentTemporaryDataGetAvailableSpaceKb.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-12T16:12:27Z.
Review: COMMENTED
Reviewed unmapped guest pointer probing in libSceAppContent — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
c45a37548ec7aff5bb704891dde1a216d002380d, basemain.diff.patch. The three changed files were read through the diff; their full text at head was not read. Excluded by rule: none.Results
Findings
Blocking
None.
Non-blocking
core/libs/prx/libSceAppContent/Export.cpp:310— Before this change,sceAppContentInitializereadinitParamonly when the SDK version was at least0x01500000. Now any non-nullinitParamthat failsGuestCopyIn_nid_no_patchreturnsSCE_APP_CONTENT_ERROR_PARAMETERfor every SDK version, so an older title that passes an unmappedinitParamnow gets an error where it used to succeed. The added tests do not show an older-SDK case. Either probeinitParamonly inside the0x01500000branch, or add a test for that path.core/libs/prx/libSceAppContent/Export.cpp:357— The probe readsavailableSpaceKb, which is an output pointer, so a guest buffer that is writable but not readable is refused. This is a design choice, not a defect. The debt note says console behaviour on unmapped memory is unmeasured, so it should say this too.Sources
GuestCopyIn_nid_no_patch: returns false for address 0 and for a size that overflows.Not verified
Fixes #18947: the linked issue was not read.To get this to a good state
Nothing is required.
Optional: the two non-blocking points above.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T04:44:23Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing in the inspected changes shows a blocking defect; review was limited to the changed files and targeted implementation context.
What I ran
Reviewed head
4ad7ff9b51daa482f148401596ab0c52487cc3dc. No commands or tests were run.Results
Findings
Blocking
None identified in the inspected code.
Non-blocking
None.
Not verified
The complete changed test file and documentation were not read. Test execution and physical-console behavior were not verified. Files read:
description.md,commits.md,manifest.json,diff.patch,core/libs/prx/libSceAppContent/Export.cpp(lines 1–90, 330–410, 550–610), andcore/libs/tests/GuestAppContent.cpp(lines 1–120). The manifest lists three changed files; the remainder of the test file anddocs/dev/debt/libSceAppContent.mdwere not read. No files were excluded by rule.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T15:27:28Z.
Review: COMMENTED
Reviewed — no blocking findings
The reviewed code adds safe guest pointer copies and errno preservation; one optional compatibility question remains about reading bootParam on older SDKs.
What I ran
Reviewed head
1b4bcbb3808586bd09d0f2e5410119bf97b9874eusing the prepared diff andrepo_read.py.Results
Negative control
Not run; no test execution was available.
Findings
Blocking
None.
Non-blocking
core/libs/prx/libSceAppContent/Export.cpp:354:bootParamis read-probed for every SDK version, although reserved-field validation only applies from SDK0x01500000. For older SDKs, this adds a read-permission requirement to an output buffer that previously only needed to be writable. Consider skipping the input copy for older SDKs, and add coverage for that case if write-only guest buffers are supported.Sources
Reviewed
core/libs/prx/libSceAppContent/Export.cpp,core/libs/tests/GuestAppContent.cpp, anddocs/dev/debt/libSceAppContent.mdat the pinned head. Changed code references above point to the prepared diff for that head.Not verified
Build and unit-test results were not verified. All three changed files listed as reviewed in the manifest were read. No files were excluded by the supplied manifest;
review/files.jsonwas not available through the reader.To get this to a good state
Nothing is required. Optional: clarify whether older-SDK boot output buffers must be readable, and adjust the probe or document the behavior accordingly.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T16:43:20Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: preserve the documented SDK behavior for legacy initialization when
bootParamis unreadable.What I ran
Reviewed head
524d977aafff807dfd77498a9908589c22157043against the prepared patch; no commands or tests were run.Results
Findings
Blocking
core/libs/prx/libSceAppContent/Export.cpp:354— For SDK versions below0x01500000, the prior implementation did not readbootParambefore clearing it. The new unconditionalGuestCopyIn_nid_no_patchmakes an unreadablebootParamreturnSCE_APP_CONTENT_ERROR_PARAMETER, changing legacy behavior and contradicting the PR's SDK-specific compatibility demonstrated forinitParam. Keep the safe output write, but avoid making a readable input boot record a requirement for legacy SDKs.Non-blocking
None.
Not verified
core/libs/prx/libSceAppContent/Export.cpp,core/libs/tests/GuestAppContent.cpp, anddocs/dev/debt/libSceAppContent.md. No changed files were excluded in the manifest.To get this to a good state
Retain the SDK-specific legacy behavior for
bootParam, and add a regression test for an unreadable boot pointer with an SDK version below0x01500000; rerun the unit tests and conventions check on the updated head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T17:39:45Z.
Review: APPROVED
Reviewed — looks good
The pointer probes and errno preservation are consistent with the existing guest-copy helpers; the review covers all three changed files at head
5df954574527867c757a4f7ac305072734147800.What I ran
No tests or build commands were run. I read
description.md,commits.md,manifest.json,diff.patch, and the full text of all three changed files. I also read the relevant guest-copy implementation inGeneral.cpp.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The unit tests and conventions check reported in the PR description were not run in this review. Console behavior for invalid guest pointers remains unmeasured, as documented in the changed debt entry.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T18:33:06Z.
Review: APPROVED
Reviewed — looks good
The changed code safely probes the targeted guest pointers and preserves
errno; I found no verified blocking defect in the reviewed files.What I ran
Reviewed head
ed8bd43279d02fa7872ff870b04a85eac9185f8cusingrepo_read.pyto inspect the prepared diff and repository files. No tests or build commands were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Tests, build, conventions check, and console behavior were not verified. Read:
core/libs/prx/libSceAppContent/Export.cpp,core/libs/tests/GuestAppContent.cpp,docs/dev/debt/libSceAppContent.md, plus the prepared description, commits, manifest, and diff. The file listing identified three changed files; all three were read.files.jsonwas not present in the review bundle.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T02:22:01Z.
Review: COMMENTED
Reviewed — comments
The change adds guest pointer probing and errno preservation; I found a possible mismatch in how a legacy SDK path handles an unreadable boot parameter.
What I ran
Reviewed head
a86d409288944a22d285858e048424b5b2e1b2ad. Read the prepared description, commits, manifest, diff, and the changed implementation and test source ranges listed below. No tests or builds were run.Results
Findings
Blocking
None verified.
Non-blocking
sceAppContentInitializereadsbootParamon SDK 0x01500000 and newer to validate reserved fields, then always writes a cleared structure. On older SDKs it skips the read, but still performs the write. The tests exercise a write-only page on non-Windows hosts, while the host's guest-copy implementation may not treat write-only memory consistently across platforms. Consider documenting this platform dependence or adding a test using the project's mapped guest memory abstraction. Changed line:core/libs/prx/libSceAppContent/Export.cpp:343.Not verified
core/libs/prx/libSceAppContent/Export.cpp,core/libs/tests/GuestAppContent.cpp, anddocs/dev/debt/libSceAppContent.md. All three changed files are marked included in the manifest and their relevant ranges were read. No files were excluded according to the manifest.files.jsonwas not available through the reader.To get this to a good state
Nothing is required. Optional: clarify the write-only-page test's platform assumptions.