feat(libSceLibreSsl): free GENERAL_NAME and GENERAL_NAMES allocations #13760

Merged
hyvvs merged 6 commits from upstream-pr/13760 into main 2026-10-31 23:54:58 +00:00
hyvvs commented 2026-10-31 04:29:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hyvvs on 2026-10-31T04:29:58Z.


What

Implement two pending LibreSSL 2.5.4 memory-release exports, with full ASN.1 ownership handling and guest allocator regression tests. See details below.

Tested

Windows build CI: pass. Linux ASan/UBSan linked guest allocator harness: pass. Progress tests (56): pass. Public header audit: pass. Emscripten library portability: pass. PS5 native oracle: not available; firmware-specific differences are not verified.

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; no silent stubs added
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none introduced)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none currently verified
  • GPUs tested: n/a
  • AI-assisted: yes

Summary - Implement GENERAL_NAME_free for all nine LibreSSL 2.5.4 GENERAL_NAME choices (including OTHERNAME/ANY, X509_NAME cached data and entries, and EDIPARTYNAME), replacing the throwing stub with an ABI-correct void export. - Implement GENERAL_NAMES_free by recursively releasing the guest stack and its elements, using existing sk_pop_free and guest heap dispatch. - Reproduce owned vs borrowed memory behavior for ASN.1 strings (NDEF), OID dynamic flags, and secure zeroing of owned contents. Assert relevant x86-64 structure layouts. - Add guest allocator tests and register a CTest target. Document the reference source and remaining verification limit. ## Measured progress - Based on 0835ec8bdc, system libraries: 7,229 / 27,404 -> 7,231 / 27,404 (+2 genuine implemented exports, ~26.39% on this branch). - libSceLibreSsl: 97 / 401 -> 99 / 401. - The two local callbacks use ABI-correct lambdas so the progress scanner does not accidentally count private helper functions as exports. ## Validation - python tools/tests/test_progress.py (56 tests: PASS) - python core/libs/tests/test_public_headers.py --audit-only (393 libraries, 24,536 declarations: PASS) - python tools/check_conventions.py --base upstream/main (PASS) - git diff --check and Windows MinGW C++20 syntax checks for new source/test (PASS) - Linked Linux standalone test with actual GeneralName.cpp + Stack.cpp, a local guest-allocator dispatch shim and -fsanitize=address,undefined (detect_leaks=1) (PASS); tests all nine choices, nested allocations, static OIDs, NDEF borrowing and wiping before freeing. - Full CMake test executable was not built in this worktree because third-party submodule directories are not initialized; CI should verify the normal project build. ## Reference and limitations The memory ownership and recursive free semantics follow LibreSSL 2.5.4 in libressl/openbsd commit 2e2c612066aa993717528a0249c15c51128d61cb, especially x509v3/v3_genn.c, asn1/tasn_fre.c, asn1/asn1_lib.c, asn1/a_object.c and asn1/x_name.c. These exports have not been exercised against a native PS5 library; firmware-specific variations are unverified. For malformed negative owned buffer lengths, we throw rather than risk an oversized memory wipe. ### Open PR coordination No open PR was found implementing either exact GENERAL_NAME_free or GENERAL_NAMES_free symbol. Some active LibreSSL PRs touch Export.cpp/Api.hpp/CMakeLists.txt or implement adjacent ASN.1 cleanup functions, so textual merges may need coordination.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5094524487 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13760). Originally posted by [hyvvs](https://github.com/hyvvs) on 2026-10-31T04:29:58Z. --- ### What Implement two pending LibreSSL 2.5.4 memory-release exports, with full ASN.1 ownership handling and guest allocator regression tests. See details below. ### Tested Windows build CI: pass. Linux ASan/UBSan linked guest allocator harness: pass. Progress tests (56): pass. Public header audit: pass. Emscripten library portability: pass. PS5 native oracle: not available; firmware-specific differences are not verified. ### Checklist - [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 - [x] Unimplemented paths throw; no silent stubs added - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none introduced) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none currently verified - [x] GPUs tested: n/a - [x] AI-assisted: yes ## Summary - Implement `GENERAL_NAME_free` for all nine LibreSSL 2.5.4 `GENERAL_NAME` choices (including OTHERNAME/ANY, X509_NAME cached data and entries, and EDIPARTYNAME), replacing the throwing stub with an ABI-correct `void` export. - Implement `GENERAL_NAMES_free` by recursively releasing the guest stack and its elements, using existing `sk_pop_free` and guest heap dispatch. - Reproduce owned vs borrowed memory behavior for ASN.1 strings (NDEF), OID dynamic flags, and secure zeroing of owned contents. Assert relevant x86-64 structure layouts. - Add guest allocator tests and register a CTest target. Document the reference source and remaining verification limit. ## Measured progress - Based on `0835ec8bdc`, system libraries: **7,229 / 27,404 -> 7,231 / 27,404** (+2 genuine implemented exports, ~26.39% on this branch). - `libSceLibreSsl`: **97 / 401 -> 99 / 401**. - The two local callbacks use ABI-correct lambdas so the progress scanner does not accidentally count private helper functions as exports. ## Validation - `python tools/tests/test_progress.py` (56 tests: PASS) - `python core/libs/tests/test_public_headers.py --audit-only` (393 libraries, 24,536 declarations: PASS) - `python tools/check_conventions.py --base upstream/main` (PASS) - `git diff --check` and Windows MinGW C++20 syntax checks for new source/test (PASS) - Linked Linux standalone test with actual `GeneralName.cpp` + `Stack.cpp`, a local guest-allocator dispatch shim and `-fsanitize=address,undefined` (`detect_leaks=1`) (PASS); tests all nine choices, nested allocations, static OIDs, NDEF borrowing and wiping before freeing. - Full CMake test executable was not built in this worktree because third-party submodule directories are not initialized; CI should verify the normal project build. ## Reference and limitations The memory ownership and recursive free semantics follow LibreSSL **2.5.4** in `libressl/openbsd` commit `2e2c612066aa993717528a0249c15c51128d61cb`, especially `x509v3/v3_genn.c`, `asn1/tasn_fre.c`, `asn1/asn1_lib.c`, `asn1/a_object.c` and `asn1/x_name.c`. These exports have **not** been exercised against a native PS5 library; firmware-specific variations are unverified. For malformed negative owned buffer lengths, we throw rather than risk an oversized memory wipe. ### Open PR coordination No open PR was found implementing either exact `GENERAL_NAME_free` or `GENERAL_NAMES_free` symbol. Some active LibreSSL PRs touch `Export.cpp`/`Api.hpp`/`CMakeLists.txt` or implement adjacent ASN.1 cleanup functions, so textual merges may need coordination.
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!13760
No description provided.