feat(libSceLibreSsl): implement SSL_CTX_set_alpn_protos and SSL_CTX_set1_groups_list #11176

Open
ahmadmuj wants to merge 30 commits from upstream-pr/11176 into main
ahmadmuj commented 2026-10-25 20:38:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T20:38:16Z.


What

Adds legacy SSL context ALPN and group-list setters using LibreSSL 2.5.4 behavior.
The group parser now uses main's indexed OBJ_sn2nid lookup before the existing long-name guard and NIST aliases.
Dynamic short-name shadows return 0 and preserve the existing groups. Registered long names still throw when no short name matches.

ALPN keeps the allocation order from ssl_lib.c:1652-1663.
Allocation failure frees the old buffer, sets its pointer to null, and retains its old length.
The regression checks retained lengths 0, 3 and 12. The new case fails a twelve-byte replacement after a three-byte list. It checks the freed buffer, retained length and unchanged remaining fields.

This merge preserves main's new SSL lifecycle implementation and both existing setter bodies. It removes only their adjacent obsolete stubs and the stale debt claim that no export creates a context.

Tested

Ubuntu 24.04.2 on WSL2, GCC 13.3, Release build. Tested source head: b2b6bcefa6ef7f7f8a44ddd3ef3250dafa08b14a.
Merged main: 8490efc08f023fe01c2123aa24e8cb405c3cdb73.

  • 21 focused CPU tests pass: SSL lifecycle, ex-data, contexts, groups, object lookup/allocation, OCSP, PKEY, EC, ASN.1, X509 printing, native key references, and PKEY bits.
  • Groups cover all 29 built-in names, 15 aliases, duplicates, invalid lists, guest/host allocation failures, and dynamic name precedence.
  • The prior old-parser control fails and the restored parser passes. This merge leaves the tested parser source byte-identical; that control is reused, not rerun.
  • Standalone header compilation passes. The header audit covers 413 libraries and 34,725 exports.
  • The unchanged native ImportBinding.cpp passes against a fresh six-module lifecycle fixture, using actual NIDs.
  • Current conventions pass against pinned main and origin/main; debt fragments and the scoped whitespace check pass.

The full product and full test suite are not run. The earlier broad build attempt remains incomplete; it is not repeated here.
The focused targets and the native fixture build successfully. No full product, optional oracle, GPU, console, or title validation is claimed.

Commands (all pass unless noted above)

From the task worktree, with CCACHE_DIR=../../.cache/ccache:

cmake -S . -B ../../builds/align-11176-054 -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DBUILD_TESTING=ON -DANYPS5_LIBRESSL_ORACLE=OFF
flock ../../.git/anyps5-build.lock cmake --build ../../builds/align-11176-054 --target libSceLibreSsl guest_libressl_ssl_ctx_groups_tests guest_libressl_ssl_lifecycle_tests guest_libressl_object_name_tests guest_libressl_object_text_tests guest_libressl_object_allocation_tests guest_libressl_ssl_ctx_tests guest_libressl_ssl_ctx_fields_tests guest_libressl_ssl_ctx_callbacks_tests guest_libressl_ssl_settings_tests guest_libressl_ocsp_tests guest_libressl_ocsp_basic_response_tests guest_libressl_pkey_lifecycle_tests guest_libressl_pkey_rsa_tests guest_libressl_ec_tests guest_libressl_ec_keys_tests guest_libressl_asn1_tests guest_libressl_x509_name_print_ex_tests guest_libressl3_key_reference_tests libressl3_pkey_lifecycle_modules -j 16
flock ../../.git/anyps5-build.lock cmake --build ../../builds/align-11176-054 --target guest_libressl_ex_data_tests -j 8
ctest --test-dir ../../builds/align-11176-054 -R '^(guest_libressl_(ssl_ctx_groups|ssl_lifecycle|ex_data|ssl_ctx|ssl_ctx_fields|ssl_ctx_callbacks|ssl_settings|object_name|object_text|object_allocation|ocsp|ocsp_basic_response|pkey_lifecycle|pkey_rsa|ec|ec_keys|asn1|x509_name_print_ex)(_allocator)?|guest_libressl3_(key_reference|pkey_bits))$' --output-on-failure -j 8
python3 core/libs/tests/test_public_headers.py --compiler g++
g++ -std=c++20 -O2 core/libs/prx/libSceLibreSsl3/tests/ImportBinding.cpp -ldl -o ../../builds/align-11176-054/import-binding-scoped
LD_LIBRARY_PATH=../../builds/align-11176-054/core/libs/prx/libSceLibreSsl3/pkey-lifecycle-libs ../../builds/align-11176-054/import-binding-scoped ../../builds/align-11176-054/core/libs/prx/libSceLibreSsl3/pkey-lifecycle-libs
python3 tools/check_conventions.py --base 8490efc08f023fe01c2123aa24e8cb405c3cdb73
python3 tools/check_conventions.py --base origin/main
python3 tools/debt_fold.py --check
git diff 8490efc08f023fe01c2123aa24e8cb405c3cdb73 HEAD --check

The pinned-main and origin/main conventions checks pass. The earlier parser control applies to the unchanged parser only.
No local Windows, macOS, console, game, oracle or GPU run is claimed for this head.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5008474997 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11176). Originally posted by [ahmadmuj](https://github.com/ahmadmuj) on 2026-10-25T20:38:16Z. --- ### What Adds legacy SSL context ALPN and group-list setters using LibreSSL 2.5.4 behavior. The group parser now uses main's indexed `OBJ_sn2nid` lookup before the existing long-name guard and NIST aliases. Dynamic short-name shadows return 0 and preserve the existing groups. Registered long names still throw when no short name matches. ALPN keeps the allocation order from [ssl_lib.c:1652-1663](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libssl/ssl_lib.c#L1652-L1663). Allocation failure frees the old buffer, sets its pointer to null, and retains its old length. The regression checks retained lengths 0, 3 and 12. The new case fails a twelve-byte replacement after a three-byte list. It checks the freed buffer, retained length and unchanged remaining fields. This merge preserves main's new SSL lifecycle implementation and both existing setter bodies. It removes only their adjacent obsolete stubs and the stale debt claim that no export creates a context. ### Tested Ubuntu 24.04.2 on WSL2, GCC 13.3, Release build. Tested source head: `b2b6bcefa6ef7f7f8a44ddd3ef3250dafa08b14a`. Merged main: `8490efc08f023fe01c2123aa24e8cb405c3cdb73`. - 21 focused CPU tests pass: SSL lifecycle, ex-data, contexts, groups, object lookup/allocation, OCSP, PKEY, EC, ASN.1, X509 printing, native key references, and PKEY bits. - Groups cover all 29 built-in names, 15 aliases, duplicates, invalid lists, guest/host allocation failures, and dynamic name precedence. - The prior old-parser control fails and the restored parser passes. This merge leaves the tested parser source byte-identical; that control is reused, not rerun. - Standalone header compilation passes. The header audit covers 413 libraries and 34,725 exports. - The unchanged native `ImportBinding.cpp` passes against a fresh six-module lifecycle fixture, using actual NIDs. - Current conventions pass against pinned main and `origin/main`; debt fragments and the scoped whitespace check pass. The full product and full test suite are not run. The earlier broad build attempt remains incomplete; it is not repeated here. The focused targets and the native fixture build successfully. No full product, optional oracle, GPU, console, or title validation is claimed. <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> <details> <summary>Commands (all pass unless noted above)</summary> From the task worktree, with `CCACHE_DIR=../../.cache/ccache`: ```sh cmake -S . -B ../../builds/align-11176-054 -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DBUILD_TESTING=ON -DANYPS5_LIBRESSL_ORACLE=OFF flock ../../.git/anyps5-build.lock cmake --build ../../builds/align-11176-054 --target libSceLibreSsl guest_libressl_ssl_ctx_groups_tests guest_libressl_ssl_lifecycle_tests guest_libressl_object_name_tests guest_libressl_object_text_tests guest_libressl_object_allocation_tests guest_libressl_ssl_ctx_tests guest_libressl_ssl_ctx_fields_tests guest_libressl_ssl_ctx_callbacks_tests guest_libressl_ssl_settings_tests guest_libressl_ocsp_tests guest_libressl_ocsp_basic_response_tests guest_libressl_pkey_lifecycle_tests guest_libressl_pkey_rsa_tests guest_libressl_ec_tests guest_libressl_ec_keys_tests guest_libressl_asn1_tests guest_libressl_x509_name_print_ex_tests guest_libressl3_key_reference_tests libressl3_pkey_lifecycle_modules -j 16 flock ../../.git/anyps5-build.lock cmake --build ../../builds/align-11176-054 --target guest_libressl_ex_data_tests -j 8 ctest --test-dir ../../builds/align-11176-054 -R '^(guest_libressl_(ssl_ctx_groups|ssl_lifecycle|ex_data|ssl_ctx|ssl_ctx_fields|ssl_ctx_callbacks|ssl_settings|object_name|object_text|object_allocation|ocsp|ocsp_basic_response|pkey_lifecycle|pkey_rsa|ec|ec_keys|asn1|x509_name_print_ex)(_allocator)?|guest_libressl3_(key_reference|pkey_bits))$' --output-on-failure -j 8 python3 core/libs/tests/test_public_headers.py --compiler g++ g++ -std=c++20 -O2 core/libs/prx/libSceLibreSsl3/tests/ImportBinding.cpp -ldl -o ../../builds/align-11176-054/import-binding-scoped LD_LIBRARY_PATH=../../builds/align-11176-054/core/libs/prx/libSceLibreSsl3/pkey-lifecycle-libs ../../builds/align-11176-054/import-binding-scoped ../../builds/align-11176-054/core/libs/prx/libSceLibreSsl3/pkey-lifecycle-libs python3 tools/check_conventions.py --base 8490efc08f023fe01c2123aa24e8cb405c3cdb73 python3 tools/check_conventions.py --base origin/main python3 tools/debt_fold.py --check git diff 8490efc08f023fe01c2123aa24e8cb405c3cdb73 HEAD --check ``` The pinned-main and origin/main conventions checks pass. The earlier parser control applies to the unchanged parser only. No local Windows, macOS, console, game, oracle or GPU run is claimed for this head. </details> ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
MarcZX10 commented 2026-10-25 20:43:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T20:43:52Z.

Review: COMMENTED


I reviewed head c0bac5f985ab8663d50e81dffc75805f67905244. The ALPN setter's inverted return value and allocation-failure state match the cited 2.5.4 behavior; the group-list path keeps the old allocation until parsing and allocation succeed, and preserves order/duplicates. The test harness covers these behaviors and failure injection. I did not find a concrete functional issue in the changed code.

Independent checks here: conventions, git diff --check upstream/main...HEAD, and C++20 syntax compilation of SslCtxSettings.cpp and GuestLibreSslSslCtxGroups.cpp passed. I could not run the guest test binary here; the PR reports a LibreSSL differential and 15 focused suites passing. Hosted eligibility, conventions, intake, labels, and report checks passed; product build jobs were skipped.

One integration item to coordinate: #11138 is open and clean, but the declared #10508 dependency is still open and currently labeled needs rebase with merge state DIRTY. Please keep the stack aligned with #10508's eventual rebased head before merging this dependent change. I’m leaving a comment-only review pending that integration and independent runtime/build evidence.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5645179981 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11176#pullrequestreview-5645179981). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T20:43:52Z. **Review:** COMMENTED --- I reviewed head `c0bac5f985ab8663d50e81dffc75805f67905244`. The ALPN setter's inverted return value and allocation-failure state match the cited 2.5.4 behavior; the group-list path keeps the old allocation until parsing and allocation succeed, and preserves order/duplicates. The test harness covers these behaviors and failure injection. I did not find a concrete functional issue in the changed code. Independent checks here: conventions, `git diff --check upstream/main...HEAD`, and C++20 syntax compilation of `SslCtxSettings.cpp` and `GuestLibreSslSslCtxGroups.cpp` passed. I could not run the guest test binary here; the PR reports a LibreSSL differential and 15 focused suites passing. Hosted eligibility, conventions, intake, labels, and report checks passed; product build jobs were skipped. One integration item to coordinate: #11138 is open and clean, but the declared #10508 dependency is still open and currently labeled `needs rebase` with merge state `DIRTY`. Please keep the stack aligned with #10508's eventual rebased head before merging this dependent change. I’m leaving a comment-only review pending that integration and independent runtime/build evidence.
thepoppfish commented 2026-10-25 21:17:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thepoppfish on 2026-10-25T21:17:24Z.

Review: CHANGES_REQUESTED


Found one reproducible allocation-failure mismatch on exact head c0bac5f985ab8663d50e81dffc75805f67905244: SSL_CTX_set1_groups_list can let std::bad_alloc escape from its parser instead of returning 0.

For the minimal valid list "X25519", failing the first host operator new reaches groups.push_back, throws out of the export, and never calls the guest allocator. Failing std::string allocation for a long unknown name does the same. Thus the existing failAllocation guest-heap check does not cover these paths. The old group pointer/length and bytes survive, but the documented error return does not.

The pinned LibreSSL 2.5.4 implementation explicitly returns 0 when strdup or reallocarray fails, preserving the previous list. Please convert parser allocation failure to that result. The patch below catches std::bad_alloc around the parser only, after the existing null/context checks and before allocating/committing the new guest list. It leaves the deliberate invalid-argument throws in place.

Independent Windows 11 build 26200 / MSYS2 UCRT64 GCC 16.2.0 validation:

  • Built complete production SslCtxSettings.cpp, Objects.cpp and ApplicationHeap.cpp. Current and patched variants use the same toolchain and real registered application-heap callbacks. The fault probe overrides host operator new in the same executable/runtime and arms it only during the export call.
  • Five no-fault inputs: a single curve, all 29 supported curves, duplicates, a 128-character unknown name and valid-then-unknown. Enumerated all 14 actual parser allocations across those inputs and failed each separately. Current: 14 escaped bad_alloc exceptions; candidate: 14 returns of 0, unchanged full internal/context bytes and old list contents, zero tracked live scratch allocations and no guest allocation leaks. Also tested final guest allocation failure on all three valid lists.
  • Both variants pass the complete unchanged committed GuestLibreSslSslCtxGroups.cpp fixture. External CTest 4/4 passed, 0.18 s (current fixture, patched fixture, current no-fault controls, patched fault matrix). The unchanged current fault matrix is a separate expected exit-1 negative control; it is not counted as passing.
  • Candidate committed locally as 74a468b65cbd86f87b2114be96cd33eebe6a730a; conventions against local origin/main 2f506cacac52cc58887236582b96338c5ad51f62 and whitespace checks pass. No fork branch or competing PR was published.

Scope: this is a focused native executable, not the full shared-library build/15-test suite. The external malloc/free boundary forwards to real ApplicationHeap; its malloc wrapper translates bad_alloc/length_error to errno 12/null, matching FileAndHeap's custom-heap path. Unused default-heap/process lookups throw if called. No group parser, object lookup, application-heap registration or failure assertion is replaced. I did not run a complete upstream LibreSSL binary, PS5 hardware, a title, Linux or macOS. #11138/#10508 integration/order still needs its own resolution. AI-assisted: yes.

Tested patch
--- a/core/libs/prx/libSceLibreSsl/src/SslCtxSettings.cpp
+++ b/core/libs/prx/libSceLibreSsl/src/SslCtxSettings.cpp
@@ -4,6 +4,7 @@
 #include <cstddef>
 #include <cstdint>
 #include <cstring>
+#include <new>
 #include <stdexcept>
 #include <string>
 #include <string_view>
@@ -70,19 +71,23 @@
     LibreSslCtxInternal& internal = Internal(ctx, __func__);
     if (!list) throw std::invalid_argument(std::string(__func__) + ": null group list");
     std::vector<std::uint16_t> groups;
-    const std::string_view names = list;
-    std::size_t start = 0;
-    while (true) {
-        const std::size_t end = names.find(':', start);
-        const std::string name(names.substr(start, end == std::string_view::npos ? std::string_view::npos : end - start));
-        int nid = OBJ_sn2nid_nid_postfix(name.c_str());
-        if (!nid) nid = NistCurveNid(name);
-        if (!nid) return 0;
-        const std::uint16_t group = CurveId(nid);
-        if (!group) return 0;
-        groups.push_back(group);
-        if (end == std::string_view::npos) break;
-        start = end + 1;
+    try {
+        const std::string_view names = list;
+        std::size_t start = 0;
+        while (true) {
+            const std::size_t end = names.find(':', start);
+            const std::string name(names.substr(start, end == std::string_view::npos ? std::string_view::npos : end - start));
+            int nid = OBJ_sn2nid_nid_postfix(name.c_str());
+            if (!nid) nid = NistCurveNid(name);
+            if (!nid) return 0;
+            const std::uint16_t group = CurveId(nid);
+            if (!group) return 0;
+            groups.push_back(group);
+            if (end == std::string_view::npos) break;
+            start = end + 1;
+        }
+    } catch (const std::bad_alloc&) {
+        return 0;
     }
     auto* result = static_cast<std::uint16_t*>(malloc_nid_postfix(groups.size() * sizeof(std::uint16_t)));
     if (!result) return 0;

Raw fault matrix (current then candidate)
{"variant": "current-fault-negative-control", "exit_code": 1}
{"input":"single","fail_at":-1,"host_calls":1,"guest_calls":1,"threw_bad_alloc":false,"result":1,"old_state_kept":false,"leaked":false}
{"input":"single","fail_at":0,"host_calls":1,"guest_calls":0,"threw_bad_alloc":true,"result":-999,"old_state_kept":true,"leaked":false}
{"input":"single","fail_at":-2,"host_calls":1,"guest_calls":1,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false}
{"input":"all-29","fail_at":-1,"host_calls":6,"guest_calls":1,"threw_bad_alloc":false,"result":1,"old_state_kept":false,"leaked":false}
{"input":"all-29","fail_at":0,"host_calls":1,"guest_calls":0,"threw_bad_alloc":true,"result":-999,"old_state_kept":true,"leaked":false}
{"input":"all-29","fail_at":1,"host_calls":2,"guest_calls":0,"threw_bad_alloc":true,"result":-999,"old_state_kept":true,"leaked":false}
{"input":"all-29","fail_at":2,"host_calls":3,"guest_calls":0,"threw_bad_alloc":true,"result":-999,"old_state_kept":true,"leaked":false}
{"input":"all-29","fail_at":3,"host_calls":4,"guest_calls":0,"threw_bad_alloc":true,"result":-999,"old_state_kept":true,"leaked":false}
{"input":"all-29","fail_at":4,"host_calls":5,"guest_calls":0,"threw_bad_alloc":true,"result":-999,"old_state_kept":true,"leaked":false}
{"input":"all-29","fail_at":5,"host_calls":6,"guest_calls":0,"threw_bad_alloc":true,"result":-999,"old_state_kept":true,"leaked":false}
{"input":"all-29","fail_at":-2,"host_calls":6,"guest_calls":1,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false}
{"input":"duplicates","fail_at":-1,"host_calls":4,"guest_calls":1,"threw_bad_alloc":false,"result":1,"old_state_kept":false,"leaked":false}
{"input":"duplicates","fail_at":0,"host_calls":1,"guest_calls":0,"threw_bad_alloc":true,"result":-999,"old_state_kept":true,"leaked":false}
{"input":"duplicates","fail_at":1,"host_calls":2,"guest_calls":0,"threw_bad_alloc":true,"result":-999,"old_state_kept":true,"leaked":false}
{"input":"duplicates","fail_at":2,"host_calls":3,"guest_calls":0,"threw_bad_alloc":true,"result":-999,"old_state_kept":true,"leaked":false}
{"input":"duplicates","fail_at":3,"host_calls":4,"guest_calls":0,"threw_bad_alloc":true,"result":-999,"old_state_kept":true,"leaked":false}
{"input":"duplicates","fail_at":-2,"host_calls":4,"guest_calls":1,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false}
{"input":"invalid-long","fail_at":-1,"host_calls":1,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false}
{"input":"invalid-long","fail_at":0,"host_calls":1,"guest_calls":0,"threw_bad_alloc":true,"result":-999,"old_state_kept":true,"leaked":false}
{"input":"valid-then-invalid","fail_at":-1,"host_calls":2,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false}
{"input":"valid-then-invalid","fail_at":0,"host_calls":1,"guest_calls":0,"threw_bad_alloc":true,"result":-999,"old_state_kept":true,"leaked":false}
{"input":"valid-then-invalid","fail_at":1,"host_calls":2,"guest_calls":0,"threw_bad_alloc":true,"result":-999,"old_state_kept":true,"leaked":false}
{"failures":14,"live_host":0,"live_guest":0}
{"variant": "fixed-fault-details", "exit_code": 0}
{"input":"single","fail_at":-1,"host_calls":1,"guest_calls":1,"threw_bad_alloc":false,"result":1,"old_state_kept":false,"leaked":false}
{"input":"single","fail_at":0,"host_calls":1,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false}
{"input":"single","fail_at":-2,"host_calls":1,"guest_calls":1,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false}
{"input":"all-29","fail_at":-1,"host_calls":6,"guest_calls":1,"threw_bad_alloc":false,"result":1,"old_state_kept":false,"leaked":false}
{"input":"all-29","fail_at":0,"host_calls":1,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false}
{"input":"all-29","fail_at":1,"host_calls":2,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false}
{"input":"all-29","fail_at":2,"host_calls":3,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false}
{"input":"all-29","fail_at":3,"host_calls":4,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false}
{"input":"all-29","fail_at":4,"host_calls":5,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false}
{"input":"all-29","fail_at":5,"host_calls":6,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false}
{"input":"all-29","fail_at":-2,"host_calls":6,"guest_calls":1,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false}
{"input":"duplicates","fail_at":-1,"host_calls":4,"guest_calls":1,"threw_bad_alloc":false,"result":1,"old_state_kept":false,"leaked":false}
{"input":"duplicates","fail_at":0,"host_calls":1,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false}
{"input":"duplicates","fail_at":1,"host_calls":2,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false}
{"input":"duplicates","fail_at":2,"host_calls":3,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false}
{"input":"duplicates","fail_at":3,"host_calls":4,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false}
{"input":"duplicates","fail_at":-2,"host_calls":4,"guest_calls":1,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false}
{"input":"invalid-long","fail_at":-1,"host_calls":1,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false}
{"input":"invalid-long","fail_at":0,"host_calls":1,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false}
{"input":"valid-then-invalid","fail_at":-1,"host_calls":2,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false}
{"input":"valid-then-invalid","fail_at":0,"host_calls":1,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false}
{"input":"valid-then-invalid","fail_at":1,"host_calls":2,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false}
{"failures":0,"live_host":0,"live_guest":0}
Complete focused harness and replay

Place review-11176 and native-groups11176 beside each other; save the three files below under native-groups11176. With Git, MinGW GCC, CMake and Ninja on PATH:

git clone --no-checkout https://github.com/boykopovar/AnyPS5.git review-11176
git -C review-11176 checkout --detach c0bac5f985ab8663d50e81dffc75805f67905244

Save a copy of production SslCtxSettings.cpp as native-groups11176/FixedSettings.cpp and apply the patch above to that copy only. Keep the original checkout untouched. Then:

cmake -S native-groups11176 -B native-groups11176/build -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build native-groups11176/build -j 4
ctest --test-dir native-groups11176/build --output-on-failure -V
./native-groups11176/build/current_probe.exe faults
./native-groups11176/build/fixed_probe.exe faults

The current fault probe should exit 1 with 14 failures; the patched one should exit 0. CTest cases have 8 s timeouts. All logs are JSON lines with the injected allocation index, host/guest call counts, return/exception and preserved-state/leak assertions.

CMakeLists.txt

cmake_minimum_required(VERSION 3.20)
project(GroupsAllocationReview LANGUAGES CXX)
get_filename_component(DEFAULT_REPO "${CMAKE_CURRENT_LIST_DIR}/../review-11176" ABSOLUTE)
set(REPO "${DEFAULT_REPO}" CACHE PATH "Exact author checkout")
enable_testing()
foreach(variant IN ITEMS current fixed)
    if(variant STREQUAL current)
        set(source "${REPO}/core/libs/prx/libSceLibreSsl/src/SslCtxSettings.cpp")
    else()
        set(source "${CMAKE_CURRENT_LIST_DIR}/FixedSettings.cpp")
    endif()
    foreach(kind IN ITEMS author probe)
        if(kind STREQUAL author)
            set(entry "${REPO}/core/libs/tests/GuestLibreSslSslCtxGroups.cpp")
        else()
            set(entry "${CMAKE_CURRENT_LIST_DIR}/Probe.cpp")
        endif()
        add_executable(${variant}_${kind} "${entry}" Support.cpp "${source}" "${REPO}/core/libs/prx/libSceLibreSsl/src/Objects.cpp" "${REPO}/core/libs/prx/libc/src/ApplicationHeap.cpp")
        target_compile_features(${variant}_${kind} PRIVATE cxx_std_20)
        target_compile_options(${variant}_${kind} PRIVATE -O1 -g -fno-inline -fno-lto -ffunction-sections -fdata-sections)
        target_include_directories(${variant}_${kind} PRIVATE "${REPO}/core/libs")
        target_link_options(${variant}_${kind} PRIVATE -static-libstdc++ -static-libgcc -Wl,--gc-sections)
        add_custom_command(TARGET ${variant}_${kind} POST_BUILD COMMAND "${CMAKE_OBJCOPY}" --rename-section .eh_frame=.ehfram --rename-section .eh_fram=.ehfram "$<TARGET_FILE:${variant}_${kind}>" VERBATIM)
    endforeach()
    add_test(NAME ${variant}_author COMMAND ${variant}_author)
    set_tests_properties(${variant}_author PROPERTIES TIMEOUT 8)
endforeach()
add_test(NAME current_no_fault COMMAND current_probe nofault)
add_test(NAME fixed_allocation_faults COMMAND fixed_probe faults)
set_tests_properties(current_no_fault fixed_allocation_faults PROPERTIES TIMEOUT 8)

Support.cpp

#include "prx/libc/include/ApplicationHeap.hpp"
#include "prx/libc/include/GuestHeap.hpp"
#include "prx/libc/include/General.hpp"
#include "prx/libc/include/Api.hpp"
#include <cerrno>
#include <new>
#include <stdexcept>

extern "C" void* APS5_VABI malloc_nid_postfix(std::size_t bytes) {
    try { return ApplicationHeapAllocate_nid_no_patch(bytes); }
    catch (const std::bad_alloc&) {}
    catch (const std::length_error&) {}
    errno = 12;
    return nullptr;
}
extern "C" void APS5_VABI free_nid_postfix(void* pointer) { ApplicationHeapFree_nid_no_patch(pointer); }
extern "C" const void* ApplicationProcessParameters_nid_no_patch() { throw std::runtime_error("unexpected process parameter lookup"); }
extern "C" bool ApplicationGuestHeapApi_nid_no_patch(void**) { throw std::runtime_error("unexpected guest API lookup"); }
extern "C" [[noreturn]] void NotImplemented_nid_no_patch(const char* name) { throw std::runtime_error(name); }
namespace GuestHeap {
extern "C" std::size_t GuestHeapUsableSize_nid_postfix(const void*) { throw std::runtime_error("unexpected default heap usable size"); }
extern "C" void* GuestHeapAllocate_nid_postfix(std::size_t) { throw std::runtime_error("unexpected default heap allocation"); }
extern "C" void GuestHeapFree_nid_postfix(void*) { throw std::runtime_error("unexpected default heap free"); }
extern "C" void* GuestHeapReallocate_nid_postfix(void*, std::size_t) { throw std::runtime_error("unexpected default heap reallocation"); }
extern "C" void* GuestHeapAlign_nid_postfix(std::size_t, std::size_t) { throw std::runtime_error("unexpected default heap alignment"); }
extern "C" void* GuestHeapRealign_nid_postfix(void*, std::size_t, std::size_t) { throw std::runtime_error("unexpected default heap realignment"); }
extern "C" int GuestHeapStatsFast_nid_postfix(void*) { throw std::runtime_error("unexpected default heap statistics"); }
}

Probe.cpp

#include "prx/libc/include/Api.hpp"
#include "prx/libc/include/ApplicationHeap.hpp"
#include "prx/libSceLibreSsl/include/Api.hpp"
#include <array>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <new>
#include <stdexcept>
#include <string>

namespace {
bool tracking = false;
int hostCalls = 0;
int failAt = -1;
std::array<void*, 1024> allocations{};
int liveHost = 0;
bool failGuest = false;
int guestCalls = 0;
int liveGuest = 0;
int failures = 0;
void Track(void* pointer) {
    if (!tracking) return;
    for (auto& slot : allocations) if (!slot) { slot = pointer; ++liveHost; return; }
    std::abort();
}
void Untrack(void* pointer) {
    for (auto& slot : allocations) if (slot && slot == pointer) { slot = nullptr; --liveHost; break; }
}
void* APS5_VABI Allocate(std::size_t bytes) {
    ++guestCalls;
    if (failGuest) return nullptr;
    void* pointer = std::malloc(bytes ? bytes : 1);
    if (pointer) ++liveGuest;
    return pointer;
}
void APS5_VABI Free(void* pointer) {
    if (pointer) --liveGuest;
    std::free(pointer);
}
void* APS5_VABI Unexpected() { throw std::runtime_error("unexpected allocator callback"); }
void InitHeap() {
    const std::array<void*, 10> api{reinterpret_cast<void*>(Allocate), reinterpret_cast<void*>(Free), reinterpret_cast<void*>(Unexpected), reinterpret_cast<void*>(Unexpected), reinterpret_cast<void*>(Unexpected), reinterpret_cast<void*>(Unexpected), reinterpret_cast<void*>(Unexpected)};
    ApplicationHeapRegister_nid_no_patch(api.data());
}
struct Outcome { int hostCalls; int guestCalls; bool threw; int returned; bool kept; bool leaked; };
Outcome Call(const char* input, int position, bool guestFailure, bool expectedSuccess) {
    LibreSslCtxInternal internal;
    LibreSslCtx ctx;
    std::memset(&internal, 0xA5, sizeof internal);
    std::memset(&ctx, 0x5A, sizeof ctx);
    ctx.internal = &internal;
    auto* kept = static_cast<std::uint16_t*>(malloc_nid_postfix(4));
    kept[0] = 23;
    kept[1] = 24;
    internal.tlsextSupportedgroups = kept;
    internal.tlsextSupportedgroupsLength = 2;
    std::array<unsigned char, sizeof internal> before;
    std::array<unsigned char, sizeof ctx> beforeCtx;
    std::memcpy(before.data(), &internal, sizeof internal);
    std::memcpy(beforeCtx.data(), &ctx, sizeof ctx);
    hostCalls = 0;
    guestCalls = 0;
    failAt = position;
    failGuest = guestFailure;
    int result = -999;
    bool threw = false;
    tracking = true;
    try { result = SSL_CTX_set1_groups_list_nid_postfix(&ctx, input); }
    catch (const std::bad_alloc&) { threw = true; }
    tracking = false;
    failAt = -1;
    failGuest = false;
    const bool same = std::memcmp(before.data(), &internal, sizeof internal) == 0 && kept[0] == 23 && kept[1] == 24 && std::memcmp(beforeCtx.data(), &ctx, sizeof ctx) == 0;
    const bool successful = result == 1 && !threw;
    const bool expected = expectedSuccess ? successful : !threw && result == 0 && same;
    if (!expected || liveHost != 0 || liveGuest != 1) ++failures;
    Outcome outcome{hostCalls, guestCalls, threw, result, same, liveHost != 0 || liveGuest != 1};
    free_nid_postfix(internal.tlsextSupportedgroups);
    return outcome;
}
void Print(const char* label, int fail, const Outcome& value) {
    std::printf("{\"input\":\"%s\",\"fail_at\":%d,\"host_calls\":%d,\"guest_calls\":%d,\"threw_bad_alloc\":%s,\"result\":%d,\"old_state_kept\":%s,\"leaked\":%s}\n", label, fail, value.hostCalls, value.guestCalls, value.threw ? "true" : "false", value.returned, value.kept ? "true" : "false", value.leaked ? "true" : "false");
}
}
void* operator new(std::size_t bytes) {
    if (tracking) {
        const int index = hostCalls++;
        if (index == failAt) { failAt = -1; throw std::bad_alloc(); }
    }
    if (void* pointer = std::malloc(bytes ? bytes : 1)) { Track(pointer); return pointer; }
    throw std::bad_alloc();
}
void* operator new[](std::size_t bytes) { return ::operator new(bytes); }
void operator delete(void* pointer) noexcept { Untrack(pointer); std::free(pointer); }
void operator delete[](void* pointer) noexcept { ::operator delete(pointer); }
void operator delete(void* pointer, std::size_t) noexcept { ::operator delete(pointer); }
void operator delete[](void* pointer, std::size_t) noexcept { ::operator delete(pointer); }
int main(int argc, char** argv) {
    InitHeap();
    const bool inject = argc == 2 && std::strcmp(argv[1], "faults") == 0;
    const std::string many = "sect163k1:sect163r1:sect163r2:sect193r1:sect193r2:sect233k1:sect233r1:sect239k1:sect283k1:sect283r1:sect409k1:sect409r1:sect571k1:sect571r1:secp160k1:secp160r1:secp160r2:secp192k1:prime192v1:secp224k1:secp224r1:secp256k1:prime256v1:secp384r1:secp521r1:brainpoolP256r1:brainpoolP384r1:brainpoolP512r1:X25519";
    const std::string longInvalid(128, 'x');
    const std::string mixed = "X25519:" + longInvalid;
    struct Input { const char* label; const char* text; bool valid; };
    for (const Input input : {Input{"single", "X25519", true}, Input{"all-29", many.c_str(), true}, Input{"duplicates", "X25519:X25519:P-256:P-384:X25519:P-521", true}, Input{"invalid-long", longInvalid.c_str(), false}, Input{"valid-then-invalid", mixed.c_str(), false}}) {
        const auto normal = Call(input.text, -1, false, input.valid);
        Print(input.label, -1, normal);
        if (inject) {
            for (int position = 0; position < normal.hostCalls; ++position) Print(input.label, position, Call(input.text, position, false, false));
            if (input.valid) Print(input.label, -2, Call(input.text, -1, true, false));
        }
    }
    std::printf("{\"failures\":%d,\"live_host\":%d,\"live_guest\":%d}\n", failures, liveHost, liveGuest);
    return failures || liveHost || liveGuest ? 1 : 0;
}

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5645358203 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11176#pullrequestreview-5645358203). Originally posted by [thepoppfish](https://github.com/thepoppfish) on 2026-10-25T21:17:24Z. **Review:** CHANGES_REQUESTED --- Found one reproducible allocation-failure mismatch on exact head `c0bac5f985ab8663d50e81dffc75805f67905244`: `SSL_CTX_set1_groups_list` can let `std::bad_alloc` escape from its parser instead of returning 0. For the minimal valid list `"X25519"`, failing the first host `operator new` reaches `groups.push_back`, throws out of the export, and never calls the guest allocator. Failing `std::string` allocation for a long unknown name does the same. Thus the existing `failAllocation` guest-heap check does not cover these paths. The old group pointer/length and bytes survive, but the documented error return does not. The [pinned LibreSSL 2.5.4 implementation](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libssl/t1_lib.c#L410-L456) explicitly returns 0 when strdup or reallocarray fails, preserving the previous list. Please convert parser allocation failure to that result. The patch below catches `std::bad_alloc` around the parser only, after the existing null/context checks and before allocating/committing the new guest list. It leaves the deliberate invalid-argument throws in place. Independent Windows 11 build 26200 / MSYS2 UCRT64 GCC 16.2.0 validation: - Built complete production `SslCtxSettings.cpp`, `Objects.cpp` and `ApplicationHeap.cpp`. Current and patched variants use the same toolchain and real registered application-heap callbacks. The fault probe overrides host operator new in the same executable/runtime and arms it only during the export call. - Five no-fault inputs: a single curve, all 29 supported curves, duplicates, a 128-character unknown name and valid-then-unknown. Enumerated **all 14 actual parser allocations** across those inputs and failed each separately. Current: 14 escaped bad_alloc exceptions; candidate: 14 returns of 0, unchanged full internal/context bytes and old list contents, zero tracked live scratch allocations and no guest allocation leaks. Also tested final guest allocation failure on all three valid lists. - Both variants pass the complete unchanged committed `GuestLibreSslSslCtxGroups.cpp` fixture. External CTest **4/4 passed, 0.18 s** (current fixture, patched fixture, current no-fault controls, patched fault matrix). The unchanged current fault matrix is a separate expected exit-1 negative control; it is not counted as passing. - Candidate committed locally as `74a468b65cbd86f87b2114be96cd33eebe6a730a`; conventions against local `origin/main` `2f506cacac52cc58887236582b96338c5ad51f62` and whitespace checks pass. No fork branch or competing PR was published. Scope: this is a focused native executable, not the full shared-library build/15-test suite. The external malloc/free boundary forwards to real ApplicationHeap; its malloc wrapper translates bad_alloc/length_error to errno 12/null, matching FileAndHeap's custom-heap path. Unused default-heap/process lookups throw if called. No group parser, object lookup, application-heap registration or failure assertion is replaced. I did not run a complete upstream LibreSSL binary, PS5 hardware, a title, Linux or macOS. #11138/#10508 integration/order still needs its own resolution. AI-assisted: yes. <details> <summary>Tested patch</summary> ```diff --- a/core/libs/prx/libSceLibreSsl/src/SslCtxSettings.cpp +++ b/core/libs/prx/libSceLibreSsl/src/SslCtxSettings.cpp @@ -4,6 +4,7 @@ #include <cstddef> #include <cstdint> #include <cstring> +#include <new> #include <stdexcept> #include <string> #include <string_view> @@ -70,19 +71,23 @@ LibreSslCtxInternal& internal = Internal(ctx, __func__); if (!list) throw std::invalid_argument(std::string(__func__) + ": null group list"); std::vector<std::uint16_t> groups; - const std::string_view names = list; - std::size_t start = 0; - while (true) { - const std::size_t end = names.find(':', start); - const std::string name(names.substr(start, end == std::string_view::npos ? std::string_view::npos : end - start)); - int nid = OBJ_sn2nid_nid_postfix(name.c_str()); - if (!nid) nid = NistCurveNid(name); - if (!nid) return 0; - const std::uint16_t group = CurveId(nid); - if (!group) return 0; - groups.push_back(group); - if (end == std::string_view::npos) break; - start = end + 1; + try { + const std::string_view names = list; + std::size_t start = 0; + while (true) { + const std::size_t end = names.find(':', start); + const std::string name(names.substr(start, end == std::string_view::npos ? std::string_view::npos : end - start)); + int nid = OBJ_sn2nid_nid_postfix(name.c_str()); + if (!nid) nid = NistCurveNid(name); + if (!nid) return 0; + const std::uint16_t group = CurveId(nid); + if (!group) return 0; + groups.push_back(group); + if (end == std::string_view::npos) break; + start = end + 1; + } + } catch (const std::bad_alloc&) { + return 0; } auto* result = static_cast<std::uint16_t*>(malloc_nid_postfix(groups.size() * sizeof(std::uint16_t))); if (!result) return 0; ``` </details> <details> <summary>Raw fault matrix (current then candidate)</summary> ```jsonl {"variant": "current-fault-negative-control", "exit_code": 1} {"input":"single","fail_at":-1,"host_calls":1,"guest_calls":1,"threw_bad_alloc":false,"result":1,"old_state_kept":false,"leaked":false} {"input":"single","fail_at":0,"host_calls":1,"guest_calls":0,"threw_bad_alloc":true,"result":-999,"old_state_kept":true,"leaked":false} {"input":"single","fail_at":-2,"host_calls":1,"guest_calls":1,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false} {"input":"all-29","fail_at":-1,"host_calls":6,"guest_calls":1,"threw_bad_alloc":false,"result":1,"old_state_kept":false,"leaked":false} {"input":"all-29","fail_at":0,"host_calls":1,"guest_calls":0,"threw_bad_alloc":true,"result":-999,"old_state_kept":true,"leaked":false} {"input":"all-29","fail_at":1,"host_calls":2,"guest_calls":0,"threw_bad_alloc":true,"result":-999,"old_state_kept":true,"leaked":false} {"input":"all-29","fail_at":2,"host_calls":3,"guest_calls":0,"threw_bad_alloc":true,"result":-999,"old_state_kept":true,"leaked":false} {"input":"all-29","fail_at":3,"host_calls":4,"guest_calls":0,"threw_bad_alloc":true,"result":-999,"old_state_kept":true,"leaked":false} {"input":"all-29","fail_at":4,"host_calls":5,"guest_calls":0,"threw_bad_alloc":true,"result":-999,"old_state_kept":true,"leaked":false} {"input":"all-29","fail_at":5,"host_calls":6,"guest_calls":0,"threw_bad_alloc":true,"result":-999,"old_state_kept":true,"leaked":false} {"input":"all-29","fail_at":-2,"host_calls":6,"guest_calls":1,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false} {"input":"duplicates","fail_at":-1,"host_calls":4,"guest_calls":1,"threw_bad_alloc":false,"result":1,"old_state_kept":false,"leaked":false} {"input":"duplicates","fail_at":0,"host_calls":1,"guest_calls":0,"threw_bad_alloc":true,"result":-999,"old_state_kept":true,"leaked":false} {"input":"duplicates","fail_at":1,"host_calls":2,"guest_calls":0,"threw_bad_alloc":true,"result":-999,"old_state_kept":true,"leaked":false} {"input":"duplicates","fail_at":2,"host_calls":3,"guest_calls":0,"threw_bad_alloc":true,"result":-999,"old_state_kept":true,"leaked":false} {"input":"duplicates","fail_at":3,"host_calls":4,"guest_calls":0,"threw_bad_alloc":true,"result":-999,"old_state_kept":true,"leaked":false} {"input":"duplicates","fail_at":-2,"host_calls":4,"guest_calls":1,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false} {"input":"invalid-long","fail_at":-1,"host_calls":1,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false} {"input":"invalid-long","fail_at":0,"host_calls":1,"guest_calls":0,"threw_bad_alloc":true,"result":-999,"old_state_kept":true,"leaked":false} {"input":"valid-then-invalid","fail_at":-1,"host_calls":2,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false} {"input":"valid-then-invalid","fail_at":0,"host_calls":1,"guest_calls":0,"threw_bad_alloc":true,"result":-999,"old_state_kept":true,"leaked":false} {"input":"valid-then-invalid","fail_at":1,"host_calls":2,"guest_calls":0,"threw_bad_alloc":true,"result":-999,"old_state_kept":true,"leaked":false} {"failures":14,"live_host":0,"live_guest":0} {"variant": "fixed-fault-details", "exit_code": 0} {"input":"single","fail_at":-1,"host_calls":1,"guest_calls":1,"threw_bad_alloc":false,"result":1,"old_state_kept":false,"leaked":false} {"input":"single","fail_at":0,"host_calls":1,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false} {"input":"single","fail_at":-2,"host_calls":1,"guest_calls":1,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false} {"input":"all-29","fail_at":-1,"host_calls":6,"guest_calls":1,"threw_bad_alloc":false,"result":1,"old_state_kept":false,"leaked":false} {"input":"all-29","fail_at":0,"host_calls":1,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false} {"input":"all-29","fail_at":1,"host_calls":2,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false} {"input":"all-29","fail_at":2,"host_calls":3,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false} {"input":"all-29","fail_at":3,"host_calls":4,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false} {"input":"all-29","fail_at":4,"host_calls":5,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false} {"input":"all-29","fail_at":5,"host_calls":6,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false} {"input":"all-29","fail_at":-2,"host_calls":6,"guest_calls":1,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false} {"input":"duplicates","fail_at":-1,"host_calls":4,"guest_calls":1,"threw_bad_alloc":false,"result":1,"old_state_kept":false,"leaked":false} {"input":"duplicates","fail_at":0,"host_calls":1,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false} {"input":"duplicates","fail_at":1,"host_calls":2,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false} {"input":"duplicates","fail_at":2,"host_calls":3,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false} {"input":"duplicates","fail_at":3,"host_calls":4,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false} {"input":"duplicates","fail_at":-2,"host_calls":4,"guest_calls":1,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false} {"input":"invalid-long","fail_at":-1,"host_calls":1,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false} {"input":"invalid-long","fail_at":0,"host_calls":1,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false} {"input":"valid-then-invalid","fail_at":-1,"host_calls":2,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false} {"input":"valid-then-invalid","fail_at":0,"host_calls":1,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false} {"input":"valid-then-invalid","fail_at":1,"host_calls":2,"guest_calls":0,"threw_bad_alloc":false,"result":0,"old_state_kept":true,"leaked":false} {"failures":0,"live_host":0,"live_guest":0} ``` </details> <details> <summary>Complete focused harness and replay</summary> Place `review-11176` and `native-groups11176` beside each other; save the three files below under native-groups11176. With Git, MinGW GCC, CMake and Ninja on PATH: ```powershell git clone --no-checkout https://github.com/boykopovar/AnyPS5.git review-11176 git -C review-11176 checkout --detach c0bac5f985ab8663d50e81dffc75805f67905244 ``` Save a copy of production SslCtxSettings.cpp as native-groups11176/FixedSettings.cpp and apply the patch above **to that copy only**. Keep the original checkout untouched. Then: ```powershell cmake -S native-groups11176 -B native-groups11176/build -G Ninja -DCMAKE_BUILD_TYPE=Release cmake --build native-groups11176/build -j 4 ctest --test-dir native-groups11176/build --output-on-failure -V ./native-groups11176/build/current_probe.exe faults ./native-groups11176/build/fixed_probe.exe faults ``` The current fault probe should exit 1 with 14 failures; the patched one should exit 0. CTest cases have 8 s timeouts. All logs are JSON lines with the injected allocation index, host/guest call counts, return/exception and preserved-state/leak assertions. `CMakeLists.txt` ```cmake cmake_minimum_required(VERSION 3.20) project(GroupsAllocationReview LANGUAGES CXX) get_filename_component(DEFAULT_REPO "${CMAKE_CURRENT_LIST_DIR}/../review-11176" ABSOLUTE) set(REPO "${DEFAULT_REPO}" CACHE PATH "Exact author checkout") enable_testing() foreach(variant IN ITEMS current fixed) if(variant STREQUAL current) set(source "${REPO}/core/libs/prx/libSceLibreSsl/src/SslCtxSettings.cpp") else() set(source "${CMAKE_CURRENT_LIST_DIR}/FixedSettings.cpp") endif() foreach(kind IN ITEMS author probe) if(kind STREQUAL author) set(entry "${REPO}/core/libs/tests/GuestLibreSslSslCtxGroups.cpp") else() set(entry "${CMAKE_CURRENT_LIST_DIR}/Probe.cpp") endif() add_executable(${variant}_${kind} "${entry}" Support.cpp "${source}" "${REPO}/core/libs/prx/libSceLibreSsl/src/Objects.cpp" "${REPO}/core/libs/prx/libc/src/ApplicationHeap.cpp") target_compile_features(${variant}_${kind} PRIVATE cxx_std_20) target_compile_options(${variant}_${kind} PRIVATE -O1 -g -fno-inline -fno-lto -ffunction-sections -fdata-sections) target_include_directories(${variant}_${kind} PRIVATE "${REPO}/core/libs") target_link_options(${variant}_${kind} PRIVATE -static-libstdc++ -static-libgcc -Wl,--gc-sections) add_custom_command(TARGET ${variant}_${kind} POST_BUILD COMMAND "${CMAKE_OBJCOPY}" --rename-section .eh_frame=.ehfram --rename-section .eh_fram=.ehfram "$<TARGET_FILE:${variant}_${kind}>" VERBATIM) endforeach() add_test(NAME ${variant}_author COMMAND ${variant}_author) set_tests_properties(${variant}_author PROPERTIES TIMEOUT 8) endforeach() add_test(NAME current_no_fault COMMAND current_probe nofault) add_test(NAME fixed_allocation_faults COMMAND fixed_probe faults) set_tests_properties(current_no_fault fixed_allocation_faults PROPERTIES TIMEOUT 8) ``` `Support.cpp` ```cpp #include "prx/libc/include/ApplicationHeap.hpp" #include "prx/libc/include/GuestHeap.hpp" #include "prx/libc/include/General.hpp" #include "prx/libc/include/Api.hpp" #include <cerrno> #include <new> #include <stdexcept> extern "C" void* APS5_VABI malloc_nid_postfix(std::size_t bytes) { try { return ApplicationHeapAllocate_nid_no_patch(bytes); } catch (const std::bad_alloc&) {} catch (const std::length_error&) {} errno = 12; return nullptr; } extern "C" void APS5_VABI free_nid_postfix(void* pointer) { ApplicationHeapFree_nid_no_patch(pointer); } extern "C" const void* ApplicationProcessParameters_nid_no_patch() { throw std::runtime_error("unexpected process parameter lookup"); } extern "C" bool ApplicationGuestHeapApi_nid_no_patch(void**) { throw std::runtime_error("unexpected guest API lookup"); } extern "C" [[noreturn]] void NotImplemented_nid_no_patch(const char* name) { throw std::runtime_error(name); } namespace GuestHeap { extern "C" std::size_t GuestHeapUsableSize_nid_postfix(const void*) { throw std::runtime_error("unexpected default heap usable size"); } extern "C" void* GuestHeapAllocate_nid_postfix(std::size_t) { throw std::runtime_error("unexpected default heap allocation"); } extern "C" void GuestHeapFree_nid_postfix(void*) { throw std::runtime_error("unexpected default heap free"); } extern "C" void* GuestHeapReallocate_nid_postfix(void*, std::size_t) { throw std::runtime_error("unexpected default heap reallocation"); } extern "C" void* GuestHeapAlign_nid_postfix(std::size_t, std::size_t) { throw std::runtime_error("unexpected default heap alignment"); } extern "C" void* GuestHeapRealign_nid_postfix(void*, std::size_t, std::size_t) { throw std::runtime_error("unexpected default heap realignment"); } extern "C" int GuestHeapStatsFast_nid_postfix(void*) { throw std::runtime_error("unexpected default heap statistics"); } } ``` `Probe.cpp` ```cpp #include "prx/libc/include/Api.hpp" #include "prx/libc/include/ApplicationHeap.hpp" #include "prx/libSceLibreSsl/include/Api.hpp" #include <array> #include <cstdio> #include <cstdlib> #include <cstring> #include <new> #include <stdexcept> #include <string> namespace { bool tracking = false; int hostCalls = 0; int failAt = -1; std::array<void*, 1024> allocations{}; int liveHost = 0; bool failGuest = false; int guestCalls = 0; int liveGuest = 0; int failures = 0; void Track(void* pointer) { if (!tracking) return; for (auto& slot : allocations) if (!slot) { slot = pointer; ++liveHost; return; } std::abort(); } void Untrack(void* pointer) { for (auto& slot : allocations) if (slot && slot == pointer) { slot = nullptr; --liveHost; break; } } void* APS5_VABI Allocate(std::size_t bytes) { ++guestCalls; if (failGuest) return nullptr; void* pointer = std::malloc(bytes ? bytes : 1); if (pointer) ++liveGuest; return pointer; } void APS5_VABI Free(void* pointer) { if (pointer) --liveGuest; std::free(pointer); } void* APS5_VABI Unexpected() { throw std::runtime_error("unexpected allocator callback"); } void InitHeap() { const std::array<void*, 10> api{reinterpret_cast<void*>(Allocate), reinterpret_cast<void*>(Free), reinterpret_cast<void*>(Unexpected), reinterpret_cast<void*>(Unexpected), reinterpret_cast<void*>(Unexpected), reinterpret_cast<void*>(Unexpected), reinterpret_cast<void*>(Unexpected)}; ApplicationHeapRegister_nid_no_patch(api.data()); } struct Outcome { int hostCalls; int guestCalls; bool threw; int returned; bool kept; bool leaked; }; Outcome Call(const char* input, int position, bool guestFailure, bool expectedSuccess) { LibreSslCtxInternal internal; LibreSslCtx ctx; std::memset(&internal, 0xA5, sizeof internal); std::memset(&ctx, 0x5A, sizeof ctx); ctx.internal = &internal; auto* kept = static_cast<std::uint16_t*>(malloc_nid_postfix(4)); kept[0] = 23; kept[1] = 24; internal.tlsextSupportedgroups = kept; internal.tlsextSupportedgroupsLength = 2; std::array<unsigned char, sizeof internal> before; std::array<unsigned char, sizeof ctx> beforeCtx; std::memcpy(before.data(), &internal, sizeof internal); std::memcpy(beforeCtx.data(), &ctx, sizeof ctx); hostCalls = 0; guestCalls = 0; failAt = position; failGuest = guestFailure; int result = -999; bool threw = false; tracking = true; try { result = SSL_CTX_set1_groups_list_nid_postfix(&ctx, input); } catch (const std::bad_alloc&) { threw = true; } tracking = false; failAt = -1; failGuest = false; const bool same = std::memcmp(before.data(), &internal, sizeof internal) == 0 && kept[0] == 23 && kept[1] == 24 && std::memcmp(beforeCtx.data(), &ctx, sizeof ctx) == 0; const bool successful = result == 1 && !threw; const bool expected = expectedSuccess ? successful : !threw && result == 0 && same; if (!expected || liveHost != 0 || liveGuest != 1) ++failures; Outcome outcome{hostCalls, guestCalls, threw, result, same, liveHost != 0 || liveGuest != 1}; free_nid_postfix(internal.tlsextSupportedgroups); return outcome; } void Print(const char* label, int fail, const Outcome& value) { std::printf("{\"input\":\"%s\",\"fail_at\":%d,\"host_calls\":%d,\"guest_calls\":%d,\"threw_bad_alloc\":%s,\"result\":%d,\"old_state_kept\":%s,\"leaked\":%s}\n", label, fail, value.hostCalls, value.guestCalls, value.threw ? "true" : "false", value.returned, value.kept ? "true" : "false", value.leaked ? "true" : "false"); } } void* operator new(std::size_t bytes) { if (tracking) { const int index = hostCalls++; if (index == failAt) { failAt = -1; throw std::bad_alloc(); } } if (void* pointer = std::malloc(bytes ? bytes : 1)) { Track(pointer); return pointer; } throw std::bad_alloc(); } void* operator new[](std::size_t bytes) { return ::operator new(bytes); } void operator delete(void* pointer) noexcept { Untrack(pointer); std::free(pointer); } void operator delete[](void* pointer) noexcept { ::operator delete(pointer); } void operator delete(void* pointer, std::size_t) noexcept { ::operator delete(pointer); } void operator delete[](void* pointer, std::size_t) noexcept { ::operator delete(pointer); } int main(int argc, char** argv) { InitHeap(); const bool inject = argc == 2 && std::strcmp(argv[1], "faults") == 0; const std::string many = "sect163k1:sect163r1:sect163r2:sect193r1:sect193r2:sect233k1:sect233r1:sect239k1:sect283k1:sect283r1:sect409k1:sect409r1:sect571k1:sect571r1:secp160k1:secp160r1:secp160r2:secp192k1:prime192v1:secp224k1:secp224r1:secp256k1:prime256v1:secp384r1:secp521r1:brainpoolP256r1:brainpoolP384r1:brainpoolP512r1:X25519"; const std::string longInvalid(128, 'x'); const std::string mixed = "X25519:" + longInvalid; struct Input { const char* label; const char* text; bool valid; }; for (const Input input : {Input{"single", "X25519", true}, Input{"all-29", many.c_str(), true}, Input{"duplicates", "X25519:X25519:P-256:P-384:X25519:P-521", true}, Input{"invalid-long", longInvalid.c_str(), false}, Input{"valid-then-invalid", mixed.c_str(), false}}) { const auto normal = Call(input.text, -1, false, input.valid); Print(input.label, -1, normal); if (inject) { for (int position = 0; position < normal.hostCalls; ++position) Print(input.label, position, Call(input.text, position, false, false)); if (input.valid) Print(input.label, -2, Call(input.text, -1, true, false)); } } std::printf("{\"failures\":%d,\"live_host\":%d,\"live_guest\":%d}\n", failures, liveHost, liveGuest); return failures || liveHost || liveGuest ? 1 : 0; } ``` </details>
adriadam10 commented 2026-10-28 14:45:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-28T14:45:51Z.

Review: CHANGES_REQUESTED


Reviewed the new code (SslCtxSettings.cpp, GuestLibreSslSslCtxGroups.cpp, the Api.hpp declarations and the debt entry): it matches LibreSSL 2.5.4 as described, and the earlier allocation-failure report is fixed in 56b22c2c57. No findings on the code itself.

  • The branch currently conflicts with main (CMakeLists.txt, include/Api.hpp, debt file) and carries the commits of #10483, #11138 and #10508 through merge commits, so it can't be rebased cleanly while those are open. Once they have merged, please rebase onto main so the diff is only this PR's commits.
  • After the rebase, recount the pending-export line in docs/dev/debt/libSceLibreSsl.md against main; it says 326 and each recent LibreSSL merge changed it.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5684566588 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11176#pullrequestreview-5684566588). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-28T14:45:51Z. **Review:** CHANGES_REQUESTED --- Reviewed the new code (`SslCtxSettings.cpp`, `GuestLibreSslSslCtxGroups.cpp`, the `Api.hpp` declarations and the debt entry): it matches LibreSSL 2.5.4 as described, and the earlier allocation-failure report is fixed in 56b22c2c57. No findings on the code itself. - The branch currently conflicts with `main` (`CMakeLists.txt`, `include/Api.hpp`, debt file) and carries the commits of #10483, #11138 and #10508 through merge commits, so it can't be rebased cleanly while those are open. Once they have merged, please rebase onto `main` so the diff is only this PR's commits. - After the rebase, recount the pending-export line in `docs/dev/debt/libSceLibreSsl.md` against `main`; it says 326 and each recent LibreSSL merge changed it.
adriadam10 commented 2026-10-29 18:10:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-29T18:10:54Z.

Review: CHANGES_REQUESTED


Nothing new on the code: SslCtxSettings.cpp, the groups test, the Api.hpp declarations and the debt entry still match LibreSSL 2.5.4.

  • The branch still conflicts with main (CMakeLists.txt, include/Api.hpp, docs/dev/debt/libSceLibreSsl.md) and carries #10483, #11138 and #10508 through merge commits. All three are still open, so a rebase now would either drag their commits along or need their content merged first. Once they have merged, rebase onto main so the diff is only this PR's commits.
  • After the rebase, recount the pending-export line in docs/dev/debt/libSceLibreSsl.md against the stubs left in Export.cpp; every recent LibreSSL merge changed it.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5702709181 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11176#pullrequestreview-5702709181). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-29T18:10:54Z. **Review:** CHANGES_REQUESTED --- Nothing new on the code: `SslCtxSettings.cpp`, the groups test, the `Api.hpp` declarations and the debt entry still match LibreSSL 2.5.4. - The branch still conflicts with `main` (`CMakeLists.txt`, `include/Api.hpp`, `docs/dev/debt/libSceLibreSsl.md`) and carries #10483, #11138 and #10508 through merge commits. All three are still open, so a rebase now would either drag their commits along or need their content merged first. Once they have merged, rebase onto `main` so the diff is only this PR's commits. - After the rebase, recount the pending-export line in `docs/dev/debt/libSceLibreSsl.md` against the stubs left in `Export.cpp`; every recent LibreSSL merge changed it.
CnRJay commented 2026-11-01 20:02:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T20:02:11Z.

Review: COMMENTED


Correction (2026-11-01): the title-ID/log demand below is not a CONTRIBUTING requirement; Unblocks: none is allowed. The technical points below are unaffected.

No title ID and no log line. The description says Unblocks: none and "No export creates a context yet, so these only see contexts the caller builds until SSL_CTX_new lands". So nothing on main can reach SSL_CTX_set_alpn_protos or SSL_CTX_set1_groups_list, and the diff (about 2,600 lines including carried #11138 and #10508 commits) cannot be exercised by a title.

  1. Reach. Please add the title ID that imports either export and the log line from main showing it. Until SSL_CTX_new lands there is no way to produce that evidence.
  2. Carried commits. The diff carries #11138 and #10508 until they merge, so the net change cannot be reviewed on its own; I would rebase and re-request review after those land.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5729964528 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11176#pullrequestreview-5729964528). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-11-01T20:02:11Z. **Review:** COMMENTED --- **Correction (2026-11-01):** the title-ID/log demand below is not a CONTRIBUTING requirement; `Unblocks: none` is allowed. The technical points below are unaffected. No title ID and no log line. The description says `Unblocks: none` and "No export creates a context yet, so these only see contexts the caller builds until `SSL_CTX_new` lands". So nothing on `main` can reach `SSL_CTX_set_alpn_protos` or `SSL_CTX_set1_groups_list`, and the diff (about 2,600 lines including carried #11138 and #10508 commits) cannot be exercised by a title. 1. **Reach.** Please add the title ID that imports either export and the log line from `main` showing it. Until `SSL_CTX_new` lands there is no way to produce that evidence. 2. **Carried commits.** The diff carries #11138 and #10508 until they merge, so the net change cannot be reviewed on its own; I would rebase and re-request review after those land.
adriadam10 commented 2026-11-10 17:13:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-11-10T17:13:22Z.

Review: CHANGES_REQUESTED


#10483, #11138 and #10508 are merged now, so the merge-commit stack can go. The branch still conflicts with main, and replaying it shows it is not a mechanical rebase:

  • The branch still carries the old OBJ_nid2sn/OBJ_sn2nid commits (src/Objects.cpp, GuestLibreSslObjects.cpp). main has them in ObjectText.cpp and tests/ObjectName.cpp, and its OBJ_sn2nid already searches added objects (ObjectText.cpp:237).
  • LibreSslHasAddedObjectName_nid_no_patch (ObjectCreate.cpp) and the group parser's refusal of registered names, plus the debt text "Name lookups ... remain unsupported", were written against the old parent. Please redo them against current main (reuse its lookup instead of refusing, or say why the refusal is still needed).
  • Please rebase onto main (a fresh branch with only this PR's commits is fine) and resolve CMakeLists.txt, Export.cpp (the two stubs are still there on main) and docs/dev/debt/libSceLibreSsl.md; recount the pending-export line against the stubs left.

The SslCtxSettings.cpp logic and the groups test matched LibreSSL 2.5.4 when reviewed; I will look at them again on the rebased head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5846152211 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11176#pullrequestreview-5846152211). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-11-10T17:13:22Z. **Review:** CHANGES_REQUESTED --- #10483, #11138 and #10508 are merged now, so the merge-commit stack can go. The branch still conflicts with `main`, and replaying it shows it is not a mechanical rebase: - The branch still carries the old `OBJ_nid2sn`/`OBJ_sn2nid` commits (`src/Objects.cpp`, `GuestLibreSslObjects.cpp`). `main` has them in `ObjectText.cpp` and `tests/ObjectName.cpp`, and its `OBJ_sn2nid` already searches added objects (`ObjectText.cpp:237`). - `LibreSslHasAddedObjectName_nid_no_patch` (`ObjectCreate.cpp`) and the group parser's refusal of registered names, plus the debt text "Name lookups ... remain unsupported", were written against the old parent. Please redo them against current `main` (reuse its lookup instead of refusing, or say why the refusal is still needed). - Please rebase onto `main` (a fresh branch with only this PR's commits is fine) and resolve `CMakeLists.txt`, `Export.cpp` (the two stubs are still there on `main`) and `docs/dev/debt/libSceLibreSsl.md`; recount the pending-export line against the stubs left. The `SslCtxSettings.cpp` logic and the groups test matched LibreSSL 2.5.4 when reviewed; I will look at them again on the rebased head.
MarcZX10 commented 2026-11-14 07:40:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T07:40:35Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: preserve the existing ALPN list and length when allocation for a replacement fails.

What I ran

Reviewed head 0d190b9a731e9da27f9189c5b7bd866f5d89a173. I did not run commands or tests. The PR description reports a Linux Release build and focused tests, but those results were not independently run here.

Results

Check Result Note
Prepared diff and source review passed Changed implementation and test read
Build and focused tests not run Author-reported only
Console behavior not run PR marks it unverified

Findings

Blocking

  • core/libs/prx/libSceLibreSsl/src/SslCtxSettings.cpp:62 frees the current ALPN list before attempting to allocate its replacement at line 63. If allocation fails, the function returns failure with the old pointer discarded and the old length still in the context. This loses valid prior state and leaves the context inconsistent. Allocate into a temporary first, then replace and free the old list only after allocation succeeds; for zero length, handle the empty list without relying on allocator behavior.

Non-blocking

None.

Sources

  • The implementation and changed focused test were read from the prepared bundle. Changed files read: core/libs/prx/libSceLibreSsl/CMakeLists.txt, core/libs/prx/libSceLibreSsl/Export.cpp, core/libs/prx/libSceLibreSsl/include/Api.hpp, core/libs/prx/libSceLibreSsl/include/ObjectTable.hpp, core/libs/prx/libSceLibreSsl/src/ObjectCreate.cpp, core/libs/prx/libSceLibreSsl/src/SslCtxSettings.cpp, core/libs/tests/GuestLibreSslSslCtxGroups.cpp, and docs/dev/debt/libSceLibreSsl.md.
  • All changed files were included in the review bundle; none were excluded by rule.

Not verified

Build, focused tests, full test suite, and console behavior were not run. The validation claims in the PR description remain author-reported.

To get this to a good state

Preserve the previous ALPN pointer and length on allocation failure, then rerun the focused ALPN/groups test and build on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5902776165 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11176#pullrequestreview-5902776165). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-14T07:40:35Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: preserve the existing ALPN list and length when allocation for a replacement fails. ## What I ran Reviewed head `0d190b9a731e9da27f9189c5b7bd866f5d89a173`. I did not run commands or tests. The PR description reports a Linux Release build and focused tests, but those results were not independently run here. ## Results | Check | Result | Note | |---|---|---| | Prepared diff and source review | passed | Changed implementation and test read | | Build and focused tests | not run | Author-reported only | | Console behavior | not run | PR marks it unverified | ## Findings ### Blocking - `core/libs/prx/libSceLibreSsl/src/SslCtxSettings.cpp:62` frees the current ALPN list before attempting to allocate its replacement at line 63. If allocation fails, the function returns failure with the old pointer discarded and the old length still in the context. This loses valid prior state and leaves the context inconsistent. Allocate into a temporary first, then replace and free the old list only after allocation succeeds; for zero length, handle the empty list without relying on allocator behavior. ### Non-blocking None. ## Sources - The implementation and changed focused test were read from the prepared bundle. Changed files read: `core/libs/prx/libSceLibreSsl/CMakeLists.txt`, `core/libs/prx/libSceLibreSsl/Export.cpp`, `core/libs/prx/libSceLibreSsl/include/Api.hpp`, `core/libs/prx/libSceLibreSsl/include/ObjectTable.hpp`, `core/libs/prx/libSceLibreSsl/src/ObjectCreate.cpp`, `core/libs/prx/libSceLibreSsl/src/SslCtxSettings.cpp`, `core/libs/tests/GuestLibreSslSslCtxGroups.cpp`, and `docs/dev/debt/libSceLibreSsl.md`. - All changed files were included in the review bundle; none were excluded by rule. ## Not verified Build, focused tests, full test suite, and console behavior were not run. The validation claims in the PR description remain author-reported. ## To get this to a good state Preserve the previous ALPN pointer and length on allocation failure, then rerun the focused ALPN/groups test and build on the updated head.
MarcZX10 commented 2026-11-18 08:40:48 +00:00 (Migrated from github.com)

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

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: preserve the previous ALPN length when allocation fails, as the described LibreSSL behavior and regression expectation require.

What I ran

Reviewed head d232e8a5b63c5791e8b703853decc9280fe77b9a. Read the prepared description, commits, diff, manifest and all changed file contents marked included; used repo_read.py to inspect relevant allocator, object lookup, context layout and build configuration source. No build or test commands were run.

Results

Check Result Note
Source review failed ALPN failure state differs from stated behavior
Build and tests not run Author-reported checks were not rerun
Changed-file coverage passed All 8 changed files were included and read

Findings

Blocking

  • core/libs/prx/libSceLibreSsl/src/SslCtxSettings.cpp:64 returns on allocation failure after freeing the old ALPN buffer, but does not restore or preserve its prior length. The context is left with a null pointer and stale length. The PR description explicitly says the prior length is retained, and the regression test asserts that behavior at core/libs/tests/GuestLibreSslSslCtxGroups.cpp:384-388; however, the implementation only produces that result if the old length happened to be 12. Save the old length before clearing the old buffer and retain it when allocation fails, or otherwise align the implementation, test and claimed behavior with LibreSSL 2.5.4.

Non-blocking

None.

Not verified

  • Tests and build results in the description are author-reported and were not independently run; the complete legacy suite, optional oracle, GPU, console and title behavior were not verified.
  • No files were excluded by the review manifest. The changed files read were core/libs/prx/libSceLibreSsl/CMakeLists.txt, core/libs/prx/libSceLibreSsl/Export.cpp, core/libs/prx/libSceLibreSsl/include/Api.hpp, core/libs/prx/libSceLibreSsl/include/ObjectTable.hpp, core/libs/prx/libSceLibreSsl/src/ObjectCreate.cpp, core/libs/prx/libSceLibreSsl/src/SslCtxSettings.cpp, core/libs/tests/GuestLibreSslSslCtxGroups.cpp and docs/dev/debt/changes/align-11176-alpn-groups.md.

To get this to a good state

Preserve the previous ALPN length across allocation failure, and ensure the regression checks the behavior from a previous length other than the expected retained value. Then rerun the focused SSL context tests on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5953214497 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11176#pullrequestreview-5953214497). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-18T08:40:48Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: preserve the previous ALPN length when allocation fails, as the described LibreSSL behavior and regression expectation require. ## What I ran Reviewed head `d232e8a5b63c5791e8b703853decc9280fe77b9a`. Read the prepared description, commits, diff, manifest and all changed file contents marked included; used `repo_read.py` to inspect relevant allocator, object lookup, context layout and build configuration source. No build or test commands were run. ## Results | Check | Result | Note | |---|---|---| | Source review | failed | ALPN failure state differs from stated behavior | | Build and tests | not run | Author-reported checks were not rerun | | Changed-file coverage | passed | All 8 changed files were included and read | ## Findings ### Blocking - `core/libs/prx/libSceLibreSsl/src/SslCtxSettings.cpp:64` returns on allocation failure after freeing the old ALPN buffer, but does not restore or preserve its prior length. The context is left with a null pointer and stale length. The PR description explicitly says the prior length is retained, and the regression test asserts that behavior at `core/libs/tests/GuestLibreSslSslCtxGroups.cpp:384-388`; however, the implementation only produces that result if the old length happened to be 12. Save the old length before clearing the old buffer and retain it when allocation fails, or otherwise align the implementation, test and claimed behavior with LibreSSL 2.5.4. ### Non-blocking None. ## Not verified - Tests and build results in the description are author-reported and were not independently run; the complete legacy suite, optional oracle, GPU, console and title behavior were not verified. - No files were excluded by the review manifest. The changed files read were `core/libs/prx/libSceLibreSsl/CMakeLists.txt`, `core/libs/prx/libSceLibreSsl/Export.cpp`, `core/libs/prx/libSceLibreSsl/include/Api.hpp`, `core/libs/prx/libSceLibreSsl/include/ObjectTable.hpp`, `core/libs/prx/libSceLibreSsl/src/ObjectCreate.cpp`, `core/libs/prx/libSceLibreSsl/src/SslCtxSettings.cpp`, `core/libs/tests/GuestLibreSslSslCtxGroups.cpp` and `docs/dev/debt/changes/align-11176-alpn-groups.md`. ## To get this to a good state Preserve the previous ALPN length across allocation failure, and ensure the regression checks the behavior from a previous length other than the expected retained value. Then rerun the focused SSL context tests on the updated head.
MarcZX10 commented 2026-11-18 10:13:37 +00:00 (Migrated from github.com)

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

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the focused behavior checks are reported as passing, and the inspected code supports the described ALPN and group-list behavior.

What I ran

No commands run. The prepared review materials identify head b2b6bcefa6ef7f7f8a44ddd3ef3250dafa08b14a; the author reports focused CPU tests and other checks, while noting that the full product and full test suite were not run. I read description.md, commits.md, manifest.json, diff.patch, SslCtxSettings.cpp, ObjectText.cpp, ObjectCreate.cpp, and the relevant portions of GuestLibreSslSslCtxGroups.cpp.

Results

Check Result Note
Source review passed Inspected changed behavior and relevant lookups
Focused checks not run Passes are author-reported
Full product and suite not run Not claimed by author

Findings

Blocking

None.

Non-blocking

None.

Not verified

I did not inspect the full changed test file, CMakeLists.txt, Export.cpp, Api.hpp, ObjectTable.hpp, or the debt note. I did not run tests, verify the reported build or CI results, or check console behavior. files.json and the prepared review/files/ copies were not accessible through the reader; source was read only through the pinned-head repository reader.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5954572278 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11176#pullrequestreview-5954572278). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-18T10:13:37Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the focused behavior checks are reported as passing, and the inspected code supports the described ALPN and group-list behavior. ## What I ran No commands run. The prepared review materials identify head `b2b6bcefa6ef7f7f8a44ddd3ef3250dafa08b14a`; the author reports focused CPU tests and other checks, while noting that the full product and full test suite were not run. I read `description.md`, `commits.md`, `manifest.json`, `diff.patch`, `SslCtxSettings.cpp`, `ObjectText.cpp`, `ObjectCreate.cpp`, and the relevant portions of `GuestLibreSslSslCtxGroups.cpp`. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Inspected changed behavior and relevant lookups | | Focused checks | not run | Passes are author-reported | | Full product and suite | not run | Not claimed by author | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified I did not inspect the full changed test file, `CMakeLists.txt`, `Export.cpp`, `Api.hpp`, `ObjectTable.hpp`, or the debt note. I did not run tests, verify the reported build or CI results, or check console behavior. `files.json` and the prepared `review/files/` copies were not accessible through the reader; source was read only through the pinned-head repository reader. ## To get this to a good state Nothing is required.
ligmaSec commented 2026-12-03 13:36:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T13:36:22Z.

Review: COMMENTED


The Linux integration build passed the registered SSL context groups CTest.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6170835816 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11176#pullrequestreview-6170835816). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T13:36:22Z. **Review:** COMMENTED --- The Linux integration build passed the registered SSL context groups CTest. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

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

Merge

Merge the changes and update on Forgejo.

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

git switch 'main'
git merge --no-ff 'upstream-pr/11176'
git switch 'upstream-pr/11176'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/11176'
git switch 'upstream-pr/11176'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/11176'
git switch 'main'
git merge --squash 'upstream-pr/11176'
git switch 'main'
git merge --ff-only 'upstream-pr/11176'
git switch 'main'
git merge 'upstream-pr/11176'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!11176
No description provided.