feat(libSceNpCommon): implement title ID and secret comparisons #12866
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12866"
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 xdCloudy on 2026-10-29T13:16:13Z.
What
Implement only the two title-value comparisons in libSceNpCommon. Title-ID equality compares 12 bytes from the raw value against 12 bytes at object offset 8. Title-secret inequality compares 128 bytes at object offset 8 against the raw 128-byte secret. The object prefix and bytes outside those ranges are excluded.
Firmware 13.60 libSceNpCommon.sprx, SHA-256 AB696280CAF5CF465C62E00D1785FB4348B59A7E376D7C6802453419E5765CD0: entry 0x1a780, NID 6jHOZ6fItFU, establishes the title-ID range; entry 0x1abe0, NID 7b5y1XSa+KQ, establishes the secret range and inequality. These were inspected statically, not executed on a console. Guest reads use GuestCopyIn; null, unreadable or overflowing addresses throw std::runtime_error as an explicit host choice. Native invalid-pointer faults remain unmeasured.
Time/RtcTick operators are left to #12859 and are not part of this PR. Current upstream main
5bae1a4bc2is integrated; the net diff remains four intended files. Adjacent shared-file changes may need merge-order reconciliation.Tested
Windows x86_64, WinLibs GCC, CMake/Ninja Release, head
4a10a05642: built guest_np_common_tests and passed guest_np_common_ids and guest_np_common_clock (2/2). Coverage includes equal/unequal values, exact comparison bounds, prefix exclusion, null/unreadable operands and address-offset overflow. Conventions and diff whitespace checks passed. The earlier independent macOS ASan/UBSan review is separate from these local results. No console or new Linux runtime result is claimed; new-head hosted checks are pending.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 rooklz on 2026-10-29T13:21:23Z.
Review: COMMENTED
Reviewed at
49ea3e1b23on macOS arm64 (Apple clang, C++20, ASan+UBSan). I built a standalone harness: your five functions and thecopyGuest/copyGuestOffsethelpers copied verbatim fromPendingExportsRound7.cpp, aGuestCopyIn_nid_no_patchstand-in with the same contract asGeneral.cpp:848(null/overflow → false, otherwise a checkedmach_vm_read_overwrite), and your newtestIds/testClockrows unchanged. Your rows pass.merge-treeagainst main157b02c4f1is clean.1. Same exports as #12859 (blocking: needs coordination).
tools/pr_overlap.py --branch(1412 PRs probed) lists #12859 (hypermoist,sce::np::Time, opened 17 minutes before this PR) under Same exports for_ZN3sce2npeqERKNS0_4TimeES3_,_ZN3sce2npleERKNS0_4TimeERK10SceRtcTickand_ZN3sce2npneERK10SceRtcTickRKNS0_4TimeE. #12859 puts all eighteen Time/RtcTick comparison operators inRuntime.cpp, typedconst NpTime*/const RtcTick*. The two branches conflict inPendingExportsRound7.cppandApi.hpp. That makes the checklist item "no other open PR implements the same functions" incorrect. I'd suggest dropping the three Time operators here and keeping the two title-ID/title-secret comparisons. The body's Overlap note will also need updating. pr_overlap also flags hunk-adjacency with #12818, #12823, #12830 and #12852 (Api.hpp/debt/test neighbours, no shared exports).2. The unreadable-input
falseis an invented result. The body says the firmware dereferences its arguments directly and "does not show this fallback". On a null or unreadable pointer the console faults; it doesn't return false. CONTRIBUTING asks us to throw on unknown behaviour, not return a made-up success or failure value. Main has a precedent for this:libSceBeisobmf/Export.cpp:26/52/73/134throwsstd::runtime_error("... is unreadable")whenGuestCopyIn_nid_no_patchfails. Suggestion: havecopyGuest/copyGuestOffsetthrow (or callNotImplemented_nid_no_patch(__func__)) instead of returning false. Turn the three "defensive false fallback" rows into throw expectations, and add adebt/libSceNpCommon.mdline saying the invalid-pointer behaviour is unmeasured. It also matters for coverage: the four mutants your rows can't kill all sit on this path. They are: returntrueon an unreadable right operand inleand inne; drop theoffset > UINTPTR_MAX - addresscheck, which is equivalent becauseGuestCopyInrefuses the wrapped address anyway; and the null-only check. A throw contract removes all of them.3. Comparison mutants your rows miss (optional rows below). I ran 15 single-line mutants and your rows kill 7. These survive:
leas signedint64_t: the only boundary row is MAX<=MAXle/eq/netruncated to 32 bits: no tick differs only in the upper halfnereplaced with>: the only "different" row is MAX vs 0The rows below go at the end of
testClock. With them, every non-fallback mutant is killed (11/11). They pass on49ea3e1b23:If the Time operators move to #12859 per point 1, these rows belong there instead.
Provenance: this is module disassembly with no proprietary code copied. That meets REVERSE_ENGINEERING.md for what the call does, and the body says plainly that nothing was run on a console. The title-ID offset 8 and title-secret offset 8 are consistent with #12823's
NpTitleSecret::Clear, which keeps the first 8 bytes.AI-assisted review.
Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-29T15:21:36Z.
Review: APPROVED
Re-reviewed at
8c4070dc37on macOS arm64 (Apple clang, C++20, ASan+UBSan). Thanks for picking up all three points from my earlier review.What changed. The three
sce::np::Timeoperators are gone, andpr_overlap(1430 PRs probed) no longer reports any same-export overlap with #12859.copyGuest/copyGuestOffsetnow throwstd::runtime_errorinstead of returningfalse. Each throw is pinned by rows covering null, unreadable (address 1) and offset-overflow (UINTPTR_MAX - 4) operands on both sides of both functions. The debt file has a line saying invalid-pointer behaviour is unmeasured and that the throw is an emulator-side choice. The two removed stub lines now match the new section.Harness. This is the same standalone setup as before: both functions and the anonymous-namespace helpers copied verbatim from
PendingExportsRound7.cpp, aGuestCopyIn_nid_no_patchstand-in matchingGeneral.cpp:848(null/overflow → false, otherwise a checkedmach_vm_read_overwrite), and your newtestIdsrows unchanged. PASS.Mutants (18 single-line): 15 KILLED.
==→!=: all killed. The byte-20 row pins the upper bound and the byte-19 row pins the last compared byte.!=→==, right read at offset 8: all killed. ThetitleSecretObject[7]row pins the prefix exclusion.runtime_error→logic_error: all killed.!sourcecheck in either helper, or dropping theoffset > UINTPTR_MAX - addresscheck.GuestCopyIn_nid_no_patchalready refuses null and wrapped ranges, so the result is the same exception either way. No rows needed.Gates.
check_conventions --base upstream/mainpasses,git diff --checkis clean, andmerge-treeagainst mainbb04a4f1eais clean. CI: 5 pass, 5 skipped.pr_overlapreports only #12823 (NpTitleSecret::Clear). That's hunk adjacency on the include block, the neighbouringApi.hpplines and the debt stub lines, with no shared exports, so it's just a merge-order rebase.AI-assisted review.
Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T19:54:12Z.
Review: COMMENTED
Withdrawn. This review applied a title-ID/log requirement that is not in CONTRIBUTING (
Unblocks: noneis allowed), and it contained no code review.