fix(libSceNpUniversalDataSystem): reject mismatched param struct size in sceNpUniversalDataSystemInitialize #12803
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12803"
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 Elma7e on 2026-10-29T09:58:16Z.
What
Reject mismatched parameter structure sizes (
param->size != sizeof(NpUniversalDataSystemInitParam), 16 bytes) insceNpUniversalDataSystemInitialize, throwingstd::invalid_argumentviaAPS5_INVALID_ARG_EX. This matches native module verification evidenced from PS5 firmware 13.42 module disassembly and execution data in a host harness, where the module verifies strictlysize == 16and returns0x80553112for any other size (smaller or larger). Cover undersized (sizeof - 1) and oversized (sizeof + 8) parameter structure rejection inGuestNpUniversalDataSystemQueries.cppand document the host gap, firmware execution data in a host harness, and local title call-site constants in technical debt documentation.Tested
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 XairRrR on 2026-10-29T10:02:58Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The change merges cleanly, builds, its test passes and fails without the fix as it should. But nothing supports the strict
sizeequality check, and the new technical-debt entry describes what the code does instead of stating the gap.What I ran
4f1686aaca6891cb0883f245333493f6a5145f35main:f7e84c4cf1609cc10bac95a44cd431805e5ebc8amainwith--no-ff, in a clean worktree, on Arch Linux 7.2.11-zen, GCC 16.2.1, Intel Core i9-14900KF.Results
maingit diff --checktools/check_conventions.py --base origin/mainAll conventions checks passed.libSceNpUniversalDataSystem,guest_np_uds_queries_tests)guest_np_uds_queries,np_uds_events,guest_np_trophy*(6 tests)guest_np_uds_queriesfails, as expectedctest, merged tree
Negative control
I restored only
core/libs/prx/libSceNpUniversalDataSystem/src/System.cppfrommainand rebuilt.guest_np_uds_queriesthen aborts at the first new size check:ctest, production file reverted
After the run I restored the merged file and rebuilt, and the test passed again.
Findings
Blocking
System.cpp:12now throws for everyparam->sizeother than 16. The test also requires that a larger size (sizeof + 8) be rejected (GuestNpUniversalDataSystemQueries.cpp:41-42). The PR gives no source for this check: no console measurement and no reference implementation. The debt file already cites KytyPS5 for this library, and itsNpUniversalDataSystemInitializerejects onlynullptr. It logssizeand accepts any value. So before this PR, a title that passes a differentsize(for example a different SDK revision of the struct, or a zero-filled struct) initialised normally; after it, the title aborts inAPS5_INVALID_ARG_EX. Throwing when the native behaviour is unknown is consistent with the project rules, but then the uncertainty has to be written down. The new entry,docs/dev/debt/libSceNpUniversalDataSystem.md:26, sits under### Unknown function infobut only says the function "enforces struct size matchingsizeof(NpUniversalDataSystemInitParam)before returning OK". CONTRIBUTING.md requires that "An entry states the gap first (what differs from the console, what is unverified, what throws)".Suggested fix: either cite a source showing that the console rejects
size != sizeof(...), including larger values, or reword the entry to state the gap. For example: whether the console checkssize, whether it accepts larger values, and which error it returns are not verified on a console (KytyPS5 accepts anysize); the host throwsstd::invalid_argumentfor anysizeother than 16. If there is no source for rejecting larger sizes, consider keeping only the checks you can justify, and dropping thesizeof + 8assertion, which asserts unverified behaviour.Non-blocking
fix(...)and the description doesn't say what was broken. Without a title or trace showing a wrongsizecausing a problem, this tightens validation rather than fixing a bug. Saying so inWhatwould help reviewers judge the compatibility risk above.Not verified
sceNpUniversalDataSystemInitializefor a mismatchedsize: I have no hardware or SDK reference.sizevalue real titles pass. I didn't run any title, so I can't confirm that none of them passes a value other than 16.To get this to a good state
docs/dev/debt/libSceNpUniversalDataSystem.md:26so it states what is unverified and what throws, as CONTRIBUTING.md requires.sizeof + 8to be rejected.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-29T10:45:54Z.
Review: APPROVED
Re-checked — approved
The new commit relaxes the check to reject only
size < 16, drops thesize + 8test case and rewrites the debt entry to state the gap. It merges cleanly, builds, the tests pass and the negative control fails as it should.What changed since my last review
System.cpp:12now throws only forparam->size < sizeof(NpUniversalDataSystemInitParam). Larger sizes are accepted.GuestNpUniversalDataSystemQueries.cpp:38-40keeps only thesizeof - 1rejection. Thesizeof + 8case is gone.docs/dev/debt/libSceNpUniversalDataSystem.md:26now opens with what is unverified (whether the console checkssize, whether it accepts larger values, which error it returns), cites KytyPS5 accepting anysize, and says what throws.main. The author's reply addresses both my review and the comment from oneandonlydean. The PR title and description did not change.What I ran
c5a41714281d4ba5c3166b427a9c3860e8440e5bmain:1db077e876a839f75d11a56e728e7f56a4a8c25emainwith--no-ff, in a clean worktree, on Arch Linux 7.2.11-zen, GCC 16.2.1, Intel Core i9-14900KF.maingit diff --checktools/check_conventions.py --base origin/mainAll conventions checks passed.libSceNpUniversalDataSystem,guest_np_uds_queries_tests)guest_np_uds_queries,np_uds_events,guest_np_trophy*(6 tests)System.cppfrommain)guest_np_uds_queriesaborts, as expectedguest_np_uds_queriespassesctest, merged tree
ctest, production file reverted
The only production change is the size condition, so the abort comes from the new
sizeof - 1check.Previous findings
sizeof + 8to a throw. The debt entry states what is unverified and what throws, as CONTRIBUTING.md requires. Undersized structs still throw without a console source. That follows the rule to throw when the native behaviour is unknown, and the debt entry records it.fix(...)title,Whatdoesn't say what was broken): Still open. TheWhatsection is also out of date now: it still says the size is validated "againstsizeof(NpUniversalDataSystemInitParam), throwing ... on mismatch", but the code rejects only smaller sizes.New findings
Blocking
None.
Non-blocking
size < 16(for example "reject undersized init param"), and say that this tightens validation rather than fixing an observed failure. The commit subject already says this. Whoever squash-merges will probably take the PR title.Not verified
sizebelow 16, and which error it returns. I have no hardware or SDK reference.sizethe local titles pass. I didn't inspect or run any title, so I can't confirm that none of them passes a zeroed or smaller struct, which would now abort.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-02T22:49:23Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
This pull request does not merge cleanly into
main(5cb015caaa): head f6ce803a8486cbb1ba01e5d9fc43f5656808916b conflicts indocs/dev/debt/libSceNpUniversalDataSystem.mdPlease rebase it onto current
main. I will review the change once it merges cleanly.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-02T23:14:36Z.
Review: CHANGES_REQUESTED
Re-checked — changes still requested
The code and test have not changed since c5a4171428. The new commit changes only the debt entry, which now records BunnyFl's 13.42 firmware run and the local-title call sites. That run shows the module rejects every
sizeother than 16, but the code still returns success for larger sizes.What changed since my last review
main5cb015caaa.System.cppandGuestNpUniversalDataSystemQueries.cppare byte-identical to c5a4171428 (see the range-diff).docs/dev/debt/libSceNpUniversalDataSystem.md:26now says the following:size == 16and returns0x80553112for any other size.0x80553102for a nullparamorpool_size == 0, and0x80553118when already initialized.size < 16and accepts larger sizes.What I ran
32128f3d1d07f9302231d1dc676b1dc74b6c6eaa,main5cb015caaaaf83f8ee431414ee6a457b5b307d49, merged treec1ce23c839e9369acaca4d94c9f0b661ec84f25a(--no-ff, clean worktree). Debian 13 VM, GCC 14.2.0, Release, Ninja.git diff --checkcheck_conventions.pyAll conventions checks passed.libs(script)guest_np_uds_queries, merged treeSystem.cppfrommain)guest_np_uds_queriesaborts (Subprocess aborted), as expectedgit status --porcelainSystem.cpprestored frommain(see below)Unrelated failures with the production file from main
agc_driver_image_sample_lod_clamp_shader_laneis an AGC sampling test that this change cannot reach.unwrap_self_..._destination_directory_groupfails inos.chownwithEINVALinside the sandbox.main(096c45570f). Both failures come frommainor this machine.Previous findings
sizerule, gap not stated): No longer applies, as I resolved it then. New evidence changes the picture, so I am reopening the question as new blocking finding 1 below. I accepted "reject only < 16" because nothing showed that larger sizes are invalid. Now there is evidence.Whatdid not match the code): Resolved. The title says "reject undersized param struct". The description says the change tightens validation rather than fixing an observed failure.New findings
Blocking
size > 16, which the PR's own debt entry says the module rejects. AtSystem.cpp:12, onlysize < 16throws. BunnyFl's 13.42 run (comment of 2026-10-30) returned0x80553112for 0x11, 0x18, 0x20, 0x100 and~0. The PR now writes this into the debt entry.size > 16the function now neither does what the module does nor throws. CONTRIBUTING.md requires one or the other.param->size != sizeof(NpUniversalDataSystemInitParam)with the sameAPS5_INVALID_ARG_EX, and pinsize + 8(or 0x18) to a rejection in the test, citing the 13.42 run in the debt entry. Alternatively, return0x80553112for anysize != 16, as the module does, and test that. Either way, update the debt entry and the description to match.Non-blocking
libSceNpUniversalDataSystem.md:26says "tested natively", which a reader can take to mean on a console. BunnyFl's run used a host harness on Windows, not a console, and partly skipped the module's start routine.0x80553112/0x80553102, acceptspool_size == 0, and keeps no initialized state. The firmware data can follow as the evidence.Not verified
np_uds_events. Its executable is not part of this selected build ("Not Run"), and the PR does not touch it.To get this to a good state
sizecheck match the documented module behaviour (!= 16, either thrown or returned as0x80553112).Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-02T23:43:55Z.
Review: APPROVED
Re-checked — approved
The PR now rejects every
sizeother than 16, as the 13.42 module run showed. The test pins both a smaller and a larger size. The debt entry opens with the host gap and says the firmware data came from a host harness, not a console.What changed since my last review
System.cpp:12: the condition changed fromparam->size < sizeof(...)toparam->size != sizeof(NpUniversalDataSystemInitParam).GuestNpUniversalDataSystemQueries.cpp: added a check thatsizeof + 8(0x18) is rejected, next to the existingsizeof - 1check.libSceNpUniversalDataSystem.md:26: the entry now opens with the gap. The host throws for a nullparamor anysize != 16, acceptspool_size == 0and keeps no initialized state. The 13.42 run follows as evidence and is described as "run in a host harness (on Windows, not on a console)".What I ran
Head
fcc66ecc5714cf30247e37aee3d069f36f14f526,main5cb015caaaaf83f8ee431414ee6a457b5b307d49, merged tree99114ca0901abb53a3fcdd5ea08fbd65f9594675(--no-ff, a clean worktree). Debian 13 VM, GCC 14.2.0, Release, Ninja.git diff --checkcheck_conventions.pyAll conventions checks passed.libs(script)guest_np_uds_queries, merged treeSystem.cppfrommain)Subprocess aborted), as expected<instead of!=)Subprocess aborted), so thesizeof + 8case does reject the relaxed rulegit status --porcelainis emptyFailures reported by the script
agc_driver_image_sample_lod_clamp_shader_laneandunwrap_self_UnwrapTest_test_new_output_inherits_the_destination_directory_groupare the same two failures I saw on the previous head, on the samemain5cb015caaa.System.cpp, restored frommain.unwrap_selfcase fails inos.chownwithEINVALinside the sandbox.main(096c45570f).Previous findings
size > 16, which the module rejects): Resolved. The check atSystem.cpp:12is now!= sizeof(NpUniversalDataSystemInitParam).NpUniversalDataSystemInitParamis twostd::size_tfields (core/libs/SceTypes.hpp:1559-1562), so the size is 16 on every 64-bit target. The test pins 0x18 to a rejection, and negative control 2 shows that this case catches the earlier<rule.New findings
Blocking
None.
Non-blocking
None.
Not verified
size; 0x10000 or 0x40000 inpool_size). These are reported by the author; I did not inspect any title.