feat(libSceLibreSsl): implement UI_METHOD creation and its opener, writer, reader and closer accessors #10376

Merged
alvaroelpob merged 11 commits from upstream-pr/10376 into main 2026-10-26 18:42:48 +00:00
alvaroelpob commented 2026-10-23 20:03:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alvaroelpob on 2026-10-23T20:03:28Z.


What

Implements UI_create_method, UI_destroy_method, UI_method_set_opener, UI_method_set_writer, UI_method_set_reader, UI_method_set_closer and the four matching UI_method_get_ exports in libSceLibreSsl. All ten threw and were declared without parameters.

The module is LibreSSL 2.5.4 (firmware 13.40 measurements in #8981). Signatures and behaviour follow that release's ui_lib.c and ui.h:

Export Behaviour
UI_METHOD* UI_create_method(char* name) a zeroed ui_method_st (56 bytes, the field order of that release's ui_locl.h) from the guest heap, with a guest-heap copy of name when it is not null; null if the method can't be allocated, and a null name if only the copy fails
void UI_destroy_method(UI_METHOD*) frees the name and the method
int UI_method_set_opener/writer/reader/closer(UI_METHOD*, fn) stores the function and returns 0; -1 for a null method
fn UI_method_get_opener/writer/reader/closer(UI_METHOD*) the stored function; null for a null method

The callbacks are only stored, never called. The exports that would run a method are UI_OpenSSL and ENGINE_load_private_key; UI_new and UI_process aren't exported. Those, along with UI_get0_user_data, UI_get_input_flags, UI_get_string_type and UI_set_result, which only make sense inside a running method, still throw. UI_destroy_method(NULL) dereferences null in LibreSSL, so it throws here.

The debt entry records the source and what is unverified, and the pending-export count drops from 357 to 347.

Tested

Ubuntu (WSL2, kernel 6.18), GCC 15.2.0, Release, full build with BUILD_TESTING=ON on main 3c44638fc. There is one commit per function: UI_create_method, UI_destroy_method, then each setter followed by its getter (opener, writer, reader, closer). Each commit adds that function with its test block and debt update. Each was built and its guest_libressl_ui test and check_conventions.py run on its own.

  • New guest_libressl_ui test:

    • the name is copied, not aliased, including an empty name, and a null name stays null;
    • every slot starts null;
    • each setter returns 0 and its getter returns the function, which is called through the getter with the guest ABI;
    • setting null clears a slot, and the setters leave the flush and prompt slots alone;
    • null-method results are -1 and null;
    • UI_destroy_method(NULL) throws.

    On main the first call throws.

  • ctest --test-dir build -R guest_libressl: 6/6 pass.

  • Full ctest -j16 at the last commit: 1991/1993 pass. agc_driver_multisample_retirement fails the same way on main on this machine. agc_driver_sgpr_pattern_fill_keys fails only under parallel load on main too, and passes when run alone.

  • Not tested: Windows, a title.

  • Rebased on main 1e740a23a3 (after #9033), head e354256104: the conflicts were only the add_library source list, the end of the test block, the pending-export count and the last debt entry; both sides are kept and the count is 357 minus this PR's exports. Full build and ctest -j16: 2043/2044 pass; agc_driver_multisample_retirement fails the same way on that main. check_conventions.py --base upstream/main passes.

  • Rebased on main e7e3e9c198, head 8e0c682151, to resolve the conflict from #9529 on the shared CMakeLists.txt and debt-file lines; both sides are kept and the count is 353 minus this PR's exports. 8e0c682151 (refactor(libSceLibreSsl): declare the UI_METHOD exports in the public header) puts the real signatures and their structs in libSceLibreSsl/include/Api.hpp and drops the test's redeclarations, which public_headers requires since #10706. Full build and ctest -j16: 2202/2203 pass; agc_driver_multisample_retirement fails the same way on that main. check_conventions.py --base upstream/main passes.

  • Rebased on main ae7d59258e (after #9949), head 2009c40e1f, to resolve the conflicts with main on the shared CMakeLists.txt and debt-file lines; both sides are kept and the count is 342 minus this PR's exports. Full build and ctest -j16: 2275/2276 pass; agc_driver_multisample_retirement fails the same way on that main. check_conventions.py --base upstream/main passes.

  • Rebased on main 2dbe9b99f5 (after #9745, #9870 and #11111), head f9fdb8652c, to resolve the conflicts with main on the shared CMakeLists.txt and debt-file lines; both sides are kept and the count is 340 minus this PR's exports. Full build and ctest -j16: 2370/2371 pass; agc_driver_multisample_retirement fails the same way on that main. check_conventions.py --base upstream/main passes.

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: #9448, #9571, #10078, #10373
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4988566946 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10376). Originally posted by [alvaroelpob](https://github.com/alvaroelpob) on 2026-10-23T20:03:28Z. --- ### What Implements `UI_create_method`, `UI_destroy_method`, `UI_method_set_opener`, `UI_method_set_writer`, `UI_method_set_reader`, `UI_method_set_closer` and the four matching `UI_method_get_` exports in libSceLibreSsl. All ten threw and were declared without parameters. The module is LibreSSL 2.5.4 ([firmware 13.40 measurements in #8981](https://github.com/boykopovar/AnyPS5/discussions/8981#discussioncomment-19111214)). Signatures and behaviour follow that release's [`ui_lib.c`](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/ui/ui_lib.c#L584-L719) and `ui.h`: | Export | Behaviour | |---|---| | `UI_METHOD* UI_create_method(char* name)` | a zeroed `ui_method_st` (56 bytes, the field order of that release's `ui_locl.h`) from the guest heap, with a guest-heap copy of `name` when it is not null; null if the method can't be allocated, and a null name if only the copy fails | | `void UI_destroy_method(UI_METHOD*)` | frees the name and the method | | `int UI_method_set_opener/writer/reader/closer(UI_METHOD*, fn)` | stores the function and returns 0; -1 for a null method | | `fn UI_method_get_opener/writer/reader/closer(UI_METHOD*)` | the stored function; null for a null method | The callbacks are only stored, never called. The exports that would run a method are `UI_OpenSSL` and `ENGINE_load_private_key`; `UI_new` and `UI_process` aren't exported. Those, along with `UI_get0_user_data`, `UI_get_input_flags`, `UI_get_string_type` and `UI_set_result`, which only make sense inside a running method, still throw. `UI_destroy_method(NULL)` dereferences null in LibreSSL, so it throws here. The debt entry records the source and what is unverified, and the pending-export count drops from 357 to 347. ### 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. --> Ubuntu (WSL2, kernel 6.18), GCC 15.2.0, Release, full build with `BUILD_TESTING=ON` on `main` 3c44638fc. There is one commit per function: `UI_create_method`, `UI_destroy_method`, then each setter followed by its getter (opener, writer, reader, closer). Each commit adds that function with its test block and debt update. Each was built and its `guest_libressl_ui` test and `check_conventions.py` run on its own. - New `guest_libressl_ui` test: - the name is copied, not aliased, including an empty name, and a null name stays null; - every slot starts null; - each setter returns 0 and its getter returns the function, which is called through the getter with the guest ABI; - setting null clears a slot, and the setters leave the flush and prompt slots alone; - null-method results are -1 and null; - `UI_destroy_method(NULL)` throws. On `main` the first call throws. - `ctest --test-dir build -R guest_libressl`: 6/6 pass. - Full `ctest -j16` at the last commit: 1991/1993 pass. `agc_driver_multisample_retirement` fails the same way on `main` on this machine. `agc_driver_sgpr_pattern_fill_keys` fails only under parallel load on `main` too, and passes when run alone. - Not tested: Windows, a title. - Rebased on `main` 1e740a23a3 (after #9033), head e354256104: the conflicts were only the `add_library` source list, the end of the test block, the pending-export count and the last debt entry; both sides are kept and the count is 357 minus this PR's exports. Full build and `ctest -j16`: 2043/2044 pass; `agc_driver_multisample_retirement` fails the same way on that `main`. `check_conventions.py --base upstream/main` passes. - Rebased on `main` e7e3e9c198, head 8e0c682151, to resolve the conflict from #9529 on the shared `CMakeLists.txt` and debt-file lines; both sides are kept and the count is 353 minus this PR's exports. 8e0c682151 (`refactor(libSceLibreSsl): declare the UI_METHOD exports in the public header`) puts the real signatures and their structs in `libSceLibreSsl/include/Api.hpp` and drops the test's redeclarations, which `public_headers` requires since #10706. Full build and `ctest -j16`: 2202/2203 pass; `agc_driver_multisample_retirement` fails the same way on that `main`. `check_conventions.py --base upstream/main` passes. - Rebased on `main` ae7d59258e (after #9949), head 2009c40e1f, to resolve the conflicts with `main` on the shared `CMakeLists.txt` and debt-file lines; both sides are kept and the count is 342 minus this PR's exports. Full build and `ctest -j16`: 2275/2276 pass; `agc_driver_multisample_retirement` fails the same way on that `main`. `check_conventions.py --base upstream/main` passes. - Rebased on `main` 2dbe9b99f5 (after #9745, #9870 and #11111), head f9fdb8652c, to resolve the conflicts with `main` on the shared `CMakeLists.txt` and debt-file lines; both sides are kept and the count is 340 minus this PR's exports. Full build and `ctest -j16`: 2370/2371 pass; `agc_driver_multisample_retirement` fails the same way on that `main`. `check_conventions.py --base upstream/main` passes. ### 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: #9448, #9571, #10078, #10373 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
copilot-pull-request-reviewer[bot] commented 2026-10-23 20:03:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-23T20:03:34Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5633807404 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10376#pullrequestreview-5633807404). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-10-23T20:03:34Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
MarcZX10 commented 2026-10-23 20:07:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T20:07:17Z.

Review: DISMISSED


I reviewed the exact head 6d974fc6a6590e758faaa5530f23b8e784b152d0. The LibreSSL 2.5.4 UI method fields, guest allocation, setters/getters and focused test coverage are clearly documented. Before merge, the required shared-file coordination is unresolved: direct git merge-tree --write-tree checks show content conflicts with open #9529 and #10373 in core/libs/prx/libSceLibreSsl/CMakeLists.txt and docs/dev/debt/libSceLibreSsl.md, and a debt-file conflict with #10071. This PR currently says Depends on: none. CONTRIBUTING asks authors to agree which overlapping PR lands first and record that dependency. Please coordinate the order with those authors, update the checklist, and confirm the combined test registrations and all debt entries/counts are retained. The conflicts are in shared integration files; I found no conflicting UI export implementation in this check.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5633847833 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10376#pullrequestreview-5633847833). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T20:07:17Z. **Review:** DISMISSED --- I reviewed the exact head 6d974fc6a6590e758faaa5530f23b8e784b152d0. The LibreSSL 2.5.4 UI method fields, guest allocation, setters/getters and focused test coverage are clearly documented. Before merge, the required shared-file coordination is unresolved: direct `git merge-tree --write-tree` checks show content conflicts with open #9529 and #10373 in `core/libs/prx/libSceLibreSsl/CMakeLists.txt` and `docs/dev/debt/libSceLibreSsl.md`, and a debt-file conflict with #10071. This PR currently says `Depends on: none`. CONTRIBUTING asks authors to agree which overlapping PR lands first and record that dependency. Please coordinate the order with those authors, update the checklist, and confirm the combined test registrations and all debt entries/counts are retained. The conflicts are in shared integration files; I found no conflicting UI export implementation in this check.
ahmadmuj commented 2026-10-25 18:48:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T18:48:44Z.

Review: APPROVED


Reviewed head 8e0c682151d0, merged locally onto main a7a2eece49 (Linux, GCC 13.3, Ninja, Release).

What I ran:

  • Built the 10 libressl test targets on the merge. ctest -R libressl: 11/11 pass, guest_libressl_ui included.
  • Red control: the same guest_libressl_ui_tests binary against main's libSceLibreSsl.prx (58c9977e3b, no LibreSSL or libc changes since a7a2eec) aborts with UI_create_method_nid_postfix not implemented.
  • Differential against real LibreSSL 2.5.4 (libcrypto.a built from the release tarball): one probe calls the 2.5.4 functions on a UI_METHOD, the other calls these exports on LibreSslUiMethod, with the same inputs. It covers sizeof and every field offset (56; 0, 8, 16, 24, 32, 40, 48), the bytes after create, after setting all 4 callbacks and after clearing 2, the setter returns, the getters, null-method set/get (-1 and null), and a null and an empty name. Output is identical, 8/8 lines.
  • tools/check_conventions.py --base origin/main passes on the merge and on the head; git diff --check is clean.

Sources: 2.5.4 crypto/ui/ui_lib.c (UI_create_method to UI_method_get_closer) and ui_locl.h (struct ui_method_st). Each export writes and reads the right field. Create matches calloc + strdup, including a null name when the copy fails. Destroy frees the name and then the method. Throwing on a null destroy fits CONTRIBUTING, because 2.5.4 dereferences the pointer there.

Export.cpp drops exactly these 10 stubs. Each one is declared once in include/Api.hpp. The 5 other UI_ stubs still throw.

The only thing left is the rebase: the debt file conflicts with main on the pending count. With main's 345 minus these 10, the count is 335, and that matches the 335 NotImplemented_nid_no_patch stubs left in Export.cpp after my merge. Everything else merges cleanly.

Not tested: console behaviour, Windows or macOS, or a full ctest run.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5644713930 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10376#pullrequestreview-5644713930). Originally posted by [ahmadmuj](https://github.com/ahmadmuj) on 2026-10-25T18:48:44Z. **Review:** APPROVED --- Reviewed head 8e0c682151d0, merged locally onto main a7a2eece499e (Linux, GCC 13.3, Ninja, Release). What I ran: - Built the 10 libressl test targets on the merge. `ctest -R libressl`: 11/11 pass, `guest_libressl_ui` included. - Red control: the same `guest_libressl_ui_tests` binary against main's `libSceLibreSsl.prx` (58c9977e3b59, no LibreSSL or libc changes since a7a2eec) aborts with `UI_create_method_nid_postfix not implemented`. - Differential against real LibreSSL 2.5.4 (`libcrypto.a` built from the release tarball): one probe calls the 2.5.4 functions on a `UI_METHOD`, the other calls these exports on `LibreSslUiMethod`, with the same inputs. It covers sizeof and every field offset (56; 0, 8, 16, 24, 32, 40, 48), the bytes after create, after setting all 4 callbacks and after clearing 2, the setter returns, the getters, null-method set/get (-1 and null), and a null and an empty name. Output is identical, 8/8 lines. - `tools/check_conventions.py --base origin/main` passes on the merge and on the head; `git diff --check` is clean. Sources: 2.5.4 `crypto/ui/ui_lib.c` (`UI_create_method` to `UI_method_get_closer`) and `ui_locl.h` (`struct ui_method_st`). Each export writes and reads the right field. Create matches calloc + strdup, including a null name when the copy fails. Destroy frees the name and then the method. Throwing on a null destroy fits CONTRIBUTING, because 2.5.4 dereferences the pointer there. Export.cpp drops exactly these 10 stubs. Each one is declared once in `include/Api.hpp`. The 5 other `UI_` stubs still throw. The only thing left is the rebase: the debt file conflicts with main on the pending count. With main's 345 minus these 10, the count is 335, and that matches the 335 `NotImplemented_nid_no_patch` stubs left in Export.cpp after my merge. Everything else merges cleanly. Not tested: console behaviour, Windows or macOS, or a full ctest run.
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!10376
No description provided.