feat(libSceLibreSsl): implement SSL_CTX_set_alpn_protos and SSL_CTX_set1_groups_list #11176
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11176"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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_sn2nidlookup 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.ImportBinding.cpppasses against a fresh six-module lifecycle fixture, using actual NIDs.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: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
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)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 ofSslCtxSettings.cppandGuestLibreSslSslCtxGroups.cpppassed. 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 rebasewith merge stateDIRTY. 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.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_listcan letstd::bad_allocescape from its parser instead of returning 0.For the minimal valid list
"X25519", failing the first hostoperator newreachesgroups.push_back, throws out of the export, and never calls the guest allocator. Failingstd::stringallocation for a long unknown name does the same. Thus the existingfailAllocationguest-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_allocaround 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:
SslCtxSettings.cpp,Objects.cppandApplicationHeap.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.GuestLibreSslSslCtxGroups.cppfixture. 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.74a468b65cbd86f87b2114be96cd33eebe6a730a; conventions against localorigin/main2f506cacac52cc58887236582b96338c5ad51f62and 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
Raw fault matrix (current then candidate)
Complete focused harness and replay
Place
review-11176andnative-groups11176beside each other; save the three files below under native-groups11176. With Git, MinGW GCC, CMake and Ninja on PATH: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:
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.txtSupport.cppProbe.cppImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-28T14:45:51Z.
Review: CHANGES_REQUESTED
Reviewed the new code (
SslCtxSettings.cpp,GuestLibreSslSslCtxGroups.cpp, theApi.hppdeclarations and the debt entry): it matches LibreSSL 2.5.4 as described, and the earlier allocation-failure report is fixed in56b22c2c57. No findings on the code itself.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 ontomainso the diff is only this PR's commits.docs/dev/debt/libSceLibreSsl.mdagainstmain; it says 326 and each recent LibreSSL merge changed it.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, theApi.hppdeclarations and the debt entry still match LibreSSL 2.5.4.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 ontomainso the diff is only this PR's commits.docs/dev/debt/libSceLibreSsl.mdagainst the stubs left inExport.cpp; every recent LibreSSL merge changed it.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: noneis allowed. The technical points below are unaffected.No title ID and no log line. The description says
Unblocks: noneand "No export creates a context yet, so these only see contexts the caller builds untilSSL_CTX_newlands". So nothing onmaincan reachSSL_CTX_set_alpn_protosorSSL_CTX_set1_groups_list, and the diff (about 2,600 lines including carried #11138 and #10508 commits) cannot be exercised by a title.mainshowing it. UntilSSL_CTX_newlands there is no way to produce that evidence.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:OBJ_nid2sn/OBJ_sn2nidcommits (src/Objects.cpp,GuestLibreSslObjects.cpp).mainhas them inObjectText.cppandtests/ObjectName.cpp, and itsOBJ_sn2nidalready 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 currentmain(reuse its lookup instead of refusing, or say why the refusal is still needed).main(a fresh branch with only this PR's commits is fine) and resolveCMakeLists.txt,Export.cpp(the two stubs are still there onmain) anddocs/dev/debt/libSceLibreSsl.md; recount the pending-export line against the stubs left.The
SslCtxSettings.cpplogic and the groups test matched LibreSSL 2.5.4 when reviewed; I will look at them again on the rebased head.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
Findings
Blocking
core/libs/prx/libSceLibreSsl/src/SslCtxSettings.cpp:62frees 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
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, anddocs/dev/debt/libSceLibreSsl.md.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.
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; usedrepo_read.pyto inspect relevant allocator, object lookup, context layout and build configuration source. No build or test commands were run.Results
Findings
Blocking
core/libs/prx/libSceLibreSsl/src/SslCtxSettings.cpp:64returns 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 atcore/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
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.cppanddocs/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.
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 readdescription.md,commits.md,manifest.json,diff.patch,SslCtxSettings.cpp,ObjectText.cpp,ObjectCreate.cpp, and the relevant portions ofGuestLibreSslSslCtxGroups.cpp.Results
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.jsonand the preparedreview/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.
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.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.