feat(libSceLibreSsl): implement SSL_get_servername #15280

Open
alvaroelpob wants to merge 6 commits from upstream-pr/15280 into main
alvaroelpob commented 2026-11-02 22:37:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alvaroelpob on 2026-11-02T22:37:42Z.


What

Implements SSL_get_servername(const SSL*, int) in libSceLibreSsl, which threw and was declared without parameters.

As in LibreSSL 2.5.4 ssl_lib.c:

  • A type other than TLSEXT_NAMETYPE_host_name (0) returns null.
  • Otherwise it returns the connection's tlsext_hostname, or the session's when the connection has none and a session is set.

The connection's hostname is at offset 184 of #10481's SSL layout, now checked with a static_assert. The session's is at offset 192 of the 232-byte SSL_SESSION; it is read by offset, so as not to define a second session struct next to #10482's. Both offsets come from compiling the 2.5.4 release's ssl_locl.h.

Builds on the PRs below, which extend the same file and test. A null connection with type 0, which LibreSSL dereferences, throws. The pending count drops by one.

Tested

Linux: suite.py feat/libscelibressl-ssl-get-servername at 9e645f001a: CTest 6574/6574 passed; conventions passed.

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: #15278
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5128551462 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15280). Originally posted by [alvaroelpob](https://github.com/alvaroelpob) on 2026-11-02T22:37:42Z. --- ### What Implements `SSL_get_servername(const SSL*, int)` in libSceLibreSsl, which threw and was declared without parameters. As in [LibreSSL 2.5.4](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libssl/ssl_lib.c) `ssl_lib.c`: - A type other than `TLSEXT_NAMETYPE_host_name` (0) returns null. - Otherwise it returns the connection's `tlsext_hostname`, or the session's when the connection has none and a session is set. The connection's hostname is at offset 184 of #10481's `SSL` layout, now checked with a `static_assert`. The session's is at offset 192 of the 232-byte `SSL_SESSION`; it is read by offset, so as not to define a second session struct next to #10482's. Both offsets come from compiling the 2.5.4 release's `ssl_locl.h`. Builds on the PRs below, which extend the same file and test. A null connection with type 0, which LibreSSL dereferences, throws. The pending count drops by one. ### Tested <!-- 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. --> Linux: `suite.py feat/libscelibressl-ssl-get-servername` at 9e645f001a: CTest 6574/6574 passed; conventions passed. ### 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: #15278 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
BunnyFl commented 2026-11-04 00:37:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-04T00:37:47Z.

Review: APPROVED


@alvaroelpob approved at 3d5881e4a1. I only looked at the new SSL_get_servername; the code from #10481, #15278 and #15279 is theirs to review.

What I ran: this head merged onto main (merge ff09222833), Windows 11, WinLibs GCC, Release.

  • guest_libressl_ssl and public_headers pass (2 of 2). That covers the Windows run your description lists as not tested.
  • tools/check_conventions.py --base upstream/main --head on this head: all checks pass.
  • Mutation: with SSL_get_servername returning nullptr first, guest_libressl_ssl fails at line 185 (1 of 1).

Firmware: this answers what the layout compile left open. In 13.42 system/common/lib/libSceLibreSsl.sprx (sha256 57de57100cdeecdf8db74d6914b0c50ac9a9113fead232d03dce2df227cd9032), SSL_get_servername (BMcXei7NXB8) is, read from disassembly and not run:

da660: test   %esi,%esi
da662: je     0xda667
da664: xor    %eax,%eax           ; type != 0: null
da667: mov    0x80(%rdi),%rax     ; session
da66e: test   %rax,%rax
da671: je     0xda67d
da673: cmpq   $0x0,0xb8(%rdi)     ; tlsext_hostname
da67d: add    $0xb8,%rdi
da688: add    $0xc0,%rax          ; session->tlsext_hostname

The type check comes first, then the session at 0x80, the connection's hostname at 0xb8 and the session's at +0xc0. That is your order, session at 128, tlsextHostname at 184 and SessionTlsextHostnameOffset 192.

So the offsets you got from compiling LibreSSL 2.5.4 match the console module.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5761541398 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15280#pullrequestreview-5761541398). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-04T00:37:47Z. **Review:** APPROVED --- @alvaroelpob approved at `3d5881e4a1`. I only looked at the new `SSL_get_servername`; the code from #10481, #15278 and #15279 is theirs to review. **What I ran:** this head merged onto `main` (merge `ff09222833`), Windows 11, WinLibs GCC, Release. - `guest_libressl_ssl` and `public_headers` pass (2 of 2). That covers the Windows run your description lists as not tested. - `tools/check_conventions.py --base upstream/main --head` on this head: all checks pass. - **Mutation:** with `SSL_get_servername` returning `nullptr` first, `guest_libressl_ssl` fails at line 185 (1 of 1). **Firmware:** this answers what the layout compile left open. In 13.42 `system/common/lib/libSceLibreSsl.sprx` (sha256 `57de57100cdeecdf8db74d6914b0c50ac9a9113fead232d03dce2df227cd9032`), `SSL_get_servername` (`BMcXei7NXB8`) is, read from disassembly and not run: ``` da660: test %esi,%esi da662: je 0xda667 da664: xor %eax,%eax ; type != 0: null da667: mov 0x80(%rdi),%rax ; session da66e: test %rax,%rax da671: je 0xda67d da673: cmpq $0x0,0xb8(%rdi) ; tlsext_hostname da67d: add $0xb8,%rdi da688: add $0xc0,%rax ; session->tlsext_hostname ``` The type check comes first, then the session at `0x80`, the connection's hostname at `0xb8` and the session's at `+0xc0`. That is your order, `session` at 128, `tlsextHostname` at 184 and `SessionTlsextHostnameOffset` 192. So the offsets you got from compiling LibreSSL 2.5.4 match the console module.
MarcZX10 commented 2026-11-20 21:20:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T21:20:35Z.

Review: COMMENTED


Reviewed — no blocking findings

The reviewed code has no verified blocking defect, but the review bundle’s files.json was unavailable, so reviewed-file completeness could not be confirmed.

What I ran

Reviewed head 59a665f9c643fbf792bb81d5c083dc66d6d439de using repo_read.py to inspect the prepared diff and targeted source ranges. No build or test commands were run.

Results

Check Result Note
Changed implementation and direct helpers passed Behavior and layout inspected
Tests not run Author-reported results only
Reviewed-file completeness not run files.json unavailable

Findings

Blocking

None verified in the inspected implementation.

Non-blocking

None.

Not verified

files.json could not be read from the provided review resources, so the exact reviewed/excluded file accounting is unconfirmed. No build, tests, convention checks, Windows run, or console behavior were verified. The author reports test results in description.md; they were not run by this review.

Files read: Export.cpp, include/Api.hpp, src/Ssl.cpp, Stack.cpp, GuestLibreSslSsl.cpp, docs/dev/debt/libSceLibreSsl.md, plus the prepared description, commits, manifest, and diff. Excluded-file list was not available; the manifest marks all five changed files as included.

To get this to a good state

Nothing is required. Optional: restore access to files.json so the reviewed-file accounting can be confirmed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5999575301 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15280#pullrequestreview-5999575301). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T21:20:35Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The reviewed code has no verified blocking defect, but the review bundle’s `files.json` was unavailable, so reviewed-file completeness could not be confirmed. ## What I ran Reviewed head `59a665f9c643fbf792bb81d5c083dc66d6d439de` using `repo_read.py` to inspect the prepared diff and targeted source ranges. No build or test commands were run. ## Results | Check | Result | Note | |---|---|---| | Changed implementation and direct helpers | passed | Behavior and layout inspected | | Tests | not run | Author-reported results only | | Reviewed-file completeness | not run | `files.json` unavailable | ## Findings ### Blocking None verified in the inspected implementation. ### Non-blocking None. ## Not verified `files.json` could not be read from the provided review resources, so the exact reviewed/excluded file accounting is unconfirmed. No build, tests, convention checks, Windows run, or console behavior were verified. The author reports test results in `description.md`; they were not run by this review. Files read: `Export.cpp`, `include/Api.hpp`, `src/Ssl.cpp`, `Stack.cpp`, `GuestLibreSslSsl.cpp`, `docs/dev/debt/libSceLibreSsl.md`, plus the prepared description, commits, manifest, and diff. Excluded-file list was not available; the manifest marks all five changed files as included. ## To get this to a good state Nothing is required. Optional: restore access to `files.json` so the reviewed-file accounting can be confirmed.
MarcZX10 commented 2026-11-22 06:48:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T06:48:39Z.

Review: COMMENTED


Reviewed — comments

The review covers all changed files at head 9e645f001a846bb5fb86894b95c10bed7d3d7f4b; no check was run, and a documented layout assumption remains unverified.

What I ran

Read the prepared description, commit list, manifest, diff, and all changed lines listed in the manifest. Read the relevant declarations and implementations in Api.hpp, Ssl.cpp, and GuestLibreSslSsl.cpp. No build or tests were run.

Results

Check Result Note
Changed line review passed All manifest-listed additions were read
Build and tests not run No local command was run
Console behavior not run No console comparison was available

Findings

Blocking

None.

Non-blocking

  • The session hostname is read from a hard-coded offset of 192 for a 232-byte SSL_SESSION, but this change does not establish that the session object provided by the target module uses the LibreSSL 2.5.4 layout. The description says the offset was compiled from that release's header, which is evidence for that layout but not for the target module's session layout. Add a verified target-layout check or document the basis for applying the 2.5.4 offset to this module. Changed line: core/libs/prx/libSceLibreSsl/src/Ssl.cpp:355.

Not verified

  • No files were excluded by the manifest; all six changed files were reviewed. The full reader output for excluded files was not applicable.
  • Build, tests, console behavior, and the target module's SSL_SESSION layout were not verified.

To get this to a good state

Nothing is required. Optional: verify or document the target module's session layout before relying on the offset.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6010850294 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15280#pullrequestreview-6010850294). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T06:48:39Z. **Review:** COMMENTED --- # Reviewed — comments The review covers all changed files at head `9e645f001a846bb5fb86894b95c10bed7d3d7f4b`; no check was run, and a documented layout assumption remains unverified. ## What I ran Read the prepared description, commit list, manifest, diff, and all changed lines listed in the manifest. Read the relevant declarations and implementations in `Api.hpp`, `Ssl.cpp`, and `GuestLibreSslSsl.cpp`. No build or tests were run. ## Results | Check | Result | Note | |---|---|---| | Changed line review | passed | All manifest-listed additions were read | | Build and tests | not run | No local command was run | | Console behavior | not run | No console comparison was available | ## Findings ### Blocking None. ### Non-blocking - The session hostname is read from a hard-coded offset of 192 for a 232-byte `SSL_SESSION`, but this change does not establish that the session object provided by the target module uses the LibreSSL 2.5.4 layout. The description says the offset was compiled from that release's header, which is evidence for that layout but not for the target module's session layout. Add a verified target-layout check or document the basis for applying the 2.5.4 offset to this module. Changed line: `core/libs/prx/libSceLibreSsl/src/Ssl.cpp:355`. ## Not verified - No files were excluded by the manifest; all six changed files were reviewed. The full reader output for excluded files was not applicable. - Build, tests, console behavior, and the target module's `SSL_SESSION` layout were not verified. ## To get this to a good state Nothing is required. Optional: verify or document the target module's session layout before relying on the offset.
ligmaSec commented 2026-12-03 13:16:21 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Checked the branch sources and built the focused tests against the existing Linux runtime. GuestLibreSslSsl passed, including the server-name accessor checks.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6170524866 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15280#pullrequestreview-6170524866). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T13:16:21Z. **Review:** COMMENTED --- Checked the branch sources and built the focused tests against the existing Linux runtime. `GuestLibreSslSsl` passed, including the server-name accessor checks. 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/15280:upstream-pr/15280'
git switch 'upstream-pr/15280'

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/15280'
git switch 'upstream-pr/15280'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/15280'
git switch 'upstream-pr/15280'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/15280'
git switch 'main'
git merge --squash 'upstream-pr/15280'
git switch 'main'
git merge --ff-only 'upstream-pr/15280'
git switch 'main'
git merge 'upstream-pr/15280'
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!15280
No description provided.