feat(libSceLibreSsl): implement SSL_set_session #23336

Open
Callimann8 wants to merge 2 commits from upstream-pr/23336 into main
Callimann8 commented 2026-11-18 22:00:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Callimann8 on 2026-11-18T22:00:33Z.


What

Implements SSL_set_session in libSceLibreSsl. It threw on every call. Clients call it to hand a session they kept with SSL_get1_session to a new connection for resumption.

This builds on #23139 (SSL_get1_session and the reference-dropping SSL_SESSION_free), whose two commits are included until it merges.

  • SSL_set_session (src/SslSession.cpp) follows LibreSSL 2.5.4 ssl_sess.c:
    • With a session, it asks the context's method, then the connection's, for the method of the session's ssl_version. No method queues SSL_R_UNABLE_TO_FIND_SSL_METHOD (240) and returns 0.
    • It switches the connection to that method as SSL_set_ssl_method does: the same protocol version only swaps the pointer, another creates the new connection state before freeing the old one (a failed allocation returns 0 and leaves the old state and method in place), and a handshake function set to the old connect or accept moves to the new one.
    • It takes a reference on the new session, drops the old one and copies the session's verify_result to the connection.
    • A null session drops the old one and returns the connection to the context's method.
  • get_ssl_method (src/SslMethod.cpp) threw for every method. It now returns the TLS 1.0, 1.1 and 1.2 client or server methods of t1_clnt.c and t1_srvr.c, or the DTLS 1.0 method, and null for any other version. The six TLS methods are not exported. Each has one version, the SSL3_ENC_METHOD flags of its version and the ssl3_renegotiate slots, which throw like the other unimplemented slots.
  • LibreSslSession maps ssl_version (offset 0) and verify_result (offset 136) from the ssl_session_st layout on LP64.
  • SSL_get1_session and SSL_set_session share one checked reference increment.

Setting a session while the connection holds the last reference to its old session still throws through SSL_SESSION_free (#23139). The connection keeps its old session and the new session's count is restored, but the method switch has already happened. A null connection or context throws where LibreSSL dereferences it. Debt fragment docs/dev/debt/changes/feat-libressl-ssl-set-session.md adds the entry and updates the method entry.

Tested

Linux (Ubuntu 24.04), GCC 13, Release. Unit tests only; nothing checked on a console or in a title.

core/libs/tests/GuestLibreSslSslLifecycle.cpp adds TestSetSession on a real TLS_client_method connection:

  • a TLS 1.2 session switches to the TLS 1.2 client method (one version, its get_ssl_method maps back to itself), takes a reference and copies verify_result; setting it again leaves the count alone;
  • after SSL_set_connect_state, a TLS 1.0 session recreates the connection state at version 0x0301, moves the handshake function to the new connect slot and drops the old session's reference;
  • version 0x0300 returns 0, queues reason 240 and changes nothing;
  • a TLS 1.1 session whose state allocation fails returns 0 and leaves the method, connection state, version, handshake function and both counts unchanged;
  • the last-reference cases throw and leave the sessions and counts as they were;
  • a null session drops the reference and returns to the context's method and connect slot;
  • server and DTLS get_ssl_method results.
ctest -R guest_libressl
100% tests passed, 0 tests failed out of 184

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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: #23139
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5384818030 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23336). Originally posted by [Callimann8](https://github.com/Callimann8) on 2026-11-18T22:00:33Z. --- ### What Implements `SSL_set_session` in libSceLibreSsl. It threw on every call. Clients call it to hand a session they kept with `SSL_get1_session` to a new connection for resumption. This builds on #23139 (`SSL_get1_session` and the reference-dropping `SSL_SESSION_free`), whose two commits are included until it merges. - `SSL_set_session` (`src/SslSession.cpp`) follows LibreSSL 2.5.4 [`ssl_sess.c`](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libssl/ssl_sess.c#L715-L757): - With a session, it asks the context's method, then the connection's, for the method of the session's `ssl_version`. No method queues `SSL_R_UNABLE_TO_FIND_SSL_METHOD` (240) and returns 0. - It switches the connection to that method as [`SSL_set_ssl_method`](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libssl/ssl_lib.c#L2269-L2293) does: the same protocol version only swaps the pointer, another creates the new connection state before freeing the old one (a failed allocation returns 0 and leaves the old state and method in place), and a handshake function set to the old connect or accept moves to the new one. - It takes a reference on the new session, drops the old one and copies the session's `verify_result` to the connection. - A null session drops the old one and returns the connection to the context's method. - `get_ssl_method` (`src/SslMethod.cpp`) threw for every method. It now returns the TLS 1.0, 1.1 and 1.2 client or server methods of [`t1_clnt.c`](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libssl/t1_clnt.c#L203-L213) and [`t1_srvr.c`](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libssl/t1_srvr.c#L204-L214), or the DTLS 1.0 method, and null for any other version. The six TLS methods are not exported. Each has one version, the `SSL3_ENC_METHOD` flags of its version and the `ssl3_renegotiate` slots, which throw like the other unimplemented slots. - `LibreSslSession` maps `ssl_version` (offset 0) and `verify_result` (offset 136) from the [`ssl_session_st` layout](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libssl/ssl.h#L435-L478) on LP64. - `SSL_get1_session` and `SSL_set_session` share one checked reference increment. Setting a session while the connection holds the last reference to its old session still throws through `SSL_SESSION_free` (#23139). The connection keeps its old session and the new session's count is restored, but the method switch has already happened. A null connection or context throws where LibreSSL dereferences it. Debt fragment `docs/dev/debt/changes/feat-libressl-ssl-set-session.md` adds the entry and updates the method entry. ### Tested Linux (Ubuntu 24.04), GCC 13, Release. Unit tests only; nothing checked on a console or in a title. `core/libs/tests/GuestLibreSslSslLifecycle.cpp` adds `TestSetSession` on a real `TLS_client_method` connection: - a TLS 1.2 session switches to the TLS 1.2 client method (one version, its `get_ssl_method` maps back to itself), takes a reference and copies `verify_result`; setting it again leaves the count alone; - after `SSL_set_connect_state`, a TLS 1.0 session recreates the connection state at version 0x0301, moves the handshake function to the new connect slot and drops the old session's reference; - version 0x0300 returns 0, queues reason 240 and changes nothing; - a TLS 1.1 session whose state allocation fails returns 0 and leaves the method, connection state, version, handshake function and both counts unchanged; - the last-reference cases throw and leave the sessions and counts as they were; - a null session drops the reference and returns to the context's method and connect slot; - server and DTLS `get_ssl_method` results. ``` ctest -R guest_libressl 100% tests passed, 0 tests failed out of 184 ``` ### 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) and the licence notice of code adapted from upstream (see AGENTS.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: #23139 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-18 22:03:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-18T22:03:47Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 03ec1a0ad7:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libressl_ssl_lifecycle_tests, guest_libressl_ssl_session_tests built cleanly.
  • CTest (guest_libressl_ssl_session, guest_libressl_ssl_lifecycle):
    1/2 Test #4366: guest_libressl_ssl_session .......   Passed    0.01 sec
    2/2 Test #4388: guest_libressl_ssl_lifecycle .....   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 2
    
  • Negative control: with core/libs/prx/libSceLibreSsl/Export.cpp, core/libs/prx/libSceLibreSsl/include/Api.hpp, core/libs/prx/libSceLibreSsl/include/SslInternal.hpp, core/libs/prx/libSceLibreSsl/src/SslMethod.cpp, core/libs/prx/libSceLibreSsl/src/SslSession.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified SSL_set_session implementation against LibreSSL 2.5.4 ssl_sess.c and ssl_lib.c, ensuring correct method lookup via ctx->method and ssl->method, and error queueing with ReasonUnableToFindSslMethod (240).
    • Audited reference counting in Retain, SSL_SESSION_free_nid_postfix, and SSL_set_session_nid_postfix for overflow protection, underflow checks, atomic memory orderings, and rollback on failure.
    • Confirmed SetMethod correctly checks ssl->internal nullness, preserves/updates ssl->internal->handshakeFunc across protocol version transitions, and reconstructs SSL state via sslFree/sslNew.
    • Checked struct layout alignment and offsets (verifyResult at 136, references at 160) across 64-bit architectures, matching LibreSSL ssl_session_st.
    • Verified full compliance with AGENTS.md conventions, technical debt tracking fragments, Conventional Commits, and test coverage for new functions.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5965904640 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23336#pullrequestreview-5965904640). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-18T22:03:47Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `03ec1a0ad7`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_libressl_ssl_lifecycle_tests`, `guest_libressl_ssl_session_tests` built cleanly. - **CTest** (`guest_libressl_ssl_session`, `guest_libressl_ssl_lifecycle`): ``` 1/2 Test #4366: guest_libressl_ssl_session ....... Passed 0.01 sec 2/2 Test #4388: guest_libressl_ssl_lifecycle ..... Passed 0.01 sec 100% tests passed, 0 tests failed out of 2 ``` - **Negative control**: with `core/libs/prx/libSceLibreSsl/Export.cpp`, `core/libs/prx/libSceLibreSsl/include/Api.hpp`, `core/libs/prx/libSceLibreSsl/include/SslInternal.hpp`, `core/libs/prx/libSceLibreSsl/src/SslMethod.cpp`, `core/libs/prx/libSceLibreSsl/src/SslSession.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified SSL_set_session implementation against LibreSSL 2.5.4 ssl_sess.c and ssl_lib.c, ensuring correct method lookup via ctx->method and ssl->method, and error queueing with ReasonUnableToFindSslMethod (240). - Audited reference counting in Retain, SSL_SESSION_free_nid_postfix, and SSL_set_session_nid_postfix for overflow protection, underflow checks, atomic memory orderings, and rollback on failure. - Confirmed SetMethod correctly checks ssl->internal nullness, preserves/updates ssl->internal->handshakeFunc across protocol version transitions, and reconstructs SSL state via sslFree/sslNew. - Checked struct layout alignment and offsets (verifyResult at 136, references at 160) across 64-bit architectures, matching LibreSSL ssl_session_st. - Verified full compliance with AGENTS.md conventions, technical debt tracking fragments, Conventional Commits, and test coverage for new functions. Looks Good To Me
MarcZX10 commented 2026-11-18 23:55:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T23:55:18Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: make TLS state recreation failure-safe so a failed allocation does not leave the connection switched to a method with no state.

What I ran

Reviewed head 03ec1a0ad777cb53f7f7b18e2a2106775f4fbbb6 and the prepared patch. No commands or tests were run; repo_read.py was unavailable as an executable tool, so I read the changed source at the pinned head directly.

Files read: SslSession.cpp, SslMethod.cpp, Api.hpp, and the prepared diff.patch, description.md, commits.md, and manifest.json. All eight files marked reviewed in manifest.json were included in the prepared material, but I did not read all eight full texts.

Results

Check Result Note
Diff and manifest review passed Prepared review materials
Targeted source inspection passed Session and TLS method implementation
Tests not run Author reports 184 passing tests
Full reviewed-file coverage not run Not all listed files read

Findings

Blocking

  • core/libs/prx/libSceLibreSsl/src/SslSession.cpp:111: SetMethod can return false after sslFree has released the current TLS state and sslNew fails; it has already assigned the new method. SSL_set_session then returns immediately without restoring the prior method or state, leaving the connection with no state and potentially leaking its prior session reference. Keep method/state consistent on allocation failure before returning.

Non-blocking

None.

Not verified

The contents of Export.cpp, both changed test files, and both debt fragments were not independently read at head. The author-reported test run was not reproduced. Console/title behavior was not checked.

To get this to a good state

Make method switching preserve a valid connection on state allocation failure, then rerun the lifecycle tests and review the affected change.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5967134941 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23336#pullrequestreview-5967134941). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-18T23:55:18Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: make TLS state recreation failure-safe so a failed allocation does not leave the connection switched to a method with no state. ## What I ran Reviewed head `03ec1a0ad777cb53f7f7b18e2a2106775f4fbbb6` and the prepared patch. No commands or tests were run; `repo_read.py` was unavailable as an executable tool, so I read the changed source at the pinned head directly. Files read: `SslSession.cpp`, `SslMethod.cpp`, `Api.hpp`, and the prepared `diff.patch`, `description.md`, `commits.md`, and `manifest.json`. All eight files marked `reviewed` in `manifest.json` were included in the prepared material, but I did not read all eight full texts. ## Results | Check | Result | Note | |---|---|---| | Diff and manifest review | passed | Prepared review materials | | Targeted source inspection | passed | Session and TLS method implementation | | Tests | not run | Author reports 184 passing tests | | Full reviewed-file coverage | not run | Not all listed files read | ## Findings ### Blocking - `core/libs/prx/libSceLibreSsl/src/SslSession.cpp:111`: `SetMethod` can return `false` after `sslFree` has released the current TLS state and `sslNew` fails; it has already assigned the new method. `SSL_set_session` then returns immediately without restoring the prior method or state, leaving the connection with no state and potentially leaking its prior session reference. Keep method/state consistent on allocation failure before returning. ### Non-blocking None. ## Not verified The contents of `Export.cpp`, both changed test files, and both debt fragments were not independently read at head. The author-reported test run was not reproduced. Console/title behavior was not checked. ## To get this to a good state Make method switching preserve a valid connection on state allocation failure, then rerun the lifecycle tests and review the affected change.
PrivacyOnion commented 2026-11-19 00:42:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-19T00:42:57Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 22538e3974:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libressl_ssl_lifecycle_tests, guest_libressl_ssl_session_tests built cleanly.
  • CTest (guest_libressl_ssl_session, guest_libressl_ssl_lifecycle):
    1/2 Test #4371: guest_libressl_ssl_session .......   Passed    0.01 sec
    2/2 Test #4393: guest_libressl_ssl_lifecycle .....   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 2
    
  • Negative control: with core/libs/prx/libSceLibreSsl/Export.cpp, core/libs/prx/libSceLibreSsl/include/Api.hpp, core/libs/prx/libSceLibreSsl/include/SslInternal.hpp, core/libs/prx/libSceLibreSsl/src/SslMethod.cpp, core/libs/prx/libSceLibreSsl/src/SslSession.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Audited SSL_set_session in SslSession.cpp:103-133: verified null checks for ssl and ctx, method resolution logic via ctx->method and ssl->method, and queuing of ReasonUnableToFindSslMethod (240).
    • Audited SetMethod state recreation and atomic reference count handling in SslSession.cpp:38-69 and 119-129: verified strong exception safety, rollback on allocation failure, and safe reference rollback on throw.
    • Audited method resolution tables in SslMethod.cpp:528-625: verified TLS 1.0, 1.1, 1.2 client/server dispatch, DTLS version matching, and unsupported version handling.
    • Checked struct alignments and layout offsets against 64-bit LibreSSL 2.5.4 in Api.hpp and SslSession.cpp (verifyResult at 136, references at 160, cipher at 168).
    • Verified compliance with AGENTS.md rules, technical debt tracking fragments in docs/dev/debt/changes/, and absence of code comments outside permitted headers.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5967545293 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23336#pullrequestreview-5967545293). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-19T00:42:57Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `22538e3974`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_libressl_ssl_lifecycle_tests`, `guest_libressl_ssl_session_tests` built cleanly. - **CTest** (`guest_libressl_ssl_session`, `guest_libressl_ssl_lifecycle`): ``` 1/2 Test #4371: guest_libressl_ssl_session ....... Passed 0.01 sec 2/2 Test #4393: guest_libressl_ssl_lifecycle ..... Passed 0.01 sec 100% tests passed, 0 tests failed out of 2 ``` - **Negative control**: with `core/libs/prx/libSceLibreSsl/Export.cpp`, `core/libs/prx/libSceLibreSsl/include/Api.hpp`, `core/libs/prx/libSceLibreSsl/include/SslInternal.hpp`, `core/libs/prx/libSceLibreSsl/src/SslMethod.cpp`, `core/libs/prx/libSceLibreSsl/src/SslSession.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Audited SSL_set_session in SslSession.cpp:103-133: verified null checks for ssl and ctx, method resolution logic via ctx->method and ssl->method, and queuing of ReasonUnableToFindSslMethod (240). - Audited SetMethod state recreation and atomic reference count handling in SslSession.cpp:38-69 and 119-129: verified strong exception safety, rollback on allocation failure, and safe reference rollback on throw. - Audited method resolution tables in SslMethod.cpp:528-625: verified TLS 1.0, 1.1, 1.2 client/server dispatch, DTLS version matching, and unsupported version handling. - Checked struct alignments and layout offsets against 64-bit LibreSSL 2.5.4 in Api.hpp and SslSession.cpp (verifyResult at 136, references at 160, cipher at 168). - Verified compliance with AGENTS.md rules, technical debt tracking fragments in docs/dev/debt/changes/, and absence of code comments outside permitted headers. Looks Good To Me
MarcZX10 commented 2026-11-19 02:00:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T02:00:57Z.

Review: COMMENTED


Reviewed — comments

Changes are required before merge: none; the implementation appears consistent with its documented behavior, but I could not verify the complete set of changed files or run the reported checks.

What I ran

  • Reviewed head 22538e39740b00d27c31c00d4c4afbf47868865e using the prepared review artifacts and repo_read.py reader tools.
  • No tests or build commands were run.

Results

Check Result Note
Diff review passed Main implementation and tests inspected
Unit tests not run Reported by author only
Complete file review not run All changed files were not read

Findings

Blocking

None verified.

Non-blocking

None.

Not verified

  • review/files.json was unavailable through the reader, so I could not establish which changes were excluded or confirm that every file classified as reviewed was read. I inspected the prepared diff, plus the relevant sections of SslSession.cpp, SslMethod.cpp, Api.hpp, and Export.cpp.
  • I did not read the complete changed files SslInternal.hpp, GuestLibreSslSslLifecycle.cpp, GuestLibreSslSslSession.cpp, or either debt fragment.
  • The author reports Linux unit tests passed; I did not run them. Console and title behavior were not verified.

To get this to a good state

Nothing is required. Optional: provide the review file manifest and run the reported unit test command on this head to support a complete review.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5968220527 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23336#pullrequestreview-5968220527). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-19T02:00:57Z. **Review:** COMMENTED --- # Reviewed — comments Changes are required before merge: none; the implementation appears consistent with its documented behavior, but I could not verify the complete set of changed files or run the reported checks. ## What I ran - Reviewed head `22538e39740b00d27c31c00d4c4afbf47868865e` using the prepared review artifacts and `repo_read.py` reader tools. - No tests or build commands were run. ## Results | Check | Result | Note | |---|---|---| | Diff review | passed | Main implementation and tests inspected | | Unit tests | not run | Reported by author only | | Complete file review | not run | All changed files were not read | ## Findings ### Blocking None verified. ### Non-blocking None. ## Not verified - `review/files.json` was unavailable through the reader, so I could not establish which changes were excluded or confirm that every file classified as reviewed was read. I inspected the prepared diff, plus the relevant sections of `SslSession.cpp`, `SslMethod.cpp`, `Api.hpp`, and `Export.cpp`. - I did not read the complete changed files `SslInternal.hpp`, `GuestLibreSslSslLifecycle.cpp`, `GuestLibreSslSslSession.cpp`, or either debt fragment. - The author reports Linux unit tests passed; I did not run them. Console and title behavior were not verified. ## To get this to a good state Nothing is required. Optional: provide the review file manifest and run the reported unit test command on this head to support a complete review.
MarcZX10 commented 2026-11-21 12:11:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T12:11:02Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: method switching can leave connection state invalid when allocation or old-state cleanup fails.

What I ran

  • Reviewed head 6a9e89c7f1b172d82db1d57da142f5a46aa10057; base main was not merged for a preview.
  • Read the prepared diff and all six changed source, test, and debt files listed in the manifest. No tests were run; the test result in the description is author-reported.
  • Targeted source reads used repo_read.py to inspect session handling, method switching, TLS state allocation, and the relevant layouts.

Results

Check Result Note
Diff and changed files passed All six manifest files read
Unit tests not run Reported by author only
Console behavior not run Not tested on hardware

Findings

Blocking

  • core/libs/prx/libSceLibreSsl/src/SslSession.cpp:61: After next.sslNew succeeds, SetMethod swaps in the new state and calls current.sslFree(&ssl) while ssl.method is temporarily restored to the old method. If freeing the old state throws, the function exits before restoring ssl.method to method, and the connection has already lost its old state. The caller then propagates the exception, leaving the connection with the new state but the old method pointer. Make the transition exception-safe so all exits preserve a consistent method/state pair.

Non-blocking

  • None.

Not verified

  • No tests were run in this review; the Ubuntu/GCC/Release result and ctest -R guest_libressl output are from the PR description.
  • Console behavior, firmware compatibility, and behavior in titles were not verified.
  • No files were excluded by the manifest; files.json was not available through the reader.

To get this to a good state

Make the method/state switch preserve a consistent connection if freeing the previous state fails, then rerun the lifecycle tests on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6005091733 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23336#pullrequestreview-6005091733). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T12:11:02Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: method switching can leave connection state invalid when allocation or old-state cleanup fails. ## What I ran - Reviewed head `6a9e89c7f1b172d82db1d57da142f5a46aa10057`; base `main` was not merged for a preview. - Read the prepared diff and all six changed source, test, and debt files listed in the manifest. No tests were run; the test result in the description is author-reported. - Targeted source reads used `repo_read.py` to inspect session handling, method switching, TLS state allocation, and the relevant layouts. ## Results | Check | Result | Note | |---|---|---| | Diff and changed files | passed | All six manifest files read | | Unit tests | not run | Reported by author only | | Console behavior | not run | Not tested on hardware | ## Findings ### Blocking - `core/libs/prx/libSceLibreSsl/src/SslSession.cpp:61`: After `next.sslNew` succeeds, `SetMethod` swaps in the new state and calls `current.sslFree(&ssl)` while `ssl.method` is temporarily restored to the old method. If freeing the old state throws, the function exits before restoring `ssl.method` to `method`, and the connection has already lost its old state. The caller then propagates the exception, leaving the connection with the new state but the old method pointer. Make the transition exception-safe so all exits preserve a consistent method/state pair. ### Non-blocking - None. ## Not verified - No tests were run in this review; the Ubuntu/GCC/Release result and `ctest -R guest_libressl` output are from the PR description. - Console behavior, firmware compatibility, and behavior in titles were not verified. - No files were excluded by the manifest; `files.json` was not available through the reader. ## To get this to a good state Make the method/state switch preserve a consistent connection if freeing the previous state fails, then rerun the lifecycle tests on the updated head.
ligmaSec commented 2026-12-03 12:52:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T12:52:24Z.

Review: COMMENTED


Built the branch’s changed sources and ran GuestLibreSslSslLifecycle and GuestLibreSslSslSession on Linux against the existing runtime libraries. The test run passed and covered SSL session assignment and the existing lifecycle cases.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6170171936 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23336#pullrequestreview-6170171936). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T12:52:24Z. **Review:** COMMENTED --- Built the branch’s changed sources and ran GuestLibreSslSslLifecycle and GuestLibreSslSslSession on Linux against the existing runtime libraries. The test run passed and covered SSL session assignment and the existing lifecycle cases. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/23336:upstream-pr/23336'
git switch 'upstream-pr/23336'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/23336'
git switch 'upstream-pr/23336'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/23336'
git switch 'upstream-pr/23336'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/23336'
git switch 'main'
git merge --squash 'upstream-pr/23336'
git switch 'main'
git merge --ff-only 'upstream-pr/23336'
git switch 'main'
git merge 'upstream-pr/23336'
git push origin 'main'
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!23336
No description provided.