feat(libSceLibreSsl3): implement SSL_CTX_add0_chain_cert and SSL_CTX_clear_chain_certs #23029

Merged
heditrigui merged 4 commits from upstream-pr/23029 into main 2026-11-26 10:51:44 +00:00
heditrigui commented 2026-11-18 16:54:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by heditrigui on 2026-11-18T16:54:33Z.


What

feat(libSceLibreSsl3): implement SSL_CTX_add0_chain_cert and SSL_CTX_clear_chain_certs.

  • SSL_CTX_add0_chain_cert appends an X509 certificate to the context's extra chain certificates list (context->extraCerts) without incrementing the certificate's reference count, taking ownership per LibreSSL / OpenSSL add0 semantics.
  • SSL_CTX_clear_chain_certs clears the certificate chain associated with the context, freeing the stack and decrementing certificate reference counts via sk_pop_free, returning 1 on success (or 0 if context is null).
  • Added unit tests in core/libs/prx/libSceLibreSsl3/tests/SslCtxChainCerts.cpp covering null argument validation, chain addition, stack growth, reference count retention across clear operations, and allocation failure paths.
  • Added technical debt fragment in docs/dev/debt/changes/feat-libressl3-ssl-ctx-chain-certs.md.

Tested

  • Zero C++ comments across modified and new files.
  • Pure LF line endings confirmed with git diff --check.
  • Conventions checked with tools/check_conventions.py --base main (0 errors).
  • Debt fold validated with tools/debt_fold.py --check.
  • Pre-screened against open pull requests with tools/pr_overlap.py (0 collisions).

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)
  • No notes, investigation .md files or images added to the repository
  • 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:5380331904 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029). Originally posted by [heditrigui](https://github.com/heditrigui) on 2026-11-18T16:54:33Z. --- ### What feat(libSceLibreSsl3): implement `SSL_CTX_add0_chain_cert` and `SSL_CTX_clear_chain_certs`. - `SSL_CTX_add0_chain_cert` appends an `X509` certificate to the context's extra chain certificates list (`context->extraCerts`) without incrementing the certificate's reference count, taking ownership per LibreSSL / OpenSSL `add0` semantics. - `SSL_CTX_clear_chain_certs` clears the certificate chain associated with the context, freeing the stack and decrementing certificate reference counts via `sk_pop_free`, returning 1 on success (or 0 if context is null). - Added unit tests in `core/libs/prx/libSceLibreSsl3/tests/SslCtxChainCerts.cpp` covering null argument validation, chain addition, stack growth, reference count retention across clear operations, and allocation failure paths. - Added technical debt fragment in `docs/dev/debt/changes/feat-libressl3-ssl-ctx-chain-certs.md`. ### Tested - Zero C++ comments across modified and new files. - Pure LF line endings confirmed with `git diff --check`. - Conventions checked with `tools/check_conventions.py --base main` (0 errors). - Debt fold validated with `tools/debt_fold.py --check`. - Pre-screened against open pull requests with `tools/pr_overlap.py` (0 collisions). ### 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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`) - [x] No notes, investigation `.md` files or images added to the repository - [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
PrivacyOnion commented 2026-11-18 16:59:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-18T16:59:37Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 49bbefeb57:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libressl3_ssl_ctx_chain_certs_tests built cleanly.
  • CTest (guest_libressl3_ssl_ctx_chain_certs):
    1/1 Test #4473: guest_libressl3_ssl_ctx_chain_certs ...   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceLibreSsl3/Export.cpp, core/libs/prx/libSceLibreSsl3/include/Api.hpp, core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified null pointer checks for LibreSsl3SslCtx* and LibreSsl3X509* in SSL_CTX_add0_chain_cert_nid_postfix returning 0
    • Verified stack initialization via sk_new_nid_postfix and element insertion via sk_push_nid_postfix in SslCtxChainCerts.cpp
    • Verified SSL_CTX_clear_chain_certs_nid_postfix frees extraCerts via sk_pop_free_nid_postfix with atomic reference count decrement and resets context->extraCerts to nullptr
    • Audited AGENTS.md compliance regarding comments, conventions, technical debt fragment format, and absence of fake stubs
    • Verified unit test suite in SslCtxChainCerts.cpp exercising null contexts/certificates, multiple insertions, clearing, and memory allocation failure paths

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5961322925 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029#pullrequestreview-5961322925). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-18T16:59:37Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `49bbefeb57`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_libressl3_ssl_ctx_chain_certs_tests` built cleanly. - **CTest** (`guest_libressl3_ssl_ctx_chain_certs`): ``` 1/1 Test #4473: guest_libressl3_ssl_ctx_chain_certs ... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceLibreSsl3/Export.cpp`, `core/libs/prx/libSceLibreSsl3/include/Api.hpp`, `core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified null pointer checks for LibreSsl3SslCtx* and LibreSsl3X509* in SSL_CTX_add0_chain_cert_nid_postfix returning 0 - Verified stack initialization via sk_new_nid_postfix and element insertion via sk_push_nid_postfix in SslCtxChainCerts.cpp - Verified SSL_CTX_clear_chain_certs_nid_postfix frees extraCerts via sk_pop_free_nid_postfix with atomic reference count decrement and resets context->extraCerts to nullptr - Audited AGENTS.md compliance regarding comments, conventions, technical debt fragment format, and absence of fake stubs - Verified unit test suite in SslCtxChainCerts.cpp exercising null contexts/certificates, multiple insertions, clearing, and memory allocation failure paths Looks Good To Me
MarcZX10 commented 2026-11-18 17:15:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T17:15:21Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: release each certificate when clearing its final reference.

What I ran

Reviewed head 49bbefeb578c53a0686e01f5b4eb3bbb3d3b8c9b using the prepared diff and repo_read.py source reads. No test or build commands were run.

Results

Check Result Note
Source review passed Changed code and related lifecycle code inspected
Tests and build not run No execution environment available
Negative control not run No test mutation performed

Findings

Blocking

  • core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:14: ReleaseCertificate only decrements the reference count. When the last reference is removed, it leaves the X509 object and its owned data allocated, so clearing the chain leaks certificates. Use the certificate release routine when the count reaches zero.

Non-blocking

None.

Not verified

Tests, build, and console behavior were not run. Read the prepared description, commits, diff, manifest, and README; inspected all changed files, including the complete added source, test, and debt fragment. For CMakeLists.txt, inspected the changed hunk; for Export.cpp, inspected the full file. No changed files were excluded.

To get this to a good state

Release certificate resources when clearing the final reference, then run the relevant test and build checks.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5961574757 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029#pullrequestreview-5961574757). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-18T17:15:21Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: release each certificate when clearing its final reference. ## What I ran Reviewed head `49bbefeb578c53a0686e01f5b4eb3bbb3d3b8c9b` using the prepared diff and `repo_read.py` source reads. No test or build commands were run. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Changed code and related lifecycle code inspected | | Tests and build | not run | No execution environment available | | Negative control | not run | No test mutation performed | ## Findings ### Blocking - `core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:14`: `ReleaseCertificate` only decrements the reference count. When the last reference is removed, it leaves the X509 object and its owned data allocated, so clearing the chain leaks certificates. Use the certificate release routine when the count reaches zero. ### Non-blocking None. ## Not verified Tests, build, and console behavior were not run. Read the prepared description, commits, diff, manifest, and README; inspected all changed files, including the complete added source, test, and debt fragment. For `CMakeLists.txt`, inspected the changed hunk; for `Export.cpp`, inspected the full file. No changed files were excluded. ## To get this to a good state Release certificate resources when clearing the final reference, then run the relevant test and build checks.
PrivacyOnion commented 2026-11-18 18:21:36 +00:00 (Migrated from github.com)

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

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 8ab6419b6c:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libressl3_ssl_ctx_chain_certs_tests built cleanly.
  • CTest (guest_libressl3_ssl_ctx_chain_certs):
    1/1 Test #4473: guest_libressl3_ssl_ctx_chain_certs ...   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceLibreSsl3/Export.cpp, core/libs/prx/libSceLibreSsl3/include/Api.hpp, core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.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_CTX_add0_chain_cert_nid_postfix in core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp for null pointer handling of context and certificate arguments returning 0
    • Audited stack allocation via sk_new_nid_postfix and failure handling returning 0 when allocation fails
    • Audited sk_push_nid_postfix element insertion and ownership transfer per LibreSSL add0 semantics
    • Audited SSL_CTX_clear_chain_certs_nid_postfix in core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp for null context handling returning 0 and clearing context->extraCerts to nullptr
    • Audited ReleaseCertificate callback in core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp for atomic reference count decrement and memory release via free_nid_postfix on final reference drop
    • Audited docs/dev/debt/changes/feat-libressl3-ssl-ctx-chain-certs.md and unit tests in core/libs/prx/libSceLibreSsl3/tests/SslCtxChainCerts.cpp for AGENTS.md conventions compliance

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5962579100 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029#pullrequestreview-5962579100). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-18T18:21:36Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `8ab6419b6c`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_libressl3_ssl_ctx_chain_certs_tests` built cleanly. - **CTest** (`guest_libressl3_ssl_ctx_chain_certs`): ``` 1/1 Test #4473: guest_libressl3_ssl_ctx_chain_certs ... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceLibreSsl3/Export.cpp`, `core/libs/prx/libSceLibreSsl3/include/Api.hpp`, `core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.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_CTX_add0_chain_cert_nid_postfix in core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp for null pointer handling of context and certificate arguments returning 0 - Audited stack allocation via sk_new_nid_postfix and failure handling returning 0 when allocation fails - Audited sk_push_nid_postfix element insertion and ownership transfer per LibreSSL add0 semantics - Audited SSL_CTX_clear_chain_certs_nid_postfix in core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp for null context handling returning 0 and clearing context->extraCerts to nullptr - Audited ReleaseCertificate callback in core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp for atomic reference count decrement and memory release via free_nid_postfix on final reference drop - Audited docs/dev/debt/changes/feat-libressl3-ssl-ctx-chain-certs.md and unit tests in core/libs/prx/libSceLibreSsl3/tests/SslCtxChainCerts.cpp for AGENTS.md conventions compliance Looks Good To Me
MarcZX10 commented 2026-11-18 19:40:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T19:40:12Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: release certificates through the library’s X509 reference-counting/free routine when clearing the chain.

What I ran

Reviewed head 8ab6419b6c21248e2648af94905c0465093412b9 using the pinned reader repo_read.py; no tests or build commands were run.

Results

Check Result Note
Source review passed All six changed files were read.
Build and tests not run No programmatic checks were run.

Findings

Blocking

  • core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:14 decrements the reference count itself and then calls free_nid_postfix when it reaches zero. This only frees the outer LibreSsl3X509 allocation; it skips the X509 destructor’s cleanup of owned certificate fields. Certificates whose final reference is released here can leak their internals. Use the library’s X509 free routine so final-reference cleanup follows the normal ownership path.

Non-blocking

None.

Not verified

Build and test execution, console behavior, and behavior on platforms other than the reader’s source view were not verified. Files reviewed: core/libs/prx/libSceLibreSsl3/CMakeLists.txt, core/libs/prx/libSceLibreSsl3/Export.cpp, core/libs/prx/libSceLibreSsl3/include/Api.hpp, core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp, core/libs/prx/libSceLibreSsl3/tests/SslCtxChainCerts.cpp, and docs/dev/debt/changes/feat-libressl3-ssl-ctx-chain-certs.md. No changed files were excluded; files.json was not available through the reader.

To get this to a good state

Replace the custom final-reference release with the library’s X509 free routine, then run the focused chain certificate test and the relevant build checks on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5963758472 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029#pullrequestreview-5963758472). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-18T19:40:12Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: release certificates through the library’s X509 reference-counting/free routine when clearing the chain. ## What I ran Reviewed head `8ab6419b6c21248e2648af94905c0465093412b9` using the pinned reader `repo_read.py`; no tests or build commands were run. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | All six changed files were read. | | Build and tests | not run | No programmatic checks were run. | ## Findings ### Blocking - `core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:14` decrements the reference count itself and then calls `free_nid_postfix` when it reaches zero. This only frees the outer `LibreSsl3X509` allocation; it skips the X509 destructor’s cleanup of owned certificate fields. Certificates whose final reference is released here can leak their internals. Use the library’s X509 free routine so final-reference cleanup follows the normal ownership path. ### Non-blocking None. ## Not verified Build and test execution, console behavior, and behavior on platforms other than the reader’s source view were not verified. Files reviewed: `core/libs/prx/libSceLibreSsl3/CMakeLists.txt`, `core/libs/prx/libSceLibreSsl3/Export.cpp`, `core/libs/prx/libSceLibreSsl3/include/Api.hpp`, `core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp`, `core/libs/prx/libSceLibreSsl3/tests/SslCtxChainCerts.cpp`, and `docs/dev/debt/changes/feat-libressl3-ssl-ctx-chain-certs.md`. No changed files were excluded; `files.json` was not available through the reader. ## To get this to a good state Replace the custom final-reference release with the library’s X509 free routine, then run the focused chain certificate test and the relevant build checks on the updated head.
PrivacyOnion commented 2026-11-19 09:03:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-19T09:03:14Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 8c00487dd3:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libressl3_ssl_ctx_chain_certs_tests built cleanly.
  • CTest (guest_libressl3_ssl_ctx_chain_certs):
    1/1 Test #4518: guest_libressl3_ssl_ctx_chain_certs ...   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceLibreSsl3/Export.cpp, core/libs/prx/libSceLibreSsl3/include/Api.hpp, core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Validated SSL_CTX_add0_chain_cert_nid_postfix in SslCtxChainCerts.cpp for null context and certificate checks, returning 0 per LibreSSL API contract.
    • Verified stack creation via sk_new_nid_postfix and certificate appending via sk_push_nid_postfix conforming to OpenSSL/LibreSSL add0 transfer of ownership.
    • Audited SSL_CTX_clear_chain_certs_nid_postfix handling of null and non-null context, popping/freeing certificates with sk_pop_free_nid_postfix and resetting context->extraCerts to nullptr.
    • Checked reference count decrement logic in ReleaseCertificate via std::atomic_ref with memory_order_acq_rel against documented technical debt and PR author/maintainer consensus.
    • Confirmed unit test coverage in SslCtxChainCerts.cpp exercises null parameter handling, single/multiple chain additions, capacity growth, retention across clear, and allocation failures without memory leaks.
    • Verified CMakeLists.txt and Export.cpp integration, conventions, and AGENTS.md compliance with technical debt tracking fragment.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5972069683 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029#pullrequestreview-5972069683). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-19T09:03:14Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `8c00487dd3`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_libressl3_ssl_ctx_chain_certs_tests` built cleanly. - **CTest** (`guest_libressl3_ssl_ctx_chain_certs`): ``` 1/1 Test #4518: guest_libressl3_ssl_ctx_chain_certs ... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceLibreSsl3/Export.cpp`, `core/libs/prx/libSceLibreSsl3/include/Api.hpp`, `core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Validated SSL_CTX_add0_chain_cert_nid_postfix in SslCtxChainCerts.cpp for null context and certificate checks, returning 0 per LibreSSL API contract. - Verified stack creation via sk_new_nid_postfix and certificate appending via sk_push_nid_postfix conforming to OpenSSL/LibreSSL add0 transfer of ownership. - Audited SSL_CTX_clear_chain_certs_nid_postfix handling of null and non-null context, popping/freeing certificates with sk_pop_free_nid_postfix and resetting context->extraCerts to nullptr. - Checked reference count decrement logic in ReleaseCertificate via std::atomic_ref with memory_order_acq_rel against documented technical debt and PR author/maintainer consensus. - Confirmed unit test coverage in SslCtxChainCerts.cpp exercises null parameter handling, single/multiple chain additions, capacity growth, retention across clear, and allocation failures without memory leaks. - Verified CMakeLists.txt and Export.cpp integration, conventions, and AGENTS.md compliance with technical debt tracking fragment. Looks Good To Me
MarcZX10 commented 2026-11-19 09:37:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T09:37:39Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the points below are optional.

What I ran

Reviewed head 8c00487dd3b52fbf483b376d6a8d4eaac36f0215 against base main. I read the prepared description, commits, diff, manifest, all changed source and test lines, and targeted stack and X509 ownership context via repo_read.py. No commands or tests were run.

Results

Check Result Note
Source review passed Add/clear behavior and stack semantics inspected
Tests not run No build or test command run
Console behavior not run Not verified on hardware

Findings

Blocking

None.

Non-blocking

  • core/libs/prx/libSceLibreSsl3/tests/SslCtxChainCerts.cpp:119 clears the chain, but the test only frees cert2 afterward. The certificates with a final reference of 1, including cert1, are not released by the test allocator; TestAllocationTracking therefore appears unable to reach zero. Free those test allocations or track certificate releases separately so the allocation check verifies cleanup.

Not verified

  • No build, unit test, convention check, debt check, or PR overlap check was run; those checks are reported by the author only.
  • Console behavior was not tested.
  • All changed files listed in the manifest were read. No files were excluded by rule in the manifest.

To get this to a good state

Nothing is required. Optionally, make the test release all certificate allocations so its allocation tracking assertion checks the intended cleanup.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5972529265 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029#pullrequestreview-5972529265). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-19T09:37:39Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the points below are optional. ## What I ran Reviewed head `8c00487dd3b52fbf483b376d6a8d4eaac36f0215` against base `main`. I read the prepared description, commits, diff, manifest, all changed source and test lines, and targeted stack and X509 ownership context via `repo_read.py`. No commands or tests were run. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Add/clear behavior and stack semantics inspected | | Tests | not run | No build or test command run | | Console behavior | not run | Not verified on hardware | ## Findings ### Blocking None. ### Non-blocking - `core/libs/prx/libSceLibreSsl3/tests/SslCtxChainCerts.cpp:119` clears the chain, but the test only frees `cert2` afterward. The certificates with a final reference of 1, including `cert1`, are not released by the test allocator; `TestAllocationTracking` therefore appears unable to reach zero. Free those test allocations or track certificate releases separately so the allocation check verifies cleanup. ## Not verified - No build, unit test, convention check, debt check, or PR overlap check was run; those checks are reported by the author only. - Console behavior was not tested. - All changed files listed in the manifest were read. No files were excluded by rule in the manifest. ## To get this to a good state Nothing is required. Optionally, make the test release all certificate allocations so its allocation tracking assertion checks the intended cleanup.
PrivacyOnion commented 2026-11-19 11:34:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-19T11:34:40Z.

Review: CHANGES_REQUESTED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 31237e2fd3:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libressl3_ssl_ctx_chain_certs_tests failed to build.
    core/libs/prx/libSceLibreSsl3/Export.cpp:54:15: error: conflicting declaration of C function ‘int PEM_read_RSAPrivateKey_nid_disambig1_nid_postfix()’
    core/libs/prx/libSceLibreSsl3/include/Api.hpp:292:25: note: previous declaration ‘LibreSsl3Rsa* PEM_read_RSAPrivateKey_nid_disambig1_nid_postfix(FileStream*, LibreSsl3Rsa**, LibreSslPemPasswordCallback, void*)’
    

Requesting changes for the points above.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5974230788 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029#pullrequestreview-5974230788). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-19T11:34:40Z. **Review:** CHANGES_REQUESTED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `31237e2fd3`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_libressl3_ssl_ctx_chain_certs_tests` failed to build. ``` core/libs/prx/libSceLibreSsl3/Export.cpp:54:15: error: conflicting declaration of C function ‘int PEM_read_RSAPrivateKey_nid_disambig1_nid_postfix()’ core/libs/prx/libSceLibreSsl3/include/Api.hpp:292:25: note: previous declaration ‘LibreSsl3Rsa* PEM_read_RSAPrivateKey_nid_disambig1_nid_postfix(FileStream*, LibreSsl3Rsa**, LibreSslPemPasswordCallback, void*)’ ``` Requesting changes for the points above.
MarcZX10 commented 2026-11-19 11:40:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T11:40:45Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: prevent the chain clear callback from decrementing an already-zero X509 reference count.

What I ran

Reviewed head 31237e2fd374622db002fd5a899a6a298c4bbd2d using the prepared diff and repo_read.py targeted reads/searches. No build or tests were run.

Results

Check Result Note
Source review failed X509 cleanup mishandles a zero reference count
Build and tests not run No commands available in this review session

Findings

Blocking

  • core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:14: ReleaseCertificate decrements the count unconditionally and frees the certificate when the prior count is 0 or 1. For a zero count, this wraps the count to -1 and frees the object; the X509 reference count must not be decremented below zero. Guard against nonpositive counts before decrementing and free only when decrementing from one.

Non-blocking

None.

Not verified

Build and test execution, console behavior, and the excluded-file list were not verified. Read the prepared description, commits, manifest, diff, and full text for all five changed files: core/libs/prx/libSceLibreSsl3/CMakeLists.txt, core/libs/prx/libSceLibreSsl3/Export.cpp, core/libs/prx/libSceLibreSsl3/include/Api.hpp, core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp, core/libs/prx/libSceLibreSsl3/tests/SslCtxChainCerts.cpp, and docs/dev/debt/changes/feat-libressl3-ssl-ctx-chain-certs.md. No changed files were excluded according to the manifest.

To get this to a good state

Prevent clearing a zero-reference certificate from underflowing its count or freeing it, and add a regression test for that case. Then run the focused test and relevant project checks on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5974321248 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029#pullrequestreview-5974321248). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-19T11:40:45Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: prevent the chain clear callback from decrementing an already-zero X509 reference count. ## What I ran Reviewed head `31237e2fd374622db002fd5a899a6a298c4bbd2d` using the prepared diff and `repo_read.py` targeted reads/searches. No build or tests were run. ## Results | Check | Result | Note | |---|---|---| | Source review | failed | X509 cleanup mishandles a zero reference count | | Build and tests | not run | No commands available in this review session | ## Findings ### Blocking - `core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:14`: `ReleaseCertificate` decrements the count unconditionally and frees the certificate when the prior count is `0` or `1`. For a zero count, this wraps the count to `-1` and frees the object; the X509 reference count must not be decremented below zero. Guard against nonpositive counts before decrementing and free only when decrementing from one. ### Non-blocking None. ## Not verified Build and test execution, console behavior, and the excluded-file list were not verified. Read the prepared description, commits, manifest, diff, and full text for all five changed files: `core/libs/prx/libSceLibreSsl3/CMakeLists.txt`, `core/libs/prx/libSceLibreSsl3/Export.cpp`, `core/libs/prx/libSceLibreSsl3/include/Api.hpp`, `core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp`, `core/libs/prx/libSceLibreSsl3/tests/SslCtxChainCerts.cpp`, and `docs/dev/debt/changes/feat-libressl3-ssl-ctx-chain-certs.md`. No changed files were excluded according to the manifest. ## To get this to a good state Prevent clearing a zero-reference certificate from underflowing its count or freeing it, and add a regression test for that case. Then run the focused test and relevant project checks on the updated head.
PrivacyOnion commented 2026-11-19 13:28:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-19T13:28:21Z.

Review: CHANGES_REQUESTED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 5763c85792:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libressl3_ssl_ctx_chain_certs_tests built cleanly.
  • CTest (guest_libressl3_ssl_ctx_chain_certs):
    1/1 Test #4560: guest_libressl3_ssl_ctx_chain_certs ...   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceLibreSsl3/Export.cpp, core/libs/prx/libSceLibreSsl3/include/Api.hpp, core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified null check handling for LibreSsl3SslCtx* context and LibreSsl3X509* certificate in SSL_CTX_add0_chain_cert_nid_postfix and SSL_CTX_clear_chain_certs_nid_postfix.
    • Inspected reference counting in ReleaseCertificate for X509 certificates and underflow behavior when certificate->references is nonpositive (zero or negative).
    • Checked struct layout compatibility between parent LibreSslCtx and LibreSsl3SslCtx regarding extraCerts offset.
    • Inspected leak handling in SSL_CTX_add0_chain_cert_nid_postfix when sk_new_nid_postfix succeeds but sk_push_nid_postfix fails.
    • Verified AGENTS.md rules, technical debt fragment formatting, and test coverage in tests/SslCtxChainCerts.cpp.
  • Concerns:
    • core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:14: In ReleaseCertificate, count.fetch_sub(1, std::memory_order_acq_rel) unconditionally decrements certificate->references. If certificate->references <= 0 prior to release, fetch_sub underflows the count to negative (or further negative) while satisfying <= 1, invoking free_nid_postfix(certificate) on a nonpositive reference count without guarding against nonpositive counts. Per maintainer and reviewer guidance, ReleaseCertificate must guard against count <= 0 prior to decrementing and only free when decrementing from 1.
    • core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:25: In SSL_CTX_add0_chain_cert_nid_postfix, if context->extraCerts is initially null and sk_new_nid_postfix(nullptr) succeeds in creating a new stack, but sk_push_nid_postfix(stack, certificate) fails (e.g. out of memory on reallocation), the function returns 0 while leaving context->extraCerts assigned to the newly allocated empty stack. Because context->extraCerts is left non-null, subsequent operations or context destruction leak or mismanage the orphaned empty stack without cleanup or rollback.

Requesting changes for the points above.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5975899180 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029#pullrequestreview-5975899180). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-19T13:28:21Z. **Review:** CHANGES_REQUESTED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `5763c85792`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_libressl3_ssl_ctx_chain_certs_tests` built cleanly. - **CTest** (`guest_libressl3_ssl_ctx_chain_certs`): ``` 1/1 Test #4560: guest_libressl3_ssl_ctx_chain_certs ... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceLibreSsl3/Export.cpp`, `core/libs/prx/libSceLibreSsl3/include/Api.hpp`, `core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified null check handling for LibreSsl3SslCtx* context and LibreSsl3X509* certificate in SSL_CTX_add0_chain_cert_nid_postfix and SSL_CTX_clear_chain_certs_nid_postfix. - Inspected reference counting in ReleaseCertificate for X509 certificates and underflow behavior when certificate->references is nonpositive (zero or negative). - Checked struct layout compatibility between parent LibreSslCtx and LibreSsl3SslCtx regarding extraCerts offset. - Inspected leak handling in SSL_CTX_add0_chain_cert_nid_postfix when sk_new_nid_postfix succeeds but sk_push_nid_postfix fails. - Verified AGENTS.md rules, technical debt fragment formatting, and test coverage in tests/SslCtxChainCerts.cpp. - **Concerns**: - core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:14: In ReleaseCertificate, `count.fetch_sub(1, std::memory_order_acq_rel)` unconditionally decrements `certificate->references`. If `certificate->references <= 0` prior to release, `fetch_sub` underflows the count to negative (or further negative) while satisfying `<= 1`, invoking `free_nid_postfix(certificate)` on a nonpositive reference count without guarding against nonpositive counts. Per maintainer and reviewer guidance, ReleaseCertificate must guard against `count <= 0` prior to decrementing and only free when decrementing from 1. - core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:25: In SSL_CTX_add0_chain_cert_nid_postfix, if `context->extraCerts` is initially null and `sk_new_nid_postfix(nullptr)` succeeds in creating a new stack, but `sk_push_nid_postfix(stack, certificate)` fails (e.g. out of memory on reallocation), the function returns 0 while leaving `context->extraCerts` assigned to the newly allocated empty stack. Because `context->extraCerts` is left non-null, subsequent operations or context destruction leak or mismanage the orphaned empty stack without cleanup or rollback. Requesting changes for the points above.
MarcZX10 commented 2026-11-19 13:39:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T13:39:25Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: free the certificate if insertion fails, or otherwise restore its ownership to the caller according to the API contract.

What I ran

  • Reviewed head 5763c857926f0af4edfda874d99cf5f21c558568 using the prepared review bundle and repo_read.py.
  • No build or tests were run.

Results

Check Result Note
Source review failed Insertion failure leaks the add0 certificate
Build and tests not run No commands run

Findings

Blocking

  • core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:31: If sk_push_nid_postfix returns 0, the function returns failure but does not release the certificate. sk_push_nid_postfix can return 0 when growing the stack's element array fails; its failure leaves the stack unchanged. The API description says add0 transfers ownership, so this failure path leaks the transferred certificate. Release it on failure or define and implement an explicit ownership return contract.

Non-blocking

None.

Sources

  • core/libs/prx/libSceLibreSsl3/src/Stack.cpp:120-127 shows the allocation-failure return from sk_push_nid_postfix.
  • core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:31-32 shows the failed insertion path.

Not verified

  • No build, test, CI, console, or hardware behavior was run.
  • All six changed files listed in the manifest were included and read: core/libs/prx/libSceLibreSsl3/CMakeLists.txt, core/libs/prx/libSceLibreSsl3/Export.cpp, core/libs/prx/libSceLibreSsl3/include/Api.hpp, core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp, core/libs/prx/libSceLibreSsl3/tests/SslCtxChainCerts.cpp, and docs/dev/debt/changes/feat-libressl3-ssl-ctx-chain-certs.md. No changed files were excluded by the manifest.

To get this to a good state

  • Fix the certificate ownership on insertion failure, then rerun the relevant build and tests on the updated head.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5976069055 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029#pullrequestreview-5976069055). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-19T13:39:25Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: free the certificate if insertion fails, or otherwise restore its ownership to the caller according to the API contract. ## What I ran - Reviewed head `5763c857926f0af4edfda874d99cf5f21c558568` using the prepared review bundle and `repo_read.py`. - No build or tests were run. ## Results | Check | Result | Note | |---|---|---| | Source review | failed | Insertion failure leaks the add0 certificate | | Build and tests | not run | No commands run | ## Findings ### Blocking - `core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:31`: If `sk_push_nid_postfix` returns 0, the function returns failure but does not release the certificate. `sk_push_nid_postfix` can return 0 when growing the stack's element array fails; its failure leaves the stack unchanged. The API description says add0 transfers ownership, so this failure path leaks the transferred certificate. Release it on failure or define and implement an explicit ownership return contract. ### Non-blocking None. ## Sources - `core/libs/prx/libSceLibreSsl3/src/Stack.cpp:120-127` shows the allocation-failure return from `sk_push_nid_postfix`. - `core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:31-32` shows the failed insertion path. ## Not verified - No build, test, CI, console, or hardware behavior was run. - All six changed files listed in the manifest were included and read: `core/libs/prx/libSceLibreSsl3/CMakeLists.txt`, `core/libs/prx/libSceLibreSsl3/Export.cpp`, `core/libs/prx/libSceLibreSsl3/include/Api.hpp`, `core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp`, `core/libs/prx/libSceLibreSsl3/tests/SslCtxChainCerts.cpp`, and `docs/dev/debt/changes/feat-libressl3-ssl-ctx-chain-certs.md`. No changed files were excluded by the manifest. ## To get this to a good state - Fix the certificate ownership on insertion failure, then rerun the relevant build and tests on the updated head.
PrivacyOnion commented 2026-11-19 15:54:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-19T15:54:20Z.

Review: CHANGES_REQUESTED


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

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libressl3_ssl_ctx_chain_certs_tests built cleanly.
  • CTest (guest_libressl3_ssl_ctx_chain_certs):
    1/1 Test #4582: guest_libressl3_ssl_ctx_chain_certs ...   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceLibreSsl3/Export.cpp, core/libs/prx/libSceLibreSsl3/include/Api.hpp, core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.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_CTX_add0_chain_cert_nid_postfix and SSL_CTX_clear_chain_certs_nid_postfix pointer validation for null context and null certificate, returning 0
    • Verified stack creation, reallocation handling, error rollback, and memory cleanup in SSL_CTX_add0_chain_cert_nid_postfix
    • Verified sk_pop_free callback invocation and ReleaseCertificate refcount management and deallocation via free_nid_postfix
    • Verified CMake configuration, test executable registration, Windows unwind, and CTest targets in core/libs/prx/libSceLibreSsl3/CMakeLists.txt
    • Verified AGENTS.md rule compliance: lack of code comments, lack of title-specific hacks, debt fragment presence in docs/dev/debt/changes/feat-libressl3-ssl-ctx-chain-certs.md
  • Concerns:
    • core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:14: In ReleaseCertificate(), std::atomic_refstd::int32_t::fetch_sub(1) is called unconditionally without guarding against an initial count <= 0. If certificate->references is 0 or negative upon entry, fetch_sub returns <= 0, satisfying <= 1, freeing certificate and driving references to negative values (e.g., -1). This directly violates the maintainer's explicit review requirement to guard against nonpositive counts before decrementing and return early when count is 0 or less.

Requesting changes for the points above.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5978439292 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029#pullrequestreview-5978439292). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-19T15:54:20Z. **Review:** CHANGES_REQUESTED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `b6f5f50aaa`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_libressl3_ssl_ctx_chain_certs_tests` built cleanly. - **CTest** (`guest_libressl3_ssl_ctx_chain_certs`): ``` 1/1 Test #4582: guest_libressl3_ssl_ctx_chain_certs ... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceLibreSsl3/Export.cpp`, `core/libs/prx/libSceLibreSsl3/include/Api.hpp`, `core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.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_CTX_add0_chain_cert_nid_postfix and SSL_CTX_clear_chain_certs_nid_postfix pointer validation for null context and null certificate, returning 0 - Verified stack creation, reallocation handling, error rollback, and memory cleanup in SSL_CTX_add0_chain_cert_nid_postfix - Verified sk_pop_free callback invocation and ReleaseCertificate refcount management and deallocation via free_nid_postfix - Verified CMake configuration, test executable registration, Windows unwind, and CTest targets in core/libs/prx/libSceLibreSsl3/CMakeLists.txt - Verified AGENTS.md rule compliance: lack of code comments, lack of title-specific hacks, debt fragment presence in docs/dev/debt/changes/feat-libressl3-ssl-ctx-chain-certs.md - **Concerns**: - core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:14: In ReleaseCertificate(), std::atomic_ref<std::int32_t>::fetch_sub(1) is called unconditionally without guarding against an initial count <= 0. If certificate->references is 0 or negative upon entry, fetch_sub returns <= 0, satisfying `<= 1`, freeing certificate and driving references to negative values (e.g., -1). This directly violates the maintainer's explicit review requirement to guard against nonpositive counts before decrementing and return early when count is 0 or less. Requesting changes for the points above.
MarcZX10 commented 2026-11-19 15:59:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T15:59:08Z.

Review: CHANGES_REQUESTED


Reviewed — comments

Changes are required before merge: the changed code invokes a stack cleanup API that is not declared in the included public header, so the implementation cannot compile as written.

What I ran

Reviewed head b6f5f50aaad33e4cdf1a0b5ec2d1a44c7942d432. No build or tests were run. Read the prepared description, commit list, manifest, diff, and all six changed files; inspected the stack implementation and API declarations used by the change.

Results

Check Result Note
Source review failed Undeclared stack cleanup function
Build and tests not run No execution performed
Author-reported checks not run Description reports convention and debt checks

Findings

Blocking

  • core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:44 calls sk_pop_free_nid_postfix, but the included Api.hpp declares only sk_free_nid_postfix, sk_new_nid_postfix, and sk_push_nid_postfix for stack operations (core/libs/prx/libSceLibreSsl3/include/Api.hpp:393-395). Repository search found no declaration for sk_pop_free_nid_postfix; the source also provides no local declaration. This leaves the call undeclared at compile time. Declare and implement the API or release each element and free the stack using available declared APIs.

Non-blocking

None.

Not verified

No build, unit tests, console behavior, or author-reported checks were verified by this review. files.json was not available through the reader; the manifest lists six changed files and marks all included, and all six were read. The review bundle excluded no changed files according to the manifest entries read.

To get this to a good state

Add a valid declaration and implementation for sk_pop_free_nid_postfix, or change the cleanup to use available declared APIs. Then rerun the project build and the new chain-certificate test.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5978539761 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029#pullrequestreview-5978539761). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-19T15:59:08Z. **Review:** CHANGES_REQUESTED --- # Reviewed — comments Changes are required before merge: the changed code invokes a stack cleanup API that is not declared in the included public header, so the implementation cannot compile as written. ## What I ran Reviewed head `b6f5f50aaad33e4cdf1a0b5ec2d1a44c7942d432`. No build or tests were run. Read the prepared description, commit list, manifest, diff, and all six changed files; inspected the stack implementation and API declarations used by the change. ## Results | Check | Result | Note | |---|---|---| | Source review | failed | Undeclared stack cleanup function | | Build and tests | not run | No execution performed | | Author-reported checks | not run | Description reports convention and debt checks | ## Findings ### Blocking - `core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:44` calls `sk_pop_free_nid_postfix`, but the included `Api.hpp` declares only `sk_free_nid_postfix`, `sk_new_nid_postfix`, and `sk_push_nid_postfix` for stack operations (`core/libs/prx/libSceLibreSsl3/include/Api.hpp:393-395`). Repository search found no declaration for `sk_pop_free_nid_postfix`; the source also provides no local declaration. This leaves the call undeclared at compile time. Declare and implement the API or release each element and free the stack using available declared APIs. ### Non-blocking None. ## Not verified No build, unit tests, console behavior, or author-reported checks were verified by this review. `files.json` was not available through the reader; the manifest lists six changed files and marks all included, and all six were read. The review bundle excluded no changed files according to the manifest entries read. ## To get this to a good state Add a valid declaration and implementation for `sk_pop_free_nid_postfix`, or change the cleanup to use available declared APIs. Then rerun the project build and the new chain-certificate test.
PrivacyOnion commented 2026-11-20 08:17:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-20T08:17:20Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 127f311dfa:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libressl3_ssl_ctx_chain_certs_tests built cleanly.
  • CTest (guest_libressl3_ssl_ctx_chain_certs):
    1/1 Test #4629: guest_libressl3_ssl_ctx_chain_certs ...   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceLibreSsl3/Export.cpp, core/libs/prx/libSceLibreSsl3/include/Api.hpp, core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified null pointer handling in SSL_CTX_add0_chain_cert and SSL_CTX_clear_chain_certs (SslCtxChainCerts.cpp:24, 41) returning 0 on nullptr
    • Verified stack allocation failure handling and cleanup in SSL_CTX_add0_chain_cert (SslCtxChainCerts.cpp:27-36) where sk_free_nid_postfix is invoked on newly created stack if sk_push_nid_postfix fails
    • Verified atomic reference decrement and memory order in ReleaseCertificate (SslCtxChainCerts.cpp:10-17) using std::atomic_ref with std::memory_order_acq_rel, properly freeing only on last reference (<= 1)
    • Verified SSL_CTX_clear_chain_certs iteration over stack->data and deallocation via sk_free_nid_postfix with context->extraCerts cleared to nullptr
    • Verified AGENTS.md compliance: zero comments in implementation code, clean conventions check, and proper debt fragment documentation in docs/dev/debt/changes/feat-libressl3-ssl-ctx-chain-certs.md

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5989488130 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029#pullrequestreview-5989488130). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-20T08:17:20Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `127f311dfa`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_libressl3_ssl_ctx_chain_certs_tests` built cleanly. - **CTest** (`guest_libressl3_ssl_ctx_chain_certs`): ``` 1/1 Test #4629: guest_libressl3_ssl_ctx_chain_certs ... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceLibreSsl3/Export.cpp`, `core/libs/prx/libSceLibreSsl3/include/Api.hpp`, `core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified null pointer handling in SSL_CTX_add0_chain_cert and SSL_CTX_clear_chain_certs (SslCtxChainCerts.cpp:24, 41) returning 0 on nullptr - Verified stack allocation failure handling and cleanup in SSL_CTX_add0_chain_cert (SslCtxChainCerts.cpp:27-36) where sk_free_nid_postfix is invoked on newly created stack if sk_push_nid_postfix fails - Verified atomic reference decrement and memory order in ReleaseCertificate (SslCtxChainCerts.cpp:10-17) using std::atomic_ref with std::memory_order_acq_rel, properly freeing only on last reference (<= 1) - Verified SSL_CTX_clear_chain_certs iteration over stack->data and deallocation via sk_free_nid_postfix with context->extraCerts cleared to nullptr - Verified AGENTS.md compliance: zero comments in implementation code, clean conventions check, and proper debt fragment documentation in docs/dev/debt/changes/feat-libressl3-ssl-ctx-chain-certs.md Looks Good To Me
MarcZX10 commented 2026-11-20 08:19:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T08:19:25Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: release certificates through their full destructor when the context drops the final reference.

What I ran

Inspected the prepared diff and targeted source at head 127f311dfad47a0ec9a828bbdeb4a0696e5f5cab; no build or tests were run.

Results

Check Result Note
Code review failed Final certificate release frees only its outer allocation
Build and tests not run No execution environment available

Findings

Blocking

  • core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:15 frees the LibreSsl3X509 allocation directly when its reference count reaches zero. The certificate struct contains separately allocated certInfo, sigAlg, and signature pointers, so clearing a chain with the final reference leaks those owned resources. Use the full X509 destruction path for the final release. The new tests use certificates with those pointers set to null, so they do not exercise this case.

Non-blocking

None.

Not verified

Build and test execution were not performed. The description’s reported checks were not independently run. Read the changed CMake hunk, Export.cpp, Api.hpp, SslCtxChainCerts.cpp, SslCtxChainCerts.cpp tests, and the debt fragment. No files were excluded from the prepared manifest.

To get this to a good state

Replace the final-reference raw free with full X509 destruction, then add coverage for releasing a certificate with owned sub-allocations. Re-run the relevant build and tests on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5989510749 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029#pullrequestreview-5989510749). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T08:19:25Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: release certificates through their full destructor when the context drops the final reference. ## What I ran Inspected the prepared diff and targeted source at head `127f311dfad47a0ec9a828bbdeb4a0696e5f5cab`; no build or tests were run. ## Results | Check | Result | Note | |---|---|---| | Code review | failed | Final certificate release frees only its outer allocation | | Build and tests | not run | No execution environment available | ## Findings ### Blocking - `core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:15` frees the `LibreSsl3X509` allocation directly when its reference count reaches zero. The certificate struct contains separately allocated `certInfo`, `sigAlg`, and `signature` pointers, so clearing a chain with the final reference leaks those owned resources. Use the full X509 destruction path for the final release. The new tests use certificates with those pointers set to null, so they do not exercise this case. ### Non-blocking None. ## Not verified Build and test execution were not performed. The description’s reported checks were not independently run. Read the changed CMake hunk, `Export.cpp`, `Api.hpp`, `SslCtxChainCerts.cpp`, `SslCtxChainCerts.cpp` tests, and the debt fragment. No files were excluded from the prepared manifest. ## To get this to a good state Replace the final-reference raw free with full X509 destruction, then add coverage for releasing a certificate with owned sub-allocations. Re-run the relevant build and tests on the updated head.
PrivacyOnion commented 2026-11-20 08:54:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-20T08:54:54Z.

Review: CHANGES_REQUESTED


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

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libressl3_ssl_ctx_chain_certs_tests failed to build.
    core/libs/prx/libSceLibreSsl3/tests/SslCtxChainCerts.cpp:201:25: error: invalid conversion from ‘const void*’ to ‘void*’ [-fpermissive]
    

Requesting changes for the points above.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5989905814 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029#pullrequestreview-5989905814). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-20T08:54:54Z. **Review:** CHANGES_REQUESTED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `e20bfab67a`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_libressl3_ssl_ctx_chain_certs_tests` failed to build. ``` core/libs/prx/libSceLibreSsl3/tests/SslCtxChainCerts.cpp:201:25: error: invalid conversion from ‘const void*’ to ‘void*’ [-fpermissive] ``` Requesting changes for the points above.
MarcZX10 commented 2026-11-20 08:58:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T08:58:19Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: make SSL_CTX_add0_chain_cert handle stack insertion failures without throwing or leaving partial state.

What I ran

Reviewed head e20bfab67aad0ec2f3b072909c946acbc1bd2a8f against the prepared diff. No commands or tests were run.

Results

Check Result Note
Changed code review failed Insertion failure can throw
Tests not run No test execution available

Findings

Blocking

  • SSL_CTX_add0_chain_cert_nid_postfix treats sk_push_nid_postfix as a non-throwing operation. That helper throws on invalid stack memory or a failed guest memory access; therefore such a failure can escape the API instead of returning 0, and on a newly allocated stack can leave the stack attached to the context. Catch and clean up appropriately so failure preserves the add0 contract. Evidence: core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:32.

Non-blocking

None.

Not verified

No tests or build were run. All eight changed files listed as reviewed in the manifest were read: core/libs/prx/libSceLibreSsl3/CMakeLists.txt, core/libs/prx/libSceLibreSsl3/Export.cpp, core/libs/prx/libSceLibreSsl3/include/Api.hpp, core/libs/prx/libSceLibreSsl3/include/X509.hpp, core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp, core/libs/prx/libSceLibreSsl3/src/X509StoreLoadLocations.cpp, core/libs/prx/libSceLibreSsl3/tests/SslCtxChainCerts.cpp, and docs/dev/debt/changes/feat-libressl3-ssl-ctx-chain-certs.md. No changed files were excluded by the manifest.

To get this to a good state

Handle exceptions from stack insertion, restoring context->extraCerts and freeing a newly created stack before returning 0. Add and run coverage for this failure path.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5989951234 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029#pullrequestreview-5989951234). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T08:58:19Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: make `SSL_CTX_add0_chain_cert` handle stack insertion failures without throwing or leaving partial state. ## What I ran Reviewed head `e20bfab67aad0ec2f3b072909c946acbc1bd2a8f` against the prepared diff. No commands or tests were run. ## Results | Check | Result | Note | |---|---|---| | Changed code review | failed | Insertion failure can throw | | Tests | not run | No test execution available | ## Findings ### Blocking - `SSL_CTX_add0_chain_cert_nid_postfix` treats `sk_push_nid_postfix` as a non-throwing operation. That helper throws on invalid stack memory or a failed guest memory access; therefore such a failure can escape the API instead of returning 0, and on a newly allocated stack can leave the stack attached to the context. Catch and clean up appropriately so failure preserves the add0 contract. Evidence: `core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:32`. ### Non-blocking None. ## Not verified No tests or build were run. All eight changed files listed as reviewed in the manifest were read: `core/libs/prx/libSceLibreSsl3/CMakeLists.txt`, `core/libs/prx/libSceLibreSsl3/Export.cpp`, `core/libs/prx/libSceLibreSsl3/include/Api.hpp`, `core/libs/prx/libSceLibreSsl3/include/X509.hpp`, `core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp`, `core/libs/prx/libSceLibreSsl3/src/X509StoreLoadLocations.cpp`, `core/libs/prx/libSceLibreSsl3/tests/SslCtxChainCerts.cpp`, and `docs/dev/debt/changes/feat-libressl3-ssl-ctx-chain-certs.md`. No changed files were excluded by the manifest. ## To get this to a good state Handle exceptions from stack insertion, restoring `context->extraCerts` and freeing a newly created stack before returning 0. Add and run coverage for this failure path.
PrivacyOnion commented 2026-11-20 09:11:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-20T09:11:57Z.

Review: CHANGES_REQUESTED


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

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libressl3_ssl_ctx_chain_certs_tests built cleanly.
  • CTest (guest_libressl3_ssl_ctx_chain_certs):
    1/1 Test #4629: guest_libressl3_ssl_ctx_chain_certs ...Subprocess aborted***Exception:   0.18 sec
    0% tests passed, 1 tests failed out of 1
    
    The following tests FAILED:
    

Requesting changes for the points above.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5990161992 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029#pullrequestreview-5990161992). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-20T09:11:57Z. **Review:** CHANGES_REQUESTED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `bb5cb12d6f`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_libressl3_ssl_ctx_chain_certs_tests` built cleanly. - **CTest** (`guest_libressl3_ssl_ctx_chain_certs`): ``` 1/1 Test #4629: guest_libressl3_ssl_ctx_chain_certs ...Subprocess aborted***Exception: 0.18 sec 0% tests passed, 1 tests failed out of 1 ``` ``` The following tests FAILED: ``` Requesting changes for the points above.
MarcZX10 commented 2026-11-20 09:15:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T09:15:32Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: prevent clearing an invalid stack count from indexing outside its element array.

What I ran

Reviewed head bb5cb12d6f62757230d672f169966a60e700545f. No build or tests were run. Read description.md, commits.md, diff.patch, manifest.json, and every changed line in the eight changed files; consulted Stack.cpp, Api.hpp, and X509StoreLoadLocations.cpp for stack and certificate cleanup behavior.

Results

Check Result Note
Source review failed One verified invalid-stack crash path
Build and tests not run No commands executed
Console behavior not run Not verified on console

Findings

Blocking

  • core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:51 loops to stack->num without validating that the count is nonnegative or within numAlloc. sk_push_nid_postfix explicitly rejects a negative count, and this PR's own test constructs a stack with num = -1 at tests/SslCtxChainCerts.cpp:265, but does not clear it. If a context has such a stack, SSL_CTX_clear_chain_certs indexes stack->data with a negative count and then frees the stack; malformed counts above allocated capacity similarly read beyond the array. Validate stack metadata before releasing elements, with a safe error path that avoids out-of-bounds access.

Non-blocking

None.

Sources

Not verified

Build and test results, console behavior, and behavior on other operating systems were not verified. All eight changed files listed in the manifest were read; no changed files were excluded.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5990215386 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029#pullrequestreview-5990215386). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T09:15:32Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: prevent clearing an invalid stack count from indexing outside its element array. ## What I ran Reviewed head `bb5cb12d6f62757230d672f169966a60e700545f`. No build or tests were run. Read `description.md`, `commits.md`, `diff.patch`, `manifest.json`, and every changed line in the eight changed files; consulted `Stack.cpp`, `Api.hpp`, and `X509StoreLoadLocations.cpp` for stack and certificate cleanup behavior. ## Results | Check | Result | Note | |---|---|---| | Source review | failed | One verified invalid-stack crash path | | Build and tests | not run | No commands executed | | Console behavior | not run | Not verified on console | ## Findings ### Blocking - `core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:51` loops to `stack->num` without validating that the count is nonnegative or within `numAlloc`. `sk_push_nid_postfix` explicitly rejects a negative count, and this PR's own test constructs a stack with `num = -1` at `tests/SslCtxChainCerts.cpp:265`, but does not clear it. If a context has such a stack, `SSL_CTX_clear_chain_certs` indexes `stack->data` with a negative count and then frees the stack; malformed counts above allocated capacity similarly read beyond the array. Validate stack metadata before releasing elements, with a safe error path that avoids out-of-bounds access. ### Non-blocking None. ## Sources - [Changed clear loop](https://github.com/boykopovar/AnyPS5/blob/bb5cb12d6f62757230d672f169966a60e700545f/core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp#L46-L58) - [Stack push validation](https://github.com/boykopovar/AnyPS5/blob/bb5cb12d6f62757230d672f169966a60e700545f/core/libs/prx/libSceLibreSsl3/src/Stack.cpp#L113-L145) - [Changed malformed-stack test](https://github.com/boykopovar/AnyPS5/blob/bb5cb12d6f62757230d672f169966a60e700545f/core/libs/prx/libSceLibreSsl3/tests/SslCtxChainCerts.cpp#L264-L270) ## Not verified Build and test results, console behavior, and behavior on other operating systems were not verified. All eight changed files listed in the manifest were read; no changed files were excluded.
PrivacyOnion commented 2026-11-20 10:25:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-20T10:25:48Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 76a220d0cc:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libressl3_ssl_ctx_chain_certs_tests built cleanly.
  • CTest (guest_libressl3_ssl_ctx_chain_certs):
    1/1 Test #4651: guest_libressl3_ssl_ctx_chain_certs ...   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceLibreSsl3/Export.cpp, core/libs/prx/libSceLibreSsl3/include/Api.hpp, core/libs/prx/libSceLibreSsl3/include/X509.hpp, core/libs/prx/libSceLibreSsl3/src/X509StoreLoadLocations.cpp, core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp: verified SSL_CTX_add0_chain_cert_nid_postfix correctly implements LibreSSL add0 semantics by appending certificate without incrementing references, retaining caller ownership on failure, and freeing newly created stacks on failure.
    • core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp: verified SSL_CTX_clear_chain_certs_nid_postfix checks stack metadata (num, numAlloc, data pointer consistency) before iteration and safely frees stack elements and stack structure.
    • core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp: verified ReleaseCertificate decrements reference counts with std::atomic_ref acq_rel and delegates to FreeCertificate_nid_no_patch upon reaching zero references.
    • core/libs/prx/libSceLibreSsl3/src/X509StoreLoadLocations.cpp: verified FreeCertificate_nid_no_patch properly deallocates internal X509 structures (certInfo, sigAlg, signature) before freeing outer allocation.
    • core/libs/prx/libSceLibreSsl3/tests/SslCtxChainCerts.cpp: verified unit test coverage across null context/cert pointers, multi-element growth, memory exhaustion/allocation failure, malformed stack bounds, and deep sub-allocation destruction.
    • docs/dev/debt/changes/feat-libressl3-ssl-ctx-chain-certs.md & AGENTS.md: verified technical debt fragment adheres to required format and code contains no illegal comments.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5991155666 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029#pullrequestreview-5991155666). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-20T10:25:48Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `76a220d0cc`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_libressl3_ssl_ctx_chain_certs_tests` built cleanly. - **CTest** (`guest_libressl3_ssl_ctx_chain_certs`): ``` 1/1 Test #4651: guest_libressl3_ssl_ctx_chain_certs ... Passed 0.02 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceLibreSsl3/Export.cpp`, `core/libs/prx/libSceLibreSsl3/include/Api.hpp`, `core/libs/prx/libSceLibreSsl3/include/X509.hpp`, `core/libs/prx/libSceLibreSsl3/src/X509StoreLoadLocations.cpp`, `core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp: verified SSL_CTX_add0_chain_cert_nid_postfix correctly implements LibreSSL add0 semantics by appending certificate without incrementing references, retaining caller ownership on failure, and freeing newly created stacks on failure. - core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp: verified SSL_CTX_clear_chain_certs_nid_postfix checks stack metadata (num, numAlloc, data pointer consistency) before iteration and safely frees stack elements and stack structure. - core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp: verified ReleaseCertificate decrements reference counts with std::atomic_ref acq_rel and delegates to FreeCertificate_nid_no_patch upon reaching zero references. - core/libs/prx/libSceLibreSsl3/src/X509StoreLoadLocations.cpp: verified FreeCertificate_nid_no_patch properly deallocates internal X509 structures (certInfo, sigAlg, signature) before freeing outer allocation. - core/libs/prx/libSceLibreSsl3/tests/SslCtxChainCerts.cpp: verified unit test coverage across null context/cert pointers, multi-element growth, memory exhaustion/allocation failure, malformed stack bounds, and deep sub-allocation destruction. - docs/dev/debt/changes/feat-libressl3-ssl-ctx-chain-certs.md & AGENTS.md: verified technical debt fragment adheres to required format and code contains no illegal comments. Looks Good To Me
MarcZX10 commented 2026-11-20 10:37:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T10:37:22Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: update extraCerts through the guest-memory validation and copy helpers so these entry points safely handle guest context pointers.

What I ran

Reviewed head 76a220d0cc82b9a5a043fe81425cb55338493550. No commands or tests were run; I used the pinned repo_read.py reader to inspect the prepared diff and source context.

Results

Check Result Note
Diff and changed files passed All eight changed files read
Targeted source context passed Stack, certificate cleanup, and context layout inspected
Tests not run No build or test command was run
Console behavior not run No console validation performed

Findings

Blocking

  • core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:25 — The functions directly dereference the caller-provided context, certificate, stack, and certificate fields. In this guest ABI, callers provide guest addresses; nearby SSL context code validates/copies guest memory before accessing fields, and sk_push_nid_postfix does so for its stack argument. A bad or unmapped context/certificate pointer can therefore fault the host process instead of returning a failure or following the project’s invalid-guest-pointer handling. Apply the guest-memory checks/copy-in/copy-out pattern to the context and certificate accesses (and the chain elements during clear) before modifying or releasing them.

Non-blocking

None.

Not verified

  • No build, automated tests, or console run was performed.
  • All files listed as reviewed in the manifest were read: core/libs/prx/libSceLibreSsl3/CMakeLists.txt, core/libs/prx/libSceLibreSsl3/Export.cpp, core/libs/prx/libSceLibreSsl3/include/Api.hpp, core/libs/prx/libSceLibreSsl3/include/X509.hpp, core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp, core/libs/prx/libSceLibreSsl3/src/X509StoreLoadLocations.cpp, core/libs/prx/libSceLibreSsl3/tests/SslCtxChainCerts.cpp, and docs/dev/debt/changes/feat-libressl3-ssl-ctx-chain-certs.md. No changed files were excluded by the manifest.

To get this to a good state

Update the new entry points to validate and safely copy guest context, certificate, stack, and chain-element data before access or mutation. Then run the new chain-certificate test and relevant build checks on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5991286416 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029#pullrequestreview-5991286416). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T10:37:22Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: update `extraCerts` through the guest-memory validation and copy helpers so these entry points safely handle guest context pointers. ## What I ran Reviewed head `76a220d0cc82b9a5a043fe81425cb55338493550`. No commands or tests were run; I used the pinned `repo_read.py` reader to inspect the prepared diff and source context. ## Results | Check | Result | Note | |---|---|---| | Diff and changed files | passed | All eight changed files read | | Targeted source context | passed | Stack, certificate cleanup, and context layout inspected | | Tests | not run | No build or test command was run | | Console behavior | not run | No console validation performed | ## Findings ### Blocking - `core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:25` — The functions directly dereference the caller-provided `context`, `certificate`, stack, and certificate fields. In this guest ABI, callers provide guest addresses; nearby SSL context code validates/copies guest memory before accessing fields, and `sk_push_nid_postfix` does so for its stack argument. A bad or unmapped context/certificate pointer can therefore fault the host process instead of returning a failure or following the project’s invalid-guest-pointer handling. Apply the guest-memory checks/copy-in/copy-out pattern to the context and certificate accesses (and the chain elements during clear) before modifying or releasing them. ### Non-blocking None. ## Not verified - No build, automated tests, or console run was performed. - All files listed as reviewed in the manifest were read: `core/libs/prx/libSceLibreSsl3/CMakeLists.txt`, `core/libs/prx/libSceLibreSsl3/Export.cpp`, `core/libs/prx/libSceLibreSsl3/include/Api.hpp`, `core/libs/prx/libSceLibreSsl3/include/X509.hpp`, `core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp`, `core/libs/prx/libSceLibreSsl3/src/X509StoreLoadLocations.cpp`, `core/libs/prx/libSceLibreSsl3/tests/SslCtxChainCerts.cpp`, and `docs/dev/debt/changes/feat-libressl3-ssl-ctx-chain-certs.md`. No changed files were excluded by the manifest. ## To get this to a good state Update the new entry points to validate and safely copy guest context, certificate, stack, and chain-element data before access or mutation. Then run the new chain-certificate test and relevant build checks on the updated head.
PrivacyOnion commented 2026-11-20 11:09:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-20T11:09:12Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libressl3_ssl_ctx_chain_certs_tests built cleanly.
  • CTest (guest_libressl3_ssl_ctx_chain_certs):
    1/1 Test #4652: guest_libressl3_ssl_ctx_chain_certs ...   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceLibreSsl3/Export.cpp, core/libs/prx/libSceLibreSsl3/include/Api.hpp, core/libs/prx/libSceLibreSsl3/include/X509.hpp, core/libs/prx/libSceLibreSsl3/src/X509StoreLoadLocations.cpp, core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.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_CTX_add0_chain_cert_nid_postfix correctly implements OpenSSL/LibreSSL add0 semantics by taking ownership on success without refcount increment, and leaving ownership with caller on failure.
    • Verified LibreSslCtx offset static_assert(offsetof(LibreSslCtx, extraCerts) == 40) ensures layout alignment matching parent context, resolving verifyMode collision.
    • Verified SSL_CTX_clear_chain_certs_nid_postfix stack validation (num < 0, num > numAlloc, null data array check) and atomic refcount decrements in ReleaseCertificate and FreeCertificate_nid_no_patch.
    • Verified guest memory safety checks using GuestCopyIn_nid_no_patch, GuestWritable_nid_no_patch, and GuestCopyOut_nid_no_patch across context, stack, and certificate references.
    • Verified test coverage in SslCtxChainCerts.cpp exercises null pointer inputs, stack growth/realloc, allocation failure rollback, exception handling, and layout independence.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5991720889 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029#pullrequestreview-5991720889). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-20T11:09:12Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `c96fe83c94`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_libressl3_ssl_ctx_chain_certs_tests` built cleanly. - **CTest** (`guest_libressl3_ssl_ctx_chain_certs`): ``` 1/1 Test #4652: guest_libressl3_ssl_ctx_chain_certs ... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceLibreSsl3/Export.cpp`, `core/libs/prx/libSceLibreSsl3/include/Api.hpp`, `core/libs/prx/libSceLibreSsl3/include/X509.hpp`, `core/libs/prx/libSceLibreSsl3/src/X509StoreLoadLocations.cpp`, `core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.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_CTX_add0_chain_cert_nid_postfix correctly implements OpenSSL/LibreSSL add0 semantics by taking ownership on success without refcount increment, and leaving ownership with caller on failure. - Verified LibreSslCtx offset static_assert(offsetof(LibreSslCtx, extraCerts) == 40) ensures layout alignment matching parent context, resolving verifyMode collision. - Verified SSL_CTX_clear_chain_certs_nid_postfix stack validation (num < 0, num > numAlloc, null data array check) and atomic refcount decrements in ReleaseCertificate and FreeCertificate_nid_no_patch. - Verified guest memory safety checks using GuestCopyIn_nid_no_patch, GuestWritable_nid_no_patch, and GuestCopyOut_nid_no_patch across context, stack, and certificate references. - Verified test coverage in SslCtxChainCerts.cpp exercises null pointer inputs, stack growth/realloc, allocation failure rollback, exception handling, and layout independence. Looks Good To Me
MarcZX10 commented 2026-11-20 11:16:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T11:16:39Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: prevent certificate destruction when references is zero or negative.

What I ran

Reviewed head c96fe83c940bea0f8aa5035915ef9b6e4dcf8f43 using the prepared patch and repo_read.py source reads. No build or tests were run. The author reports checks in the PR description; those results were not independently run.

Results

Check Result Note
Patch and changed-file source review passed All 8 changed files read
Build and tests not run No execution performed
Author-reported checks not run Not independently verified

Findings

Blocking

  • core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:25: fetch_sub(1) <= 1 destroys the certificate for any initial reference count of zero or less. A zero count underflows and frees the certificate; a negative count is also decremented and freed. Guard against nonpositive counts before decrementing, and free only when a valid positive count reaches zero. Otherwise a malformed or already-released certificate in the context chain can cause premature destruction or a double free.

Non-blocking

None.

Not verified

No tests, build, console behavior, or author-reported checks were run. The prepared bundle includes full text for all 8 changed files, and each changed file was read; no files were excluded according to the manifest.

To get this to a good state

Correct the reference-count handling in ReleaseCertificate so nonpositive counts cannot be decremented or freed, then rerun the relevant tests and build on the new head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5991831984 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029#pullrequestreview-5991831984). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T11:16:39Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: prevent certificate destruction when `references` is zero or negative. ## What I ran Reviewed head `c96fe83c940bea0f8aa5035915ef9b6e4dcf8f43` using the prepared patch and `repo_read.py` source reads. No build or tests were run. The author reports checks in the PR description; those results were not independently run. ## Results | Check | Result | Note | |---|---|---| | Patch and changed-file source review | passed | All 8 changed files read | | Build and tests | not run | No execution performed | | Author-reported checks | not run | Not independently verified | ## Findings ### Blocking - `core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:25`: `fetch_sub(1) <= 1` destroys the certificate for any initial reference count of zero or less. A zero count underflows and frees the certificate; a negative count is also decremented and freed. Guard against nonpositive counts before decrementing, and free only when a valid positive count reaches zero. Otherwise a malformed or already-released certificate in the context chain can cause premature destruction or a double free. ### Non-blocking None. ## Not verified No tests, build, console behavior, or author-reported checks were run. The prepared bundle includes full text for all 8 changed files, and each changed file was read; no files were excluded according to the manifest. ## To get this to a good state Correct the reference-count handling in `ReleaseCertificate` so nonpositive counts cannot be decremented or freed, then rerun the relevant tests and build on the new head.
MarcZX10 commented 2026-11-20 11:38:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T11:38:15Z.

Review: COMMENTED


Reviewed — no blocking findings

The implementation appears sound in the inspected code, but tests and build checks were not run in this reader-only review environment.

What I ran

Reviewed head 0d69f5119e62104836ee9acacf6e2daaa412931f. Inspected the prepared diff and changed lines, plus the stack helpers and related type definitions at the pinned head. No commands or tests were run.

Results

Check Result Note
Code review passed Changed lines and relevant helpers inspected
Build and tests not run No command execution available
Negative control not run Could not run tests

Findings

Blocking

None.

Non-blocking

None.

Sources

Reviewed core/libs/prx/libSceLibreSsl3/CMakeLists.txt, Export.cpp, include/Api.hpp, include/X509.hpp, src/SslCtxChainCerts.cpp, src/X509StoreLoadLocations.cpp, tests/SslCtxChainCerts.cpp, and docs/dev/debt/changes/feat-libressl3-ssl-ctx-chain-certs.md. No changed files were excluded.

Not verified

Build and test results, console behavior, and the author's reported convention, debt-fold, and PR-overlap checks were not independently verified.

To get this to a good state

Nothing is required. Optional: run the new guest_libressl3_ssl_ctx_chain_certs test and relevant build checks.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5992069817 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029#pullrequestreview-5992069817). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T11:38:15Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The implementation appears sound in the inspected code, but tests and build checks were not run in this reader-only review environment. ## What I ran Reviewed head `0d69f5119e62104836ee9acacf6e2daaa412931f`. Inspected the prepared diff and changed lines, plus the stack helpers and related type definitions at the pinned head. No commands or tests were run. ## Results | Check | Result | Note | |---|---|---| | Code review | passed | Changed lines and relevant helpers inspected | | Build and tests | not run | No command execution available | | Negative control | not run | Could not run tests | ## Findings ### Blocking None. ### Non-blocking None. ## Sources Reviewed `core/libs/prx/libSceLibreSsl3/CMakeLists.txt`, `Export.cpp`, `include/Api.hpp`, `include/X509.hpp`, `src/SslCtxChainCerts.cpp`, `src/X509StoreLoadLocations.cpp`, `tests/SslCtxChainCerts.cpp`, and `docs/dev/debt/changes/feat-libressl3-ssl-ctx-chain-certs.md`. No changed files were excluded. ## Not verified Build and test results, console behavior, and the author's reported convention, debt-fold, and PR-overlap checks were not independently verified. ## To get this to a good state Nothing is required. Optional: run the new `guest_libressl3_ssl_ctx_chain_certs` test and relevant build checks.
PrivacyOnion commented 2026-11-20 11:44:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-20T11:44:38Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 0d69f5119e:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libressl3_ssl_ctx_chain_certs_tests built cleanly.
  • CTest (guest_libressl3_ssl_ctx_chain_certs):
    1/1 Test #4653: guest_libressl3_ssl_ctx_chain_certs ...   Passed    0.03 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceLibreSsl3/Export.cpp, core/libs/prx/libSceLibreSsl3/include/Api.hpp, core/libs/prx/libSceLibreSsl3/include/X509.hpp, core/libs/prx/libSceLibreSsl3/src/X509StoreLoadLocations.cpp, core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.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_CTX_add0_chain_cert_nid_postfix correctly validates guest memory and context/certificate pointers, creates stack on demand, handles sk_push failures and cleans up on error while keeping add0 semantics (SslCtxChainCerts.cpp:40-79).
    • Verified SSL_CTX_clear_chain_certs_nid_postfix bounds checks stackCopy (num >= 0, numAlloc >= 0, num <= numAlloc, non-null data when num > 0) and releases all chain certificates before freeing stack and clearing context->extraCerts (SslCtxChainCerts.cpp:81-120).
    • Verified ReleaseCertificate atomic reference counting correctly protects against decrementing non-positive refcounts and safely invokes FreeCertificate_nid_no_patch when expected refcount drops from 1 to 0 (SslCtxChainCerts.cpp:15-34).
    • Verified context offset alignment with LibreSslCtx extraCerts at offset 40 (static_assert at SslCtxChainCerts.cpp:11) and preservation of verifyMode.
    • Verified AGENTS.md conventions, including technical debt documentation fragment in docs/dev/debt/changes/feat-libressl3-ssl-ctx-chain-certs.md and absence of illegal comments or unverified assumptions.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5992139994 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029#pullrequestreview-5992139994). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-20T11:44:38Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `0d69f5119e`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_libressl3_ssl_ctx_chain_certs_tests` built cleanly. - **CTest** (`guest_libressl3_ssl_ctx_chain_certs`): ``` 1/1 Test #4653: guest_libressl3_ssl_ctx_chain_certs ... Passed 0.03 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceLibreSsl3/Export.cpp`, `core/libs/prx/libSceLibreSsl3/include/Api.hpp`, `core/libs/prx/libSceLibreSsl3/include/X509.hpp`, `core/libs/prx/libSceLibreSsl3/src/X509StoreLoadLocations.cpp`, `core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.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_CTX_add0_chain_cert_nid_postfix correctly validates guest memory and context/certificate pointers, creates stack on demand, handles sk_push failures and cleans up on error while keeping add0 semantics (SslCtxChainCerts.cpp:40-79). - Verified SSL_CTX_clear_chain_certs_nid_postfix bounds checks stackCopy (num >= 0, numAlloc >= 0, num <= numAlloc, non-null data when num > 0) and releases all chain certificates before freeing stack and clearing context->extraCerts (SslCtxChainCerts.cpp:81-120). - Verified ReleaseCertificate atomic reference counting correctly protects against decrementing non-positive refcounts and safely invokes FreeCertificate_nid_no_patch when expected refcount drops from 1 to 0 (SslCtxChainCerts.cpp:15-34). - Verified context offset alignment with LibreSslCtx extraCerts at offset 40 (static_assert at SslCtxChainCerts.cpp:11) and preservation of verifyMode. - Verified AGENTS.md conventions, including technical debt documentation fragment in docs/dev/debt/changes/feat-libressl3-ssl-ctx-chain-certs.md and absence of illegal comments or unverified assumptions. Looks Good To Me
MarcZX10 commented 2026-11-21 11:01:01 +00:00 (Migrated from github.com)

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

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: clear the context pointer before releasing its certificates and stack so a release failure cannot leave a dangling pointer.

What I ran

Reviewed head 8c03e3ff7dfe3058af6b36d249e6324595d89ebb using the prepared diff and repo_read.py for targeted source reads. No build or tests were run.

Results

Check Result Note
Diff and targeted source review passed Changed behavior and callers inspected
Build and tests not run No execution environment used

Findings

Blocking

  • core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:108 releases each certificate before clearing context->extraCerts at lines 111–116. If ReleaseCertificate fails while validating a certificate pointer or reference field, NotImplementedAt_nid_no_patch may unwind after earlier certificates were already freed; the context still points to the original stack containing freed entries. A later clear can then access freed memory or release those entries twice. Detach the stack from the context before releasing its entries, and define safe cleanup behavior for failures.

Non-blocking

None.

Not verified

Build, tests, console behavior, and claims in the PR description about convention checks, debt folding, and overlap screening were not independently verified. The review bundle lists six changed files, all marked included; full source was read for SslCtxChainCerts.cpp, X509StoreLoadLocations.cpp, the new tests, and the relevant CMake/header context. Other changed files were reviewed through the diff only. No files were excluded by the manifest.

To get this to a good state

Detach the stack before certificate release, then rerun the chain-certificate tests and relevant build checks on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6004784125 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029#pullrequestreview-6004784125). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T11:01:01Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: clear the context pointer before releasing its certificates and stack so a release failure cannot leave a dangling pointer. ## What I ran Reviewed head `8c03e3ff7dfe3058af6b36d249e6324595d89ebb` using the prepared diff and `repo_read.py` for targeted source reads. No build or tests were run. ## Results | Check | Result | Note | |---|---|---| | Diff and targeted source review | passed | Changed behavior and callers inspected | | Build and tests | not run | No execution environment used | ## Findings ### Blocking - `core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp:108` releases each certificate before clearing `context->extraCerts` at lines 111–116. If `ReleaseCertificate` fails while validating a certificate pointer or reference field, `NotImplementedAt_nid_no_patch` may unwind after earlier certificates were already freed; the context still points to the original stack containing freed entries. A later clear can then access freed memory or release those entries twice. Detach the stack from the context before releasing its entries, and define safe cleanup behavior for failures. ### Non-blocking None. ## Not verified Build, tests, console behavior, and claims in the PR description about convention checks, debt folding, and overlap screening were not independently verified. The review bundle lists six changed files, all marked included; full source was read for `SslCtxChainCerts.cpp`, `X509StoreLoadLocations.cpp`, the new tests, and the relevant CMake/header context. Other changed files were reviewed through the diff only. No files were excluded by the manifest. ## To get this to a good state Detach the stack before certificate release, then rerun the chain-certificate tests and relevant build checks on the updated head.
PrivacyOnion commented 2026-11-21 11:14:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-21T11:14:11Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 8c03e3ff7d:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libressl3_ssl_ctx_chain_certs_tests built cleanly.
  • CTest (guest_libressl3_ssl_ctx_chain_certs):
    1/1 Test #4704: guest_libressl3_ssl_ctx_chain_certs ...   Passed    0.10 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceLibreSsl3/Export.cpp, core/libs/prx/libSceLibreSsl3/include/Api.hpp, core/libs/prx/libSceLibreSsl3/include/X509.hpp, core/libs/prx/libSceLibreSsl3/src/X509StoreLoadLocations.cpp, core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.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_CTX_add0_chain_cert_nid_postfix correctly validates guest context and certificate pointers using GuestCopyIn_nid_no_patch and GuestWritable_nid_no_patch, creates stack on demand, handles push failure by freeing allocated stack and resetting context->extraCerts, and preserves add0 ownership semantics (SslCtxChainCerts.cpp:40-79).
    • Verified SSL_CTX_clear_chain_certs_nid_postfix checks stack bounds (num >= 0, numAlloc >= 0, num <= numAlloc, non-null data when num > 0), releases certificates via ReleaseCertificate, frees stack via sk_free_nid_postfix, and clears context->extraCerts to nullptr (SslCtxChainCerts.cpp:81-120).
    • Verified ReleaseCertificate atomic reference counting and conditional call to FreeCertificate_nid_no_patch when reference drops from 1 to 0 while protecting against non-positive reference values (SslCtxChainCerts.cpp:15-34).
    • Verified struct layout alignment and static_assert(offsetof(LibreSslCtx, extraCerts) == 40) addressing maintainer feedback to avoid overlapping verifyMode (SslCtxChainCerts.cpp:11).
    • Verified AGENTS.md compliance: no comments in source code, technical debt fragment in docs/dev/debt/changes/feat-libressl3-ssl-ctx-chain-certs.md, and comprehensive unit tests covering all edge cases.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6004834067 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029#pullrequestreview-6004834067). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-21T11:14:11Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `8c03e3ff7d`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_libressl3_ssl_ctx_chain_certs_tests` built cleanly. - **CTest** (`guest_libressl3_ssl_ctx_chain_certs`): ``` 1/1 Test #4704: guest_libressl3_ssl_ctx_chain_certs ... Passed 0.10 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceLibreSsl3/Export.cpp`, `core/libs/prx/libSceLibreSsl3/include/Api.hpp`, `core/libs/prx/libSceLibreSsl3/include/X509.hpp`, `core/libs/prx/libSceLibreSsl3/src/X509StoreLoadLocations.cpp`, `core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.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_CTX_add0_chain_cert_nid_postfix correctly validates guest context and certificate pointers using GuestCopyIn_nid_no_patch and GuestWritable_nid_no_patch, creates stack on demand, handles push failure by freeing allocated stack and resetting context->extraCerts, and preserves add0 ownership semantics (SslCtxChainCerts.cpp:40-79). - Verified SSL_CTX_clear_chain_certs_nid_postfix checks stack bounds (num >= 0, numAlloc >= 0, num <= numAlloc, non-null data when num > 0), releases certificates via ReleaseCertificate, frees stack via sk_free_nid_postfix, and clears context->extraCerts to nullptr (SslCtxChainCerts.cpp:81-120). - Verified ReleaseCertificate atomic reference counting and conditional call to FreeCertificate_nid_no_patch when reference drops from 1 to 0 while protecting against non-positive reference values (SslCtxChainCerts.cpp:15-34). - Verified struct layout alignment and static_assert(offsetof(LibreSslCtx, extraCerts) == 40) addressing maintainer feedback to avoid overlapping verifyMode (SslCtxChainCerts.cpp:11). - Verified AGENTS.md compliance: no comments in source code, technical debt fragment in docs/dev/debt/changes/feat-libressl3-ssl-ctx-chain-certs.md, and comprehensive unit tests covering all edge cases. Looks Good To Me
MarcZX10 commented 2026-11-21 12:24:25 +00:00 (Migrated from github.com)

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

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the review found no verified blocking defect.

What I ran

Reviewed head 93092235245197352f5e7f4e62b1c183369d086f using the prepared diff and repo_read.py. No build or tests were run.

Results

Check Result Note
Code review passed Changed code and relevant stack/free routines read
Build and tests not run No commands run

Findings

Blocking

None.

Non-blocking

None.

Not verified

Build/test results and physical-console behavior were not verified. All eight changed files listed in the manifest were read; the manifest lists no exclusions.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6005162043 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029#pullrequestreview-6005162043). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T12:24:25Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the review found no verified blocking defect. ## What I ran Reviewed head `93092235245197352f5e7f4e62b1c183369d086f` using the prepared diff and `repo_read.py`. No build or tests were run. ## Results | Check | Result | Note | |---|---|---| | Code review | passed | Changed code and relevant stack/free routines read | | Build and tests | not run | No commands run | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified Build/test results and physical-console behavior were not verified. All eight changed files listed in the manifest were read; the manifest lists no exclusions. ## To get this to a good state Nothing is required.
PrivacyOnion commented 2026-11-21 12:51:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-21T12:51:29Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libressl3_ssl_ctx_chain_certs_tests built cleanly.
  • CTest (guest_libressl3_ssl_ctx_chain_certs):
    1/1 Test #4730: guest_libressl3_ssl_ctx_chain_certs ...   Passed    0.05 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceLibreSsl3/Export.cpp, core/libs/prx/libSceLibreSsl3/include/Api.hpp, core/libs/prx/libSceLibreSsl3/include/X509.hpp, core/libs/prx/libSceLibreSsl3/src/X509StoreLoadLocations.cpp, core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified struct layout alignment in core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp (static_assert(offsetof(LibreSslCtx, extraCerts) == 40)) and include/X509.hpp (offsetof(LibreSsl3X509, references) == 28), ensuring mutations to extraCerts operate at offset 40 without interfering with verifyMode at offset 48.
    • Verified guest memory safety and bounds validation in SSL_CTX_add0_chain_cert_nid_postfix and SSL_CTX_clear_chain_certs_nid_postfix via GuestCopyIn_nid_no_patch, GuestWritable_nid_no_patch, and GuestCopyOut_nid_no_patch with errno preserved across checks.
    • Verified add0 ownership contract in SSL_CTX_add0_chain_cert_nid_postfix, ensuring callers retain certificate ownership on failure while any freshly created stack on push failure is safely freed via sk_free_nid_postfix and context->extraCerts reset to nullptr.
    • Verified atomic reference counting and deallocation in ReleaseCertificate, guarding nonpositive counts against underflow and invoking FreeCertificate_nid_no_patch via an acquire-release compare-exchange loop when references transition from 1 to 0.
    • Verified exception safety in SSL_CTX_clear_chain_certs_nid_postfix, detaching context->extraCerts to nullptr before releasing certificates and utilizing StackGuard to guarantee sk_free_nid_postfix cleanup even if element releases throw.
    • Verified strict compliance with AGENTS.md rules, including zero unauthorized code comments, valid technical debt fragment in docs/dev/debt/changes/feat-libressl3-ssl-ctx-chain-certs.md, and comprehensive unit tests in tests/SslCtxChainCerts.cpp.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6005296177 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23029#pullrequestreview-6005296177). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-21T12:51:29Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `9309223524`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_libressl3_ssl_ctx_chain_certs_tests` built cleanly. - **CTest** (`guest_libressl3_ssl_ctx_chain_certs`): ``` 1/1 Test #4730: guest_libressl3_ssl_ctx_chain_certs ... Passed 0.05 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceLibreSsl3/Export.cpp`, `core/libs/prx/libSceLibreSsl3/include/Api.hpp`, `core/libs/prx/libSceLibreSsl3/include/X509.hpp`, `core/libs/prx/libSceLibreSsl3/src/X509StoreLoadLocations.cpp`, `core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified struct layout alignment in core/libs/prx/libSceLibreSsl3/src/SslCtxChainCerts.cpp (static_assert(offsetof(LibreSslCtx, extraCerts) == 40)) and include/X509.hpp (offsetof(LibreSsl3X509, references) == 28), ensuring mutations to extraCerts operate at offset 40 without interfering with verifyMode at offset 48. - Verified guest memory safety and bounds validation in SSL_CTX_add0_chain_cert_nid_postfix and SSL_CTX_clear_chain_certs_nid_postfix via GuestCopyIn_nid_no_patch, GuestWritable_nid_no_patch, and GuestCopyOut_nid_no_patch with errno preserved across checks. - Verified add0 ownership contract in SSL_CTX_add0_chain_cert_nid_postfix, ensuring callers retain certificate ownership on failure while any freshly created stack on push failure is safely freed via sk_free_nid_postfix and context->extraCerts reset to nullptr. - Verified atomic reference counting and deallocation in ReleaseCertificate, guarding nonpositive counts against underflow and invoking FreeCertificate_nid_no_patch via an acquire-release compare-exchange loop when references transition from 1 to 0. - Verified exception safety in SSL_CTX_clear_chain_certs_nid_postfix, detaching context->extraCerts to nullptr before releasing certificates and utilizing StackGuard to guarantee sk_free_nid_postfix cleanup even if element releases throw. - Verified strict compliance with AGENTS.md rules, including zero unauthorized code comments, valid technical debt fragment in docs/dev/debt/changes/feat-libressl3-ssl-ctx-chain-certs.md, and comprehensive unit tests in tests/SslCtxChainCerts.cpp. Looks Good To Me
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!23029
No description provided.