feat(libSceLibreSsl): implement memory BIOs #9536

Merged
Felipebmaitan merged 9 commits from upstream-pr/9536 into main 2026-11-03 08:07:21 +00:00
Felipebmaitan commented 2026-10-22 00:43:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Felipebmaitan on 2026-10-22T00:43:54Z.


What

Memory BIO methods and callbacks. Refreshed published history onto fetched main b28bb772177768f99874ca38f6252cd0139acf2a. #9535 is merged; its numeric ERR behavior, shared queue and test-only generator/Python/submodule setup remain unchanged. No replacement PR, force push or unrelated branch changes.

Resolved the pending-export debt conflict by independently recounting the merged Export.cpp: 254 literal NotImplemented_nid_no_patch(__func__) calls, matching direct exported stub bodies. Published runtime implementations and supported fixtures are byte-identical to the previous head; the removed BIO ex-data throw/reference assertion remains absent and production refusal stays intact.

Tested

Exact head 242c41111435bd5d02a55d17acb54ea35146a3c8, integrated main b28bb772177768f99874ca38f6252cd0139acf2a. Ubuntu amd64 Docker on Apple Silicon; GCC 13.3.0, CMake 3.28.3, Ninja, Python 3.12.3, Release. Native below means unpatched symbols, not execution on native Linux hardware.

  • 46/46 native + 2/2 patched focused CTests pass, including ERR queue/numeric/load/free, BIO callbacks/null/zero/retry/errors/nonzero-slack full-capacity growth and destruction wiping, available CMAC/BN cases, and current main's LibreSSL/LibreSSL3 regressions, including new EVP and version cases.
  • Fresh initially empty source-built component build for BIO, reconfigured/rebuilt for CMAC. Actual libc/libkernel/LibreSSL/LibreSSL3 and repository NID patcher; pinned mbedTLS/ZArchive/zstd built from source. Separate native/patched loader paths. External harness imports actual repository library/test fragments; this is not a full root/product build.
  • ERR generated fixture deletion: runtime libraries build with it absent; formatter target regenerates it with unchanged SHA256 44af6828fdc064ca16f94aeb07ac913651d2bfce0f5ecbeee6b9b476e6be24e3; three lifecycle cases pass again. Runtime graphs exclude the generator and compile the shared queue once.
  • Header audit: 399 libraries / 27,365 exports, canonical unique declarations and umbrella coverage; strict standalone Clang compilation targeting x86-64 macOS passes (compile-only). All 41 scoped test executables are registered. Exact old/main public-definition/NID union and main runtime implementations are retained; counts and registrations independently audited.
  • python3 tools/check_conventions.py --base origin/main and whitespace pass in isolated Git contexts pinning origin/main to the integrated SHA above, without changing shared tracking refs.
  • Overlap scans completed with exit 2, reporting adjacent/source-list/debt conflicts, inherited BIO code and incomplete comparisons. Reported shared-file/function inventories were reviewed. #12928 inherits BIO and explicitly depends on #9536; #9446's BN work remains preserved in CMAC. The full output and unresolved comparisons are in the latest validation reply; no clean-overlap or external-order agreement is claimed.

Docker denies userfaultfd, so libc uses its existing comparison fallback. No new local Windows/macOS runtime, sanitizer, commercial-title or physical-console run; Hosted CI on 242c41111435bd5d02a55d17acb54ea35146a3c8: windows, conventions, library-portability, eligibility, labels and report succeeded. linux, relinker, relinker-asan, register-context, write-watch and edge-watch were skipped; earlier conventions attempts were cancelled. GitHub reports CLEAN / MERGEABLE; skipped jobs are not claimed as executed. Current-head maintainer re-review remains pending. Previous hosted results and bounded growth-wipe/no-Python fragment controls remain historical. Firmware-module comparison evidence remains attributed PC execution with stand-in imports, not console evidence. No success is claimed for skipped or pending jobs.
Formal re-review requests to GitHub returned HTTP 404 for this PR; no reviewer request was registered. The validation reply explicitly asks @MarcZX10 to re-review. This API failure is separate from the validated code fixes and completed hosted CI.
Readiness: the stale needs rebase label has cleared. Formal re-review requests returned HTTP 404 and no reviewer request is registered. MarcZX10 was explicitly asked in the validation reply, but the historical change request remains a review-queue blocker until a formal re-request is registered or the review state is updated.

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:4960325275 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9536). Originally posted by [Felipebmaitan](https://github.com/Felipebmaitan) on 2026-10-22T00:43:54Z. --- ### What Memory BIO methods and callbacks. Refreshed published history onto fetched main `b28bb772177768f99874ca38f6252cd0139acf2a`. #9535 is merged; its numeric ERR behavior, shared queue and test-only generator/Python/submodule setup remain unchanged. No replacement PR, force push or unrelated branch changes. Resolved the pending-export debt conflict by independently recounting the merged `Export.cpp`: **254** literal `NotImplemented_nid_no_patch(__func__)` calls, matching direct exported stub bodies. Published runtime implementations and supported fixtures are byte-identical to the previous head; the removed BIO ex-data throw/reference assertion remains absent and production refusal stays intact. ### Tested Exact head **`242c41111435bd5d02a55d17acb54ea35146a3c8`**, integrated main **`b28bb772177768f99874ca38f6252cd0139acf2a`**. Ubuntu amd64 Docker on Apple Silicon; GCC 13.3.0, CMake 3.28.3, Ninja, Python 3.12.3, Release. Native below means unpatched symbols, not execution on native Linux hardware. - **46/46 native + 2/2 patched focused CTests pass**, including ERR queue/numeric/load/free, BIO callbacks/null/zero/retry/errors/nonzero-slack full-capacity growth and destruction wiping, available CMAC/BN cases, and current main's LibreSSL/LibreSSL3 regressions, including new EVP and version cases. - Fresh initially empty source-built component build for BIO, reconfigured/rebuilt for CMAC. Actual libc/libkernel/LibreSSL/LibreSSL3 and repository NID patcher; pinned mbedTLS/ZArchive/zstd built from source. Separate native/patched loader paths. External harness imports actual repository library/test fragments; this is not a full root/product build. - ERR generated fixture deletion: runtime libraries build with it absent; formatter target regenerates it with unchanged SHA256 `44af6828fdc064ca16f94aeb07ac913651d2bfce0f5ecbeee6b9b476e6be24e3`; three lifecycle cases pass again. Runtime graphs exclude the generator and compile the shared queue once. - Header audit: **399 libraries / 27,365 exports**, canonical unique declarations and umbrella coverage; strict standalone Clang compilation targeting x86-64 macOS passes (compile-only). All **41 scoped test executables** are registered. Exact old/main public-definition/NID union and main runtime implementations are retained; counts and registrations independently audited. - `python3 tools/check_conventions.py --base origin/main` and whitespace pass in isolated Git contexts pinning `origin/main` to the integrated SHA above, without changing shared tracking refs. - Overlap scans completed with **exit 2**, reporting adjacent/source-list/debt conflicts, inherited BIO code and incomplete comparisons. Reported shared-file/function inventories were reviewed. #12928 inherits BIO and explicitly depends on #9536; #9446's BN work remains preserved in CMAC. The full output and unresolved comparisons are in the latest validation reply; no clean-overlap or external-order agreement is claimed. Docker denies userfaultfd, so libc uses its existing comparison fallback. No new local Windows/macOS runtime, sanitizer, commercial-title or physical-console run; Hosted CI on `242c41111435bd5d02a55d17acb54ea35146a3c8`: `windows`, `conventions`, `library-portability`, `eligibility`, `labels` and `report` succeeded. `linux`, `relinker`, `relinker-asan`, `register-context`, `write-watch` and `edge-watch` were skipped; earlier conventions attempts were cancelled. GitHub reports CLEAN / MERGEABLE; skipped jobs are not claimed as executed. Current-head maintainer re-review remains pending. Previous hosted results and bounded growth-wipe/no-Python fragment controls remain historical. Firmware-module comparison evidence remains attributed PC execution with stand-in imports, not console evidence. No success is claimed for skipped or pending jobs. Formal re-review requests to GitHub returned HTTP 404 for this PR; no reviewer request was registered. The validation reply explicitly asks @MarcZX10 to re-review. This API failure is separate from the validated code fixes and completed hosted CI. Readiness: the stale `needs rebase` label has cleared. Formal re-review requests returned HTTP 404 and no reviewer request is registered. MarcZX10 was explicitly asked in the validation reply, but the historical change request remains a review-queue blocker until a formal re-request is registered or the review state is updated. <!-- 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 -->
MarcZX10 commented 2026-10-22 00:55:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T00:55:44Z.

Review: COMMENTED


I reviewed the BIO implementation against the pinned LibreSSL 3.4.1 bss_mem.c, bio_lib.c and buffer.c behavior, including buffer ownership, close/reset controls, EOF/retry, method dispatch, callbacks, reference release and growth limits. The focused tests cover the main transfer/ownership/error paths, failure injection, callback order and 64-bit guest ABI. I did not find an additional BIO-specific blocker in this pass.

This stack depends on #9535, where I requested a fix for ERR_free_strings followed by ERR_load_crypto_strings remaining permanently in the freed state. Please revalidate the integrated stack after that fix; I’m not treating this comment as approval. The PR reports the Windows full-suite and 7/7 LibreSSL/patched-library selection, with baseline failures and the temporary #8310 fixture overlay disclosed; I did not rerun a local build. Current hosted eligibility, conventions, intake, labels and report checks pass; product jobs are skipped.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608015747 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9536#pullrequestreview-5608015747). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T00:55:44Z. **Review:** COMMENTED --- I reviewed the BIO implementation against the pinned LibreSSL 3.4.1 `bss_mem.c`, `bio_lib.c` and `buffer.c` behavior, including buffer ownership, close/reset controls, EOF/retry, method dispatch, callbacks, reference release and growth limits. The focused tests cover the main transfer/ownership/error paths, failure injection, callback order and 64-bit guest ABI. I did not find an additional BIO-specific blocker in this pass. This stack depends on #9535, where I requested a fix for `ERR_free_strings` followed by `ERR_load_crypto_strings` remaining permanently in the freed state. Please revalidate the integrated stack after that fix; I’m not treating this comment as approval. The PR reports the Windows full-suite and 7/7 LibreSSL/patched-library selection, with baseline failures and the temporary #8310 fixture overlay disclosed; I did not rerun a local build. Current hosted eligibility, conventions, intake, labels and report checks pass; product jobs are skipped.
MarcZX10 commented 2026-10-22 01:01:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T01:01:46Z.

Review: APPROVED


I rechecked the BIO implementation against the pinned LibreSSL 3.4.1 memory BIO behavior and verified the parent stack update on #9535. The PR declares Depends on #9535, which in turn depends on #9529; no order/overlap issue remains in the declared stack. Tests are extensively reported, with the 5 full-suite failures and platform limits disclosed; hosted eligibility, conventions, intake, labels and report checks pass, while product builds were skipped. I found no additional blocking issue in the reviewed diff.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608052466 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9536#pullrequestreview-5608052466). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T01:01:46Z. **Review:** APPROVED --- I rechecked the BIO implementation against the pinned LibreSSL 3.4.1 memory BIO behavior and verified the parent stack update on #9535. The PR declares Depends on #9535, which in turn depends on #9529; no order/overlap issue remains in the declared stack. Tests are extensively reported, with the 5 full-suite failures and platform limits disclosed; hosted eligibility, conventions, intake, labels and report checks pass, while product builds were skipped. I found no additional blocking issue in the reviewed diff.
MarcZX10 commented 2026-10-22 01:05:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T01:05:00Z.

Review: COMMENTED


My approval reflects the reviewed BIO diff and its declared #9535 → #9529 dependency stack. Note that #9535 has an earlier change-request review which I corrected and then approved after verifying the pinned LibreSSL contract; GitHub shows the approval as its latest review.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608071573 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9536#pullrequestreview-5608071573). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T01:05:00Z. **Review:** COMMENTED --- My approval reflects the reviewed BIO diff and its declared #9535 → #9529 dependency stack. Note that #9535 has an earlier change-request review which I corrected and then approved after verifying the pinned LibreSSL contract; GitHub shows the approval as its latest review.
MarcZX10 commented 2026-10-22 01:08:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T01:08:38Z.

Review: APPROVED


The reviewed memory BIO implementation matches the pinned LibreSSL 3.4.1 behavior; the declared dependency chain #9536 → #9535 → #9529 is consistent. My earlier #9535 lifecycle request was corrected after source verification, and the updated ERR change is approved. The author reports focused and full-suite testing with failures disclosed; current eligibility, conventions, intake, labels and report checks pass, while product jobs are skipped. I found no blocking issue in this diff.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608098290 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9536#pullrequestreview-5608098290). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T01:08:38Z. **Review:** APPROVED --- The reviewed memory BIO implementation matches the pinned LibreSSL 3.4.1 behavior; the declared dependency chain #9536 → #9535 → #9529 is consistent. My earlier #9535 lifecycle request was corrected after source verification, and the updated ERR change is approved. The author reports focused and full-suite testing with failures disclosed; current eligibility, conventions, intake, labels and report checks pass, while product jobs are skipped. I found no blocking issue in this diff.
MarcZX10 commented 2026-10-22 02:00:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T02:00:22Z.

Review: APPROVED


Rechecked the unchanged BIO implementation at its current head. Its memory BIO behaviors and ABI follow the pinned LibreSSL 3.4.1 sources, and the PR declares the current ERR/#9529 dependency chain. The focused tests and extensive full-suite/baseline failure accounting are author-reported; required hosted policy checks pass and product/relinker jobs were skipped. I did not run local tests.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608412920 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9536#pullrequestreview-5608412920). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T02:00:22Z. **Review:** APPROVED --- Rechecked the unchanged BIO implementation at its current head. Its memory BIO behaviors and ABI follow the pinned LibreSSL 3.4.1 sources, and the PR declares the current ERR/#9529 dependency chain. The focused tests and extensive full-suite/baseline failure accounting are author-reported; required hosted policy checks pass and product/relinker jobs were skipped. I did not run local tests.
jotitadev commented 2026-10-22 04:38:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T04:38:52Z.

Review: COMMENTED


Linux run, since the description says Linux/macOS were not run, plus one gap in the wiping coverage.

Machine: Linux x86_64, i7-8700, Ubuntu 26.04 (kernel 7.0.0-38), GCC 15.2, Release, BUILD_TESTING=ON. Head 0b6880e4d merged --no-commit onto main ab347d144 (clean). git submodule update --init checked out 3rdparty/libressl-openbsd at 078b3d1df.

  • Build ok. The seven tests pass: guest_libressl_bio, guest_libressl_bio_patched, guest_libressl_error, guest_libressl_errors, guest_libressl_free_strings, guest_libressl_free_strings_first and patched_libraries.
  • Red→green: removing bio->flags |= RetryRead from readMemory aborts guest_libressl_bio with empty writable BIO retry, so the retry and EOF paths are covered.
  • Gap: removing the clearBuffer(buffer) before free_nid_postfix(buffer.data) in the growth branch of writeMemory still passes guest_libressl_bio. The test arms wipePointer only before BIO_free, so the buffer a growing write frees (abc at capacity 8, when the second write grows it to 20) is never checked. LibreSSL wipes there too: mem_write → BUF_MEM_grow_clean → recallocarray(str->data, str->max, n, 1) (buffer.c:121 in the pinned submodule), which clears the old allocation before it frees it. Setting wipePointer/wipeSize to the old buffer->data/capacity before the second write and then requiring wipePointer == nullptr covers it: I tried it here, and it passes with the PR and aborts with freed buffer was not wiped once the growth clearBuffer is removed.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5609330835 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9536#pullrequestreview-5609330835). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-22T04:38:52Z. **Review:** COMMENTED --- Linux run, since the description says Linux/macOS were not run, plus one gap in the wiping coverage. Machine: Linux x86_64, i7-8700, Ubuntu 26.04 (kernel 7.0.0-38), GCC 15.2, Release, `BUILD_TESTING=ON`. Head `0b6880e4d` merged `--no-commit` onto `main` `ab347d144` (clean). `git submodule update --init` checked out `3rdparty/libressl-openbsd` at `078b3d1df`. - Build ok. The seven tests pass: `guest_libressl_bio`, `guest_libressl_bio_patched`, `guest_libressl_error`, `guest_libressl_errors`, `guest_libressl_free_strings`, `guest_libressl_free_strings_first` and `patched_libraries`. - Red→green: removing `bio->flags |= RetryRead` from `readMemory` aborts `guest_libressl_bio` with `empty writable BIO retry`, so the retry and EOF paths are covered. - **Gap:** removing the `clearBuffer(buffer)` before `free_nid_postfix(buffer.data)` in the growth branch of `writeMemory` still passes `guest_libressl_bio`. The test arms `wipePointer` only before `BIO_free`, so the buffer a growing write frees (`abc` at capacity 8, when the second write grows it to 20) is never checked. LibreSSL wipes there too: `mem_write` → `BUF_MEM_grow_clean` → `recallocarray(str->data, str->max, n, 1)` (`buffer.c:121` in the pinned submodule), which clears the old allocation before it frees it. Setting `wipePointer`/`wipeSize` to the old `buffer->data`/`capacity` before the second write and then requiring `wipePointer == nullptr` covers it: I tried it here, and it passes with the PR and aborts with `freed buffer was not wiped` once the growth `clearBuffer` is removed. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
MarcZX10 commented 2026-10-22 11:35:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T11:35:59Z.

Review: CHANGES_REQUESTED


The implementation currently wipes the old owned buffer before freeing it during growth, and again before destruction. The regression only arms wipePointer immediately before BIO_free, so it does not verify the growth path: removing the clearBuffer(buffer) immediately before free_nid_postfix(buffer.data) in writeMemory would still pass the submitted test. Please add an assertion around a growth-triggering write that records the old allocation/capacity and verifies those bytes are zero when that allocation is released. This matters because the PR explicitly claims secure clearing of owned storage. Also, this head is 4 ahead / 119 behind current main (merge base a6dcea927); please refresh it and rerun the focused BIO suite, conventions and test-registration checks. I did not run a local C++ build in this pass; the Linux focused test/control described by the other reviewer is independently reported, not my run.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5613521256 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9536#pullrequestreview-5613521256). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T11:35:59Z. **Review:** CHANGES_REQUESTED --- The implementation currently wipes the old owned buffer before freeing it during growth, and again before destruction. The regression only arms `wipePointer` immediately before `BIO_free`, so it does not verify the growth path: removing the `clearBuffer(buffer)` immediately before `free_nid_postfix(buffer.data)` in `writeMemory` would still pass the submitted test. Please add an assertion around a growth-triggering write that records the old allocation/capacity and verifies those bytes are zero when that allocation is released. This matters because the PR explicitly claims secure clearing of owned storage. Also, this head is 4 ahead / 119 behind current `main` (merge base `a6dcea927`); please refresh it and rerun the focused BIO suite, conventions and test-registration checks. I did not run a local C++ build in this pass; the Linux focused test/control described by the other reviewer is independently reported, not my 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!9536
No description provided.