feat(libSceLibreSsl): implement SSL_set_bio #23078

Merged
Callimann8 merged 2 commits from upstream-pr/23078 into main 2026-11-30 07:59:17 +00:00
Callimann8 commented 2026-11-18 17:40:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Callimann8 on 2026-11-18T17:40:11Z.


What

Implements SSL_set_bio in libSceLibreSsl (libSceLibreSsl3 reaches it through its parent forward rXHi08e0g80). The export was a NotImplemented stub.

  • SSL_set_bio(SSL*, BIO* rbio, BIO* wbio) sits next to SSL_set_fd in src/SslLifecycle.cpp and calls the existing SetBio helper, which is the body of LibreSSL 2.5.4's SSL_set_bio. It detaches a write buffering BIO, frees the old read chain when the read BIO changes and is not also the write BIO, and frees the old write chain when the write BIO changes.
  • Api.hpp declares the export with its real signature instead of (void).
  • A null connection throws where LibreSSL faults, like SSL_set_fd.
  • Debt fragment docs/dev/debt/changes/feat-libressl-ssl-set-bio.md. Nothing is checked on a console; the 2.5.4 behaviour is kept, so replacing only the write side of a connection whose read and write BIO are the same frees a BIO that stays installed as the read side.

Tested

Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release), homebrew test only, no title. TestSetBio in core/libs/tests/GuestLibreSslSslLifecycle.cpp uses the test's guest-heap tracker to check which BIOs are freed when the pair is set again to the same pair, to a new read and write pair, to a new read BIO with the same write BIO, to a single BIO, to null, and before SSL_set_fd; the live.empty() check catches leaks and double frees.

ctest -R guest_libressl_ssl_lifecycle
100% tests passed, 0 tests failed out of 1

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: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

Summary by CodeRabbit

  • New Features
    • SSL connections can now assign, replace, or clear their read and write BIOs. Replacing BIOs or changing the connection’s file descriptor handles associated BIO cleanup.
    • Passing a null SSL connection to this operation now raises an error.
  • Documentation
    • Added documentation describing BIO assignment, replacement, and cleanup behavior.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5381040900 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23078). Originally posted by [Callimann8](https://github.com/Callimann8) on 2026-11-18T17:40:11Z. --- ### What Implements `SSL_set_bio` in libSceLibreSsl (libSceLibreSsl3 reaches it through its parent forward `rXHi08e0g80`). The export was a `NotImplemented` stub. - `SSL_set_bio(SSL*, BIO* rbio, BIO* wbio)` sits next to `SSL_set_fd` in `src/SslLifecycle.cpp` and calls the existing `SetBio` helper, which is the body of LibreSSL 2.5.4's [`SSL_set_bio`](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libssl/ssl_lib.c#L562-L579). It detaches a write buffering BIO, frees the old read chain when the read BIO changes and is not also the write BIO, and frees the old write chain when the write BIO changes. - `Api.hpp` declares the export with its real signature instead of `(void)`. - A null connection throws where LibreSSL faults, like `SSL_set_fd`. - Debt fragment `docs/dev/debt/changes/feat-libressl-ssl-set-bio.md`. Nothing is checked on a console; the 2.5.4 behaviour is kept, so replacing only the write side of a connection whose read and write BIO are the same frees a BIO that stays installed as the read side. ### Tested Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release), homebrew test only, no title. `TestSetBio` in `core/libs/tests/GuestLibreSslSslLifecycle.cpp` uses the test's guest-heap tracker to check which BIOs are freed when the pair is set again to the same pair, to a new read and write pair, to a new read BIO with the same write BIO, to a single BIO, to null, and before `SSL_set_fd`; the `live.empty()` check catches leaks and double frees. ``` ctest -R guest_libressl_ssl_lifecycle 100% tests passed, 0 tests failed out of 1 ``` ### Checklist - [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: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * SSL connections can now assign, replace, or clear their read and write BIOs. Replacing BIOs or changing the connection’s file descriptor handles associated BIO cleanup. * Passing a null SSL connection to this operation now raises an error. * **Documentation** * Added documentation describing BIO assignment, replacement, and cleanup behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
PrivacyOnion commented 2026-11-18 17:44:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-18T17:44:36Z.

Review: CHANGES_REQUESTED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 02e0ae61d1:

  • Conventions: tools/check_conventions.py failed.
    (pull request): error: [pr-template] Fill in the pull request template: add the '### What' heading of the template
    (pull request): error: [pr-template] Fill in the pull request template: add the '### Tested' heading of the template
    (pull request): error: [pr-template] Fill in the pull request template: add the '### Checklist' heading of the template
    3 findings, 3 errors; GitHub shows at most 10 error annotations, the job summary lists all
    
  • Build: guest_libressl_ssl_lifecycle_tests built cleanly.
  • CTest (guest_libressl_ssl_lifecycle):
    1/1 Test #4375: guest_libressl_ssl_lifecycle .....   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    

Requesting changes for the points above.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5962030996 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23078#pullrequestreview-5962030996). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-18T17:44:36Z. **Review:** CHANGES_REQUESTED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `02e0ae61d1`: - **Conventions**: `tools/check_conventions.py` failed. ``` (pull request): error: [pr-template] Fill in the pull request template: add the '### What' heading of the template (pull request): error: [pr-template] Fill in the pull request template: add the '### Tested' heading of the template (pull request): error: [pr-template] Fill in the pull request template: add the '### Checklist' heading of the template 3 findings, 3 errors; GitHub shows at most 10 error annotations, the job summary lists all ``` - **Build**: `guest_libressl_ssl_lifecycle_tests` built cleanly. - **CTest** (`guest_libressl_ssl_lifecycle`): ``` 1/1 Test #4375: guest_libressl_ssl_lifecycle ..... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` Requesting changes for the points above.
PrivacyOnion commented 2026-11-18 18:00:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-18T18:00:42Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 02e0ae61d1:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libressl_ssl_lifecycle_tests built cleanly.
  • CTest (guest_libressl_ssl_lifecycle):
    1/1 Test #4375: guest_libressl_ssl_lifecycle .....   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceLibreSsl/Export.cpp, core/libs/prx/libSceLibreSsl/include/Api.hpp, core/libs/prx/libSceLibreSsl/src/SslLifecycle.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Checked SSL_set_bio signature against LibreSSL / OpenSSL C API: void SSL_set_bio(SSL *s, BIO *rbio, BIO *wbio) matches Api.hpp declaration and SslLifecycle.cpp definition.
    • Checked null ssl pointer handling: properly throws std::invalid_argument where LibreSSL/OpenSSL dereference and crash, consistent with SSL_set_fd in SslLifecycle.cpp.
    • Verified SetBio logic against LibreSSL 2.5.4 ssl_lib.c: safely detaches bbio, handles reference lifetimes of rbio and wbio chains via BIO_free_all, and handles identical/distinct bio replacement semantics.
    • Verified debt fragment docs/dev/debt/changes/feat-libressl-ssl-set-bio.md follows format and properly records functional behavior.
    • Audited GuestLibreSslSslLifecycle.cpp TestSetBio unit test: verifies null check exception, identical bio replacement, separate rbio/wbio update, partial update, clear to null, and interaction with SSL_set_fd.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5962269062 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23078#pullrequestreview-5962269062). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-18T18:00:42Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `02e0ae61d1`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_libressl_ssl_lifecycle_tests` built cleanly. - **CTest** (`guest_libressl_ssl_lifecycle`): ``` 1/1 Test #4375: guest_libressl_ssl_lifecycle ..... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceLibreSsl/Export.cpp`, `core/libs/prx/libSceLibreSsl/include/Api.hpp`, `core/libs/prx/libSceLibreSsl/src/SslLifecycle.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Checked SSL_set_bio signature against LibreSSL / OpenSSL C API: void SSL_set_bio(SSL *s, BIO *rbio, BIO *wbio) matches Api.hpp declaration and SslLifecycle.cpp definition. - Checked null ssl pointer handling: properly throws std::invalid_argument where LibreSSL/OpenSSL dereference and crash, consistent with SSL_set_fd in SslLifecycle.cpp. - Verified SetBio logic against LibreSSL 2.5.4 ssl_lib.c: safely detaches bbio, handles reference lifetimes of rbio and wbio chains via BIO_free_all, and handles identical/distinct bio replacement semantics. - Verified debt fragment docs/dev/debt/changes/feat-libressl-ssl-set-bio.md follows format and properly records functional behavior. - Audited GuestLibreSslSslLifecycle.cpp TestSetBio unit test: verifies null check exception, identical bio replacement, separate rbio/wbio update, partial update, clear to null, and interaction with SSL_set_fd. Looks Good To Me
MarcZX10 commented 2026-11-23 03:30:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T03:30:20Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the inspected implementation follows the existing BIO ownership helper, and the reviewed files support merging.

What I ran

Reviewed head 02e0ae61d11b967ef3cf19276b5fc4260394adae. No build or tests were run. I read core/libs/prx/libSceLibreSsl/Export.cpp, core/libs/prx/libSceLibreSsl/include/Api.hpp, core/libs/prx/libSceLibreSsl/src/SslLifecycle.cpp, core/libs/tests/GuestLibreSslSslLifecycle.cpp, and docs/dev/debt/changes/feat-libressl-ssl-set-bio.md. All five changed files are marked included in the manifest; no exclusions were reported there. The full source for SslLifecycle.cpp and SslBio.cpp was read only in targeted ranges.

Results

Check Result Note
Ownership logic passed Uses existing SetBio helper
Lifecycle coverage passed Tests replacement and cleanup cases
Build and test execution not run Description reports an author run
Console behavior not run Description says no console check

Findings

Blocking

None.

Non-blocking

None.

Not verified

I did not run the reported guest_libressl_ssl_lifecycle test or a build, and did not verify console behavior. The reported test result is from the PR description, not a run performed during this review. The manifest lists five changed files, all included; the targeted repository reads covered the changed implementation and test code, while SslBio.cpp was inspected to confirm the existing chain-freeing behavior.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6016247930 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23078#pullrequestreview-6016247930). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-23T03:30:20Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the inspected implementation follows the existing BIO ownership helper, and the reviewed files support merging. ## What I ran Reviewed head `02e0ae61d11b967ef3cf19276b5fc4260394adae`. No build or tests were run. I read `core/libs/prx/libSceLibreSsl/Export.cpp`, `core/libs/prx/libSceLibreSsl/include/Api.hpp`, `core/libs/prx/libSceLibreSsl/src/SslLifecycle.cpp`, `core/libs/tests/GuestLibreSslSslLifecycle.cpp`, and `docs/dev/debt/changes/feat-libressl-ssl-set-bio.md`. All five changed files are marked included in the manifest; no exclusions were reported there. The full source for `SslLifecycle.cpp` and `SslBio.cpp` was read only in targeted ranges. ## Results | Check | Result | Note | |---|---|---| | Ownership logic | passed | Uses existing `SetBio` helper | | Lifecycle coverage | passed | Tests replacement and cleanup cases | | Build and test execution | not run | Description reports an author run | | Console behavior | not run | Description says no console check | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified I did not run the reported `guest_libressl_ssl_lifecycle` test or a build, and did not verify console behavior. The reported test result is from the PR description, not a run performed during this review. The manifest lists five changed files, all included; the targeted repository reads covered the changed implementation and test code, while `SslBio.cpp` was inspected to confirm the existing chain-freeing behavior. ## To get this to a good state Nothing is required.
coderabbitai[bot] commented 2026-11-30 06:40:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T06:40:09Z.

Review: COMMENTED


Architecture findings (1)

Advisory architecture findings (1)

  • Minor — The newly active guest export exposes an ownership transition that can release the last reference to a BIO still present in the resulting SSL connection. Later access or teardown can operate on freed memory. The helper predates the PR, but the former stub did not expose this reassignment path.
Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 81a792ba-30d5-4059-a227-a0007213cf4f
Commits

Reviewing files that changed from the base of the PR and between 63ee1c120a and 8a8ab0af89.

Files selected for processing: 5

  • core/libs/prx/libSceLibreSsl/Export.cpp
  • core/libs/prx/libSceLibreSsl/include/Api.hpp
  • core/libs/prx/libSceLibreSsl/src/SslLifecycle.cpp
  • core/libs/tests/GuestLibreSslSslLifecycle.cpp
  • docs/dev/debt/changes/feat-libressl-ssl-set-bio.md
Files with no reviewable changes: 1

  • core/libs/prx/libSceLibreSsl/Export.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6107857151 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23078#pullrequestreview-6107857151). Originally posted by [coderabbitai[bot]](https://github.com/apps/coderabbitai) on 2026-11-30T06:40:09Z. **Review:** COMMENTED --- <!-- coderabbit-ai-generated:v1 --> **Architecture findings (1)** <details> <summary>Advisory architecture findings (1)</summary> <dl> <dd> <br> - **Minor** — The newly active guest export exposes an ownership transition that can release the last reference to a BIO still present in the resulting SSL connection. Later access or teardown can operate on freed memory. The helper predates the PR, but the former stub did not expose this reassignment path. </dd> </dl> </details> <h6> <details> <summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Review info</summary> <dl> <dd> <br> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</summary> <dl> <dd> <br> - **Source mode**: Auto - **Repository**: Unavailable - **Branch**: Unavailable - **File**: No configuration file from this repository applied - **Commit**: Unavailable - **Layers**: defaults - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `81a792ba-30d5-4059-a227-a0007213cf4f` </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</summary> <dl> <dd> <br> Reviewing files that changed from the base of the PR and between 63ee1c120a7296ba590451afcaa252454d7f7a6a and 8a8ab0af89cb20e1426c87fcda8c6850fe165686. </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 5</summary> <dl> <dd> <br> * `core/libs/prx/libSceLibreSsl/Export.cpp` * `core/libs/prx/libSceLibreSsl/include/Api.hpp` * `core/libs/prx/libSceLibreSsl/src/SslLifecycle.cpp` * `core/libs/tests/GuestLibreSslSslLifecycle.cpp` * `docs/dev/debt/changes/feat-libressl-ssl-set-bio.md` </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-no-changes-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-no-changes.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files with no reviewable changes: 1</summary> <dl> <dd> <br> * core/libs/prx/libSceLibreSsl/Export.cpp </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. </dd> </dl> </details> </h6> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=2d01c6d6-e9a4-47d2-88a5-989401c93cd2 attempt=19db21cb-24cc-4226-8d4a-9515b2aed4ff batch=1/1 -->
MarcZX10 commented 2026-11-30 06:52:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T06:52:56Z.

Review: APPROVED


Reviewed — looks good

Nothing in the reviewed code blocks merging; the added implementation and lifecycle tests support the documented behavior.

What I ran

Reviewed head 8a8ab0af89cb20e1426c87fcda8c6850fe165686. I inspected the prepared diff and the full text of every changed file. I did not run the author-reported test command.

Results

Check Result Note
Diff and changed code passed All five changed files read
Tests not run Test result supplied by author only
Console behavior not run No console verification supplied

Findings

Blocking

None.

Non-blocking

None.

Not verified

The reported ctest -R guest_libressl_ssl_lifecycle run was not performed during this review. Console behavior was not checked. No changed files were excluded; all files listed as reviewed in the manifest were read.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6107961243 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23078#pullrequestreview-6107961243). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-30T06:52:56Z. **Review:** APPROVED --- # Reviewed — looks good Nothing in the reviewed code blocks merging; the added implementation and lifecycle tests support the documented behavior. ## What I ran Reviewed head `8a8ab0af89cb20e1426c87fcda8c6850fe165686`. I inspected the prepared diff and the full text of every changed file. I did not run the author-reported test command. ## Results | Check | Result | Note | |---|---|---| | Diff and changed code | passed | All five changed files read | | Tests | not run | Test result supplied by author only | | Console behavior | not run | No console verification supplied | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The reported `ctest -R guest_libressl_ssl_lifecycle` run was not performed during this review. Console behavior was not checked. No changed files were excluded; all files listed as reviewed in the manifest were read. ## To get this to a good state Nothing is required.
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!23078
No description provided.