feat(libSceLibreSsl): select advertised application protocols #9785

Merged
santhoshkumar-dev merged 9 commits from upstream-pr/9785 into main 2026-10-27 08:06:23 +00:00
santhoshkumar-dev commented 2026-10-22 14:51:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by santhoshkumar-dev on 2026-10-22T14:51:22Z.


What

Implement SSL_select_next_proto (CpIzEs1Q1Ug) for valid wire-format protocol lists. The first peer-preferred match returns a borrowed pointer into the peer list and status 1; no overlap returns the first supported protocol and status 2. Names are byte strings and may contain zero or high-bit bytes.

The six-argument signature and valid-input contract follow LibreSSL 3.4.1 ssl.h and ssl_lib.c, with no new dependency.

BunnyFl's independent firmware 13.42 report executed the decrypted libSceLibreSsl.sprx on a host PC, not console hardware. It reports matching six-argument valid-list status, selected-list offset and length across 200,000 random pairs repeated three times plus 500,000 pairs with a second seed. Its invalid-list observations differ from the current guards: zero-length names can be selected, fallback lengths are unchecked, and an empty supported list is read. Those paths remain unsupported and are recorded as functional debt. Null outputs were not measured. This is attributed evidence, not a local firmware run.

Tested

Submitted and tested head 809350e09cfbe0cfc6156a15b842e9c89012f59a, including upstream main 48c160c58b589157ebd94ebd53736a182f8303bf.

Windows 11 x64 / WinLibs GCC 15.2.0 r7 and local Ubuntu 24.04.1 x86-64 under WSL2 / GCC 13.3.0 / glibc 2.39: Ninja Release, bundled dependencies, BUILD_TESTING=ON, ANYPS5_ENABLE_SPIRV_TOOLS=OFF. On each platform the complete libs target and selected test executables build, and 68/68 CTests pass, zero skips: the public-header audit, all 64 public-header compilation batches and 3 focused runtime tests. The new upstream JPEG XR and updated SPIR-V dependencies use their pinned submodule commits. Both normal-symbol and actual packaged-NID modes exercise the 7,056 generated protocol-list pairs and valid-list boundaries, alongside the packaged-library loader.

Final upstream recheck: 88795ed44801fa719eb2df990cbe1f11a1f9bd81 merges cleanly; no FreeType/LibreSSL production, shared-header, test-registration or debt changes appeared after the tested base. Results remain pinned to the exact submitted head and its stated base.

Conventions, whitespace and all 15 pairwise merge checks across the six maintained PRs pass. Open/closed/merged history was rechecked; no replacement implementation was found.

The earlier macOS report by @jotitadev used Apple M2 Max, macOS 27.2, Xcode 27 and x86-64 under Rosetta on #8658 at fa063d8b07 plus the original diff and conditional libc-link fix. That host-support PR was closed for splitting. It remains attributed historical evidence; no fresh macOS runtime host is available here, so validation on the current macOS stack remains outstanding. No title or physical-console execution is claimed.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); 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:4969361540 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9785). Originally posted by [santhoshkumar-dev](https://github.com/santhoshkumar-dev) on 2026-10-22T14:51:22Z. --- ### What Implement `SSL_select_next_proto` (`CpIzEs1Q1Ug`) for valid wire-format protocol lists. The first peer-preferred match returns a borrowed pointer into the peer list and status 1; no overlap returns the first supported protocol and status 2. Names are byte strings and may contain zero or high-bit bytes. The six-argument signature and valid-input contract follow [LibreSSL 3.4.1 ssl.h](https://github.com/libressl/openbsd/blob/078b3d1df8ca2011c1605cd40418c58fa0f5b143/src/lib/libssl/ssl.h#L619-L626) and [ssl_lib.c](https://github.com/libressl/openbsd/blob/078b3d1df8ca2011c1605cd40418c58fa0f5b143/src/lib/libssl/ssl_lib.c#L1501-L1537), with no new dependency. [BunnyFl's independent firmware 13.42 report](https://github.com/boykopovar/AnyPS5/pull/9785#issuecomment-6406712390) executed the decrypted `libSceLibreSsl.sprx` on a host PC, not console hardware. It reports matching six-argument valid-list status, selected-list offset and length across 200,000 random pairs repeated three times plus 500,000 pairs with a second seed. Its invalid-list observations differ from the current guards: zero-length names can be selected, fallback lengths are unchecked, and an empty supported list is read. Those paths remain unsupported and are recorded as functional debt. Null outputs were not measured. This is attributed evidence, not a local firmware run. ### Tested Submitted and tested head `809350e09cfbe0cfc6156a15b842e9c89012f59a`, including upstream main `48c160c58b589157ebd94ebd53736a182f8303bf`. Windows 11 x64 / WinLibs GCC 15.2.0 r7 and local Ubuntu 24.04.1 x86-64 under WSL2 / GCC 13.3.0 / glibc 2.39: Ninja Release, bundled dependencies, `BUILD_TESTING=ON`, `ANYPS5_ENABLE_SPIRV_TOOLS=OFF`. On each platform the complete `libs` target and selected test executables build, and **68/68 CTests pass, zero skips**: the public-header audit, all 64 public-header compilation batches and 3 focused runtime tests. The new upstream JPEG XR and updated SPIR-V dependencies use their pinned submodule commits. Both normal-symbol and actual packaged-NID modes exercise the 7,056 generated protocol-list pairs and valid-list boundaries, alongside the packaged-library loader. Final upstream recheck: `88795ed44801fa719eb2df990cbe1f11a1f9bd81` merges cleanly; no FreeType/LibreSSL production, shared-header, test-registration or debt changes appeared after the tested base. Results remain pinned to the exact submitted head and its stated base. Conventions, whitespace and all 15 pairwise merge checks across the six maintained PRs pass. Open/closed/merged history was rechecked; no replacement implementation was found. The earlier [macOS report by @jotitadev](https://github.com/boykopovar/AnyPS5/pull/9785#pullrequestreview-5624606073) used Apple M2 Max, macOS 27.2, Xcode 27 and x86-64 under Rosetta on #8658 at `fa063d8b07` plus the original diff and conditional libc-link fix. That host-support PR was [closed for splitting](https://github.com/boykopovar/AnyPS5/pull/8658#issuecomment-6376908709). It remains attributed historical evidence; no fresh macOS runtime host is available here, so validation on the current macOS stack remains outstanding. No title or physical-console execution 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. --> ### 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) - [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 -->
santhoshkumar-dev commented 2026-10-22 14:51:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by santhoshkumar-dev on 2026-10-22T14:51:54Z.


@Felipebmaitan This PR only implements SSL_select_next_proto; the local overlap audit found no shared exports, implementation changes, or new files with #9535, #9536 or #9571. The remaining overlap is where the debt sections are inserted.

Proposed merge order for that documentation: #9785 first, then #9535 -> #9536 -> #9571, retaining the protocol entry when those branches are rebased. There is no code/build dependency. If your stack lands first, I will rebase this PR and place its entry alongside the merged sections instead. Please let me know if you prefer a different order.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6343737305 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9785#issuecomment-6343737305). Originally posted by [santhoshkumar-dev](https://github.com/santhoshkumar-dev) on 2026-10-22T14:51:54Z. --- @Felipebmaitan This PR only implements `SSL_select_next_proto`; the local overlap audit found no shared exports, implementation changes, or new files with #9535, #9536 or #9571. The remaining overlap is where the debt sections are inserted. Proposed merge order for that documentation: #9785 first, then #9535 -> #9536 -> #9571, retaining the protocol entry when those branches are rebased. There is no code/build dependency. If your stack lands first, I will rebase this PR and place its entry alongside the merged sections instead. Please let me know if you prefer a different order.
MarcZX10 commented 2026-10-22 16:31:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T16:31:21Z.

Review: DISMISSED


The exact protocol-selection function passes the PR’s own GuestLibreSslProtocol.cpp harness locally: 7,056 generated list pairs plus the boundary and malformed-input cases. I compiled the exact PR source and harness into a temporary shared object with a throwing stub for NotImplemented_nid_no_patch; this validates the selection algorithm, but not the packaged-library/NID path or the full build. check_conventions.py and git diff --check against current main pass. The PR reports a full Windows build and 3/3 packaged tests; upstream PR checks currently run policy checks only and skip product builds.

The branch is eight commits behind live main (8499ea52e571b0edfc1feecfd3f6b9944012b359). CONTRIBUTING.md requires branches to be based on and kept up to date with main. Please update the branch and rerun the reported full build and packaged-library/NID tests on the resulting head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5617574514 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9785#pullrequestreview-5617574514). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T16:31:21Z. **Review:** DISMISSED --- The exact protocol-selection function passes the PR’s own `GuestLibreSslProtocol.cpp` harness locally: **7,056 generated list pairs plus the boundary and malformed-input cases**. I compiled the exact PR source and harness into a temporary shared object with a throwing stub for `NotImplemented_nid_no_patch`; this validates the selection algorithm, but not the packaged-library/NID path or the full build. `check_conventions.py` and `git diff --check` against current main pass. The PR reports a full Windows build and 3/3 packaged tests; upstream PR checks currently run policy checks only and skip product builds. The branch is eight commits behind live `main` (`8499ea52e571b0edfc1feecfd3f6b9944012b359`). CONTRIBUTING.md requires branches to be based on and kept up to date with `main`. Please update the branch and rerun the reported full build and packaged-library/NID tests on the resulting head.
MarcZX10 commented 2026-10-22 16:56:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T16:56:30Z.

Review: COMMENTED


I rechecked exact head 19230580171979188d3d86b3229ddbd3d708526c against current main (11f976b27c16ed91633f00039dba5dfd97dd7cc1). Conventions and diff-check pass; the merge tree is clean. The reported Windows build and protocol/packaged-library 3/3 results are contributor-run, while hosted product builds are skipped. I previously ran the exact source/harness algorithm locally (7,056 generated protocol-list pairs and malformed/boundary cases), but that does not validate the packaged NID path. The author’s overlap note proposes the documentation order for #9535/#9536/#9571 and no code overlap. This branch is 21 commits behind current main; please rebase and rerun the focused packaged-library/NID tests on the new head before merge.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5617855448 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9785#pullrequestreview-5617855448). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T16:56:30Z. **Review:** COMMENTED --- I rechecked exact head `19230580171979188d3d86b3229ddbd3d708526c` against current `main` (`11f976b27c16ed91633f00039dba5dfd97dd7cc1`). Conventions and diff-check pass; the merge tree is clean. The reported Windows build and protocol/packaged-library 3/3 results are contributor-run, while hosted product builds are skipped. I previously ran the exact source/harness algorithm locally (7,056 generated protocol-list pairs and malformed/boundary cases), but that does not validate the packaged NID path. The author’s overlap note proposes the documentation order for #9535/#9536/#9571 and no code overlap. This branch is 21 commits behind current main; please rebase and rerun the focused packaged-library/NID tests on the new head before merge.
jotitadev commented 2026-10-23 06:12:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-23T06:12:47Z.

Review: COMMENTED


macOS test: guest_libressl_protocol_nid loads the unpatched libc

Apple M2 Max, macOS 27.2, Apple clang (Xcode 27), x86-64 Release build under Rosetta 2, BUILD_TESTING=ON, full default build. Head 1ec05748ff. main does not build on macOS, so the platform is #8658 (feat/macos-port) @ fa063d8b07 with this PR's diff applied (clean apply).

guest_libressl_protocol passes. guest_libressl_protocol_nid aborts:

dlopen(.../build/core/libs/libs/libSceLibreSsl.prx, 0x0006): Symbol not found: _H480xkq8iKk
  Referenced from: <...> .../build/core/libs/libs/libkernel.prx
  Expected in:     <...> .../build/core/libs/libs/unpatched/libc.prx
LibreSSL protocol check failed at line 152

guest_libressl_protocol_tests links libc on every platform, so the process starts with unpatched/libc.prx loaded. Both libc builds have the install name @rpath/libc.prx, so when the patched libkernel.prx asks for @rpath/libc.prx, dyld reuses the unpatched image that is already loaded, and it has no NID exports.

guest_jxr_lookup_tests in #9954 avoids this by linking libc only on Windows. Doing the same in ProtocolSelection.cmake fixes it here:

    target_link_libraries(guest_libressl_protocol_tests PRIVATE ${CMAKE_DL_LIBS})
    if(WIN32)
        target_link_libraries(guest_libressl_protocol_tests PRIVATE libc)
    endif()

With that change both tests pass 3/3 (--repeat until-fail:3). I did not run Linux here, but the same pattern failed on Linux in #9646 (patched tests could not resolve NIDs until libc was linked only on Windows), so this is likely not macOS-only.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5624606073 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9785#pullrequestreview-5624606073). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-23T06:12:47Z. **Review:** COMMENTED --- ### macOS test: `guest_libressl_protocol_nid` loads the unpatched libc Apple M2 Max, macOS 27.2, Apple clang (Xcode 27), x86-64 Release build under Rosetta 2, `BUILD_TESTING=ON`, full default build. Head `1ec05748ff`. `main` does not build on macOS, so the platform is #8658 (`feat/macos-port`) @ `fa063d8b07` with this PR's diff applied (clean apply). `guest_libressl_protocol` passes. `guest_libressl_protocol_nid` aborts: ``` dlopen(.../build/core/libs/libs/libSceLibreSsl.prx, 0x0006): Symbol not found: _H480xkq8iKk Referenced from: <...> .../build/core/libs/libs/libkernel.prx Expected in: <...> .../build/core/libs/libs/unpatched/libc.prx LibreSSL protocol check failed at line 152 ``` `guest_libressl_protocol_tests` links `libc` on every platform, so the process starts with `unpatched/libc.prx` loaded. Both libc builds have the install name `@rpath/libc.prx`, so when the patched `libkernel.prx` asks for `@rpath/libc.prx`, dyld reuses the unpatched image that is already loaded, and it has no NID exports. `guest_jxr_lookup_tests` in #9954 avoids this by linking `libc` only on Windows. Doing the same in `ProtocolSelection.cmake` fixes it here: ```cmake target_link_libraries(guest_libressl_protocol_tests PRIVATE ${CMAKE_DL_LIBS}) if(WIN32) target_link_libraries(guest_libressl_protocol_tests PRIVATE libc) endif() ``` With that change both tests pass 3/3 (`--repeat until-fail:3`). I did not run Linux here, but the same pattern failed on Linux in #9646 (patched tests could not resolve NIDs until `libc` was linked only on Windows), so this is likely not macOS-only. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
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!9785
No description provided.