feat(libressl3): retain SSL_CTX references #12578

Closed
PrivacyOnion wants to merge 1 commit from upstream-pr/12578 into main
PrivacyOnion commented 2026-10-28 21:19:32 +00:00 (Migrated from github.com)

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


What

Implement SSL_CTX_up_ref in libSceLibreSsl3 by atomically incrementing the reference counter at offset 40 of LibreSsl3SslCtx, following the LP64 struct ssl_ctx_st layout in LibreSSL 4.0.0 (ssl_lib.c#L2244-L2248). Null pointers and counter overflow throw std::invalid_argument and std::overflow_error without mutation.

Tested

Windows 11, verified sequential and concurrent retain semantics, boundary return values and layout integrity with guest_libressl3_key_reference.

Ran locally on 00b24c75b4:

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

100% tests passed, 0 tests failed out of 1

Total Test time (real) =   0.14 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: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5057867449 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12578). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-10-28T21:19:32Z. --- ### What Implement `SSL_CTX_up_ref` in `libSceLibreSsl3` by atomically incrementing the reference counter at offset 40 of `LibreSsl3SslCtx`, following the LP64 `struct ssl_ctx_st` layout in LibreSSL 4.0.0 ([ssl_lib.c#L2244-L2248](https://github.com/libressl/openbsd/blob/bc9483725c5815efb64b6d9acc52fc5fba139212/src/lib/libssl/ssl_lib.c#L2244-L2248)). Null pointers and counter overflow throw `std::invalid_argument` and `std::overflow_error` without mutation. ### 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 sequential and concurrent retain semantics, boundary return values and layout integrity with `guest_libressl3_key_reference`. Ran locally on `00b24c75b4`: ``` $ ctest --test-dir build -R '^guest_libressl3_key_reference$' --output-on-failure Start 2034: guest_libressl3_key_reference 1/1 Test #2034: guest_libressl3_key_reference .... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 Total Test time (real) = 0.14 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: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-28 21:29:37 +00:00 (Migrated from github.com)

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

Review: COMMENTED


A coordination note for this PR's landing order: I checked the exact current heads, and merge previews with #12580 and #12582 conflict in Key.cpp, GuestLibreSsl3KeyReference.cpp, and docs/dev/debt/libSceLibreSsl3.md. If this PR is intended to land first, please coordinate with the same author so the later PRs declare their dependencies and are restacked. I have not found a functional blocker in this diff; its Windows check is still running.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5689941378 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12578#pullrequestreview-5689941378). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-28T21:29:37Z. **Review:** COMMENTED --- A coordination note for this PR's landing order: I checked the exact current heads, and merge previews with #12580 and #12582 conflict in `Key.cpp`, `GuestLibreSsl3KeyReference.cpp`, and `docs/dev/debt/libSceLibreSsl3.md`. If this PR is intended to land first, please coordinate with the same author so the later PRs declare their dependencies and are restacked. I have not found a functional blocker in this diff; its Windows check is still running.
MarcZX10 commented 2026-10-28 21:35:54 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Review note — coordinate the landing order

I found no functional issue in this PR’s focused change. The merge previews show a sequencing issue across the three open LibreSSL reference-count PRs: each pair conflicts in shared source, regression-test, and debt files. The PR currently declares no dependencies, so the intended application order is unclear.

What I ran

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

Results

Check Result
#12578 + #12580 merge preview conflict in Key.cpp, GuestLibreSsl3KeyReference.cpp, and libSceLibreSsl3.md
#12578 + #12582 merge preview conflict in the same three files
#12580 + #12582 merge preview conflict in the same three files
#12578 checks conventions, intake, labels, report, and Windows pass; Linux/product jobs skipped

Findings

Blocking

None in the change reviewed here. The pairwise conflicts require a recorded landing order before the stack can be applied without resolving shared hunks.

Non-blocking

This PR can be first if that is the agreed order. Please record the intended successor dependencies in the PR checklists or restack the later changes on top of this one after it lands. The conflicting files are:

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

Sources

Not verified

I did not independently rerun the focused tests. Hosted Linux/product checks were skipped; Windows and policy checks passed.

To get this to a good state

Confirm that #12578 is intended to land first and record the dependencies on #12580 and #12582, or propose another explicit order and restack the conflicting PRs accordingly.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5690006639 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12578#pullrequestreview-5690006639). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-28T21:35:54Z. **Review:** COMMENTED --- # Review note — coordinate the landing order I found no functional issue in this PR’s focused change. The merge previews show a sequencing issue across the three open LibreSSL reference-count PRs: each pair conflicts in shared source, regression-test, and debt files. The PR currently declares no dependencies, so the intended application order is unclear. ## What I ran - Compared current PR heads #12578 `00b24c75b4be4b3ee7ed97013e4ea4a7a21b3afe`, #12580 `e5f35a2407c01477085fc0d9aa78ddbba669fda7`, and #12582 `dd47c78d6d72d3d88b2d21ccac72ffd8adb193c3`. - Generated pairwise merge previews against current `main` `319621ba2e578bd053b0baba2877fe70520e0737`. - Refreshed the hosted checks. ## Results | Check | Result | |---|---| | #12578 + #12580 merge preview | conflict in `Key.cpp`, `GuestLibreSsl3KeyReference.cpp`, and `libSceLibreSsl3.md` | | #12578 + #12582 merge preview | conflict in the same three files | | #12580 + #12582 merge preview | conflict in the same three files | | #12578 checks | conventions, intake, labels, report, and Windows pass; Linux/product jobs skipped | ## Findings **Blocking** None in the change reviewed here. The pairwise conflicts require a recorded landing order before the stack can be applied without resolving shared hunks. **Non-blocking** This PR can be first if that is the agreed order. Please record the intended successor dependencies in the PR checklists or restack the later changes on top of this one after it lands. The conflicting files are: - `core/libs/prx/libSceLibreSsl3/src/Key.cpp` - `core/libs/tests/GuestLibreSsl3KeyReference.cpp` - `docs/dev/debt/libSceLibreSsl3.md` ## Sources - [PR #12578](https://github.com/boykopovar/AnyPS5/pull/12578) - [PR #12580](https://github.com/boykopovar/AnyPS5/pull/12580) - [PR #12582](https://github.com/boykopovar/AnyPS5/pull/12582) ## Not verified I did not independently rerun the focused tests. Hosted Linux/product checks were skipped; Windows and policy checks passed. ## To get this to a good state Confirm that #12578 is intended to land first and record the dependencies on #12580 and #12582, or propose another explicit order and restack the conflicting PRs accordingly.

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!12578
No description provided.