feat(libressl3): retain X509 store references #12580

Closed
PrivacyOnion wants to merge 2 commits from upstream-pr/12580 into main
PrivacyOnion commented 2026-10-28 21:20:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-10-28T21:20:52Z.


What

Implement X509_STORE_up_ref_nid_postfix in libSceLibreSsl3.

  • In core/libs/prx/libSceLibreSsl3/src/Key.cpp, implement X509_STORE_up_ref_nid_postfix(LibreSslX509Store* store) to atomically increment store->references via Retain_nid_no_patch, following LibreSSL 4.0.0 x509_lu.c#L240-L244.
  • Reject null store pointers by throwing std::invalid_argument("X509_STORE_up_ref requires a store").
  • Verify LibreSslX509Store size (136 bytes) and references offset (128 bytes) from libSceLibreSsl with static_assert in Key.cpp.
  • Declare X509_STORE_up_ref_nid_postfix(LibreSslX509Store* store) in core/libs/prx/libSceLibreSsl3/include/Api.hpp and remove the stub from core/libs/prx/libSceLibreSsl3/Export.cpp.
  • Document technical debt in docs/dev/debt/libSceLibreSsl3.md.
  • Expand core/libs/tests/GuestLibreSsl3KeyReference.cpp to cover LibreSslX509Store with CheckKey<LibreSslX509Store>(X509_STORE_up_ref_nid_postfix, 128).

Tested

Windows 11, verified reference count increments across initial values, sequential retain, and concurrent multithreaded retain via GuestLibreSsl3KeyReference.

Ran locally on 71e4f22169:

$ ctest --test-dir build -R '^guest_libressl3_key_reference$' --output-on-failure
    Start 2225: guest_libressl3_key_reference
1/1 Test #2225: guest_libressl3_key_reference ....   Passed    0.05 sec

100% tests passed, 0 tests failed out of 1

Total Test time (real) =   0.20 sec

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: #12578
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5057883947 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12580). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-10-28T21:20:52Z. --- ### What Implement `X509_STORE_up_ref_nid_postfix` in `libSceLibreSsl3`. - In `core/libs/prx/libSceLibreSsl3/src/Key.cpp`, implement `X509_STORE_up_ref_nid_postfix(LibreSslX509Store* store)` to atomically increment `store->references` via `Retain_nid_no_patch`, following LibreSSL 4.0.0 [x509_lu.c#L240-L244](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/x509/x509_lu.c#L240-L244). - Reject null store pointers by throwing `std::invalid_argument("X509_STORE_up_ref requires a store")`. - Verify `LibreSslX509Store` size (136 bytes) and `references` offset (128 bytes) from `libSceLibreSsl` with `static_assert` in `Key.cpp`. - Declare `X509_STORE_up_ref_nid_postfix(LibreSslX509Store* store)` in `core/libs/prx/libSceLibreSsl3/include/Api.hpp` and remove the stub from `core/libs/prx/libSceLibreSsl3/Export.cpp`. - Document technical debt in `docs/dev/debt/libSceLibreSsl3.md`. - Expand `core/libs/tests/GuestLibreSsl3KeyReference.cpp` to cover `LibreSslX509Store` with `CheckKey<LibreSslX509Store>(X509_STORE_up_ref_nid_postfix, 128)`. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11, verified reference count increments across initial values, sequential retain, and concurrent multithreaded retain via GuestLibreSsl3KeyReference. Ran locally on `71e4f22169`: ``` $ ctest --test-dir build -R '^guest_libressl3_key_reference$' --output-on-failure Start 2225: guest_libressl3_key_reference 1/1 Test #2225: guest_libressl3_key_reference .... Passed 0.05 sec 100% tests passed, 0 tests failed out of 1 Total Test time (real) = 0.20 sec ``` ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: #12578 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-28 21:29:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T21:29:33Z.

Review: CHANGES_REQUESTED


The implementation and focused reference-count test look internally consistent, but the PR needs an explicit landing order with the other open libSceLibreSsl3 reference-count changes before approval. I fetched the exact current heads and checked pairwise merge previews: #12580 conflicts with #12578 and #12582 in Key.cpp, GuestLibreSsl3KeyReference.cpp, and docs/dev/debt/libSceLibreSsl3.md. All three PR descriptions currently say Depends on: none.

Please agree which PR lands first, restack the later changes as needed, and record the resulting order in each affected Depends on checklist. This is a repository coordination requirement; I am not reporting a functional defect in the accessor here. Hosted Windows is still running; Ubuntu/macOS and product test jobs are not complete or are skipped.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5689940721 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12580#pullrequestreview-5689940721). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-28T21:29:33Z. **Review:** CHANGES_REQUESTED --- The implementation and focused reference-count test look internally consistent, but the PR needs an explicit landing order with the other open `libSceLibreSsl3` reference-count changes before approval. I fetched the exact current heads and checked pairwise merge previews: #12580 conflicts with #12578 and #12582 in `Key.cpp`, `GuestLibreSsl3KeyReference.cpp`, and `docs/dev/debt/libSceLibreSsl3.md`. All three PR descriptions currently say `Depends on: none`. Please agree which PR lands first, restack the later changes as needed, and record the resulting order in each affected `Depends on` checklist. This is a repository coordination requirement; I am not reporting a functional defect in the accessor here. Hosted Windows is still running; Ubuntu/macOS and product test jobs are not complete or are skipped.
MarcZX10 commented 2026-10-28 21:36:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T21:36:09Z.

Review: CHANGES_REQUESTED


Re-checked — changes requested

The ref-count change and its focused regression test look internally consistent. This PR still needs an explicit order with #12578 and #12582: exact-head pairwise merge previews conflict in the files both features edit, while the PR currently says Depends on: none.

What I ran

  • Compared #12580 head e5f35a2407c01477085fc0d9aa78ddbba669fda7 with #12578 head 00b24c75b4be4b3ee7ed97013e4ea4a7a21b3afe and #12582 head dd47c78d6d72d3d88b2d21ccac72ffd8adb193c3.
  • Generated pairwise merge previews against current main 319621ba2e578bd053b0baba2877fe70520e0737.
  • Refreshed hosted checks.

Results

Check Result
#12580 + #12578 conflict in shared implementation, test, and debt files
#12580 + #12582 conflict in shared implementation, test, and debt files
Current #12580 hosted policy checks pass
Current #12580 Windows workflow pass
Linux/product and specialized jobs skipped

Findings

Blocking

Please record an agreed dependency/landing order or restack this PR so its relationship to the two open sibling changes is explicit. The merge previews conflict in:

  • core/libs/prx/libSceLibreSsl3/src/Key.cpp
  • core/libs/tests/GuestLibreSsl3KeyReference.cpp
  • docs/dev/debt/libSceLibreSsl3.md

Non-blocking

I found no separate functional blocker in the implementation or focused test. This review is requesting changes for integration clarity only.

Sources

Not verified

I did not independently rerun the focused C++ tests. Hosted Linux/product checks were skipped.

To get this to a good state

Set the intended order in the PR body/checklist and declare the predecessor dependency, or restack and update the affected diffs so the pairwise merge previews are clean.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5690009107 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12580#pullrequestreview-5690009107). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-28T21:36:09Z. **Review:** CHANGES_REQUESTED --- # Re-checked — changes requested The ref-count change and its focused regression test look internally consistent. This PR still needs an explicit order with #12578 and #12582: exact-head pairwise merge previews conflict in the files both features edit, while the PR currently says `Depends on: none`. ## What I ran - Compared #12580 head `e5f35a2407c01477085fc0d9aa78ddbba669fda7` with #12578 head `00b24c75b4be4b3ee7ed97013e4ea4a7a21b3afe` and #12582 head `dd47c78d6d72d3d88b2d21ccac72ffd8adb193c3`. - Generated pairwise merge previews against current `main` `319621ba2e578bd053b0baba2877fe70520e0737`. - Refreshed hosted checks. ## Results | Check | Result | |---|---| | #12580 + #12578 | conflict in shared implementation, test, and debt files | | #12580 + #12582 | conflict in shared implementation, test, and debt files | | Current #12580 hosted policy checks | pass | | Current #12580 Windows workflow | pass | | Linux/product and specialized jobs | skipped | ## Findings **Blocking** Please record an agreed dependency/landing order or restack this PR so its relationship to the two open sibling changes is explicit. The merge previews conflict in: - `core/libs/prx/libSceLibreSsl3/src/Key.cpp` - `core/libs/tests/GuestLibreSsl3KeyReference.cpp` - `docs/dev/debt/libSceLibreSsl3.md` **Non-blocking** I found no separate functional blocker in the implementation or focused test. This review is requesting changes for integration clarity only. ## Sources - [#12578](https://github.com/boykopovar/AnyPS5/pull/12578) - [#12580](https://github.com/boykopovar/AnyPS5/pull/12580) - [#12582](https://github.com/boykopovar/AnyPS5/pull/12582) ## Not verified I did not independently rerun the focused C++ tests. Hosted Linux/product checks were skipped. ## To get this to a good state Set the intended order in the PR body/checklist and declare the predecessor dependency, or restack and update the affected diffs so the pairwise merge previews are clean.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!12580
No description provided.