feat(libSceLibreSsl3): implement ASN1_OBJECT_free #10461

Merged
MarcZX10 merged 8 commits from upstream-pr/10461 into main 2026-11-06 04:33:06 +00:00
MarcZX10 commented 2026-10-24 01:45:46 +00:00 (Migrated from github.com)

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


What

Implements ASN1_OBJECT_free in libSceLibreSsl3. The 40-byte object layout and ownership flags follow LibreSSL 4.0.0 asn1_local.h and its a_object.c free routine.

  • A null object is ignored.
  • ASN1_OBJECT_FLAG_DYNAMIC_STRINGS frees the short and long names.
  • ASN1_OBJECT_FLAG_DYNAMIC_DATA securely clears and frees OID data through the guest libc heap, then clears the data pointer and length.
  • ASN1_OBJECT_FLAG_DYNAMIC frees the object itself.
  • A negative data length with non-null dynamically owned data throws before freeing anything instead of passing an oversized length to the erase operation.

The export and guest-heap behavior are not verified on a PS5. The debt file records that limitation. The PR overlap check found shared CMake/debt edits with #9970 and #10452, but no duplicate export. It could not compare #9959 because that branch conflicts with main; I inspected it manually and confirmed it changes only wide libc formatting files. This PR depends on #9970 and #10452 for the shared-file merge order.

Tested

  • GCC 12.2, C++20, -Wall -Wextra -Werror: compiled the production source and focused test; passed.
  • AddressSanitizer and UndefinedBehaviorSanitizer with leak detection: the focused test passed, covering null and static objects, each ownership flag, data zeroing before free, exact wipe length, and invalid negative length.
  • MinGW GCC 12, -std=c++20 -Wall -Wextra -Werror -fsyntax-only: production source and test compiled.
  • python3 tools/check_conventions.py --base upstream/main: passed.
  • git diff --check upstream/main...HEAD: passed.

The focused direct build uses test shims for guest free and memset_s; it does not exercise the complete project runtime. A full project build and console test were not run because third-party submodules are uninitialized in this checkout.

Checklist

  • Based on current main; no other open PR implements the same function
  • 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: #9970, #10452
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4991520153 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10461). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T01:45:46Z. --- ### What Implements `ASN1_OBJECT_free` in libSceLibreSsl3. The 40-byte object layout and ownership flags follow [LibreSSL 4.0.0 `asn1_local.h`](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/asn1/asn1_local.h) and its [`a_object.c` free routine](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/asn1/a_object.c). - A null object is ignored. - `ASN1_OBJECT_FLAG_DYNAMIC_STRINGS` frees the short and long names. - `ASN1_OBJECT_FLAG_DYNAMIC_DATA` securely clears and frees OID data through the guest libc heap, then clears the data pointer and length. - `ASN1_OBJECT_FLAG_DYNAMIC` frees the object itself. - A negative data length with non-null dynamically owned data throws before freeing anything instead of passing an oversized length to the erase operation. The export and guest-heap behavior are not verified on a PS5. The debt file records that limitation. The PR overlap check found shared CMake/debt edits with #9970 and #10452, but no duplicate export. It could not compare #9959 because that branch conflicts with main; I inspected it manually and confirmed it changes only wide libc formatting files. This PR depends on #9970 and #10452 for the shared-file merge order. ### Tested - GCC 12.2, C++20, `-Wall -Wextra -Werror`: compiled the production source and focused test; passed. - AddressSanitizer and UndefinedBehaviorSanitizer with leak detection: the focused test passed, covering null and static objects, each ownership flag, data zeroing before free, exact wipe length, and invalid negative length. - MinGW GCC 12, `-std=c++20 -Wall -Wextra -Werror -fsyntax-only`: production source and test compiled. - `python3 tools/check_conventions.py --base upstream/main`: passed. - `git diff --check upstream/main...HEAD`: passed. The focused direct build uses test shims for guest `free` and `memset_s`; it does not exercise the complete project runtime. A full project build and console test were not run because third-party submodules are uninitialized in this checkout. ### 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 function - [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: #9970, #10452 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
harisibrar1 commented 2026-10-24 05:38:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-24T05:38:20Z.

Review: APPROVED


Checked against main 7c2400d29b and LibreSSL 4.0.0 (a_object.c / asn1_local.h at ce488b78):

  • ASN1_OBJECT_free matches upstream lines 94-110 step for step: names, then data, then the object. The flag values (0x01/0x04/0x08) and the 40-byte layout match asn1_local.h:74-80, and static OBJ-table objects are left alone because they have no DYNAMIC flag.
  • Freeing through free_nid_postfix and wiping through memset_s_nid_postfix follows the same pattern libSceLibreSsl's CRYPTO_free already uses. Throwing on a negative length before anything is freed seems better than upstream's huge (size_t) wipe.
  • One thing to keep in mind: OBJ_txt2obj in this module still throws, so nothing can produce a dynamic object yet. Whoever implements it will need to allocate the object, names and data with malloc_nid_postfix so they pair with this free. That might be worth a few words in the debt entry.
  • It still merges cleanly into current main.

Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5637033617 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10461#pullrequestreview-5637033617). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-24T05:38:20Z. **Review:** APPROVED --- Checked against main 7c2400d29b and LibreSSL 4.0.0 (`a_object.c` / `asn1_local.h` at ce488b78): - `ASN1_OBJECT_free` matches upstream lines 94-110 step for step: names, then data, then the object. The flag values (0x01/0x04/0x08) and the 40-byte layout match `asn1_local.h:74-80`, and static OBJ-table objects are left alone because they have no DYNAMIC flag. - Freeing through `free_nid_postfix` and wiping through `memset_s_nid_postfix` follows the same pattern libSceLibreSsl's `CRYPTO_free` already uses. Throwing on a negative length before anything is freed seems better than upstream's huge `(size_t)` wipe. - One thing to keep in mind: `OBJ_txt2obj` in this module still throws, so nothing can produce a dynamic object yet. Whoever implements it will need to allocate the object, names and data with `malloc_nid_postfix` so they pair with this free. That might be worth a few words in the debt entry. - It still merges cleanly into current main. Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
MarcZX10 commented 2026-11-02 04:57:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T04:57:29Z.

Review: COMMENTED


Reviewed — Windows link fix confirmed at head

The fix-up the reviewer pushed is present at this head: the test target links libc before configure_windows_unwind, and the hosted Windows check passed.

What I ran

  • Live head b8eea742e326559b33e7172188a9041b99a5b20f (matches batch).
  • gh pr view 10461 (headRefOid, commits, statusCheckRollup); gh api GET of comments and reviews newer than 2026-10-27T02:23:09Z.
  • git log and git show of core/libs/prx/libSceLibreSsl3/CMakeLists.txt at the head.
  • Nothing was built or run.

Results

Check Result Note
eligibility, conventions, labels, report SUCCESS hosted
windows SUCCESS hosted; covers the reviewer's Windows link failure
relinker, relinker-asan, register-context, write-watch SKIPPED hosted
linux SKIPPED hosted

Findings

  • oneandonlydean (2026-10-28T09:58:42Z) asked for libc on guest_libressl3_asn1_object_tests before configure_windows_unwind. Verified: CMakeLists.txt:9 links libc, and line 10 is configure_windows_unwind.
  • oneandonlydean (2026-10-29T11:51:42Z) reports that they pushed this as a fix-up. Verified: head commit b8eea742 ("fix(libressl3): link ASN1 object test with libc") is authored by Dean Galvin and contains that line.
  • The declaration move (2026-10-28) is not re-checked here.

Sources

Not verified

  • The Windows test run itself; only the hosted status is read.
  • Linux was skipped by hosted CI.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5732249311 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10461#pullrequestreview-5732249311). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-02T04:57:29Z. **Review:** COMMENTED --- # Reviewed — Windows link fix confirmed at head The fix-up the reviewer pushed is present at this head: the test target links libc before configure_windows_unwind, and the hosted Windows check passed. ## What I ran - Live head b8eea742e326559b33e7172188a9041b99a5b20f (matches batch). - gh pr view 10461 (headRefOid, commits, statusCheckRollup); gh api GET of comments and reviews newer than 2026-10-27T02:23:09Z. - git log and git show of core/libs/prx/libSceLibreSsl3/CMakeLists.txt at the head. - Nothing was built or run. ## Results | Check | Result | Note | |---|---|---| | eligibility, conventions, labels, report | SUCCESS | hosted | | windows | SUCCESS | hosted; covers the reviewer's Windows link failure | | relinker, relinker-asan, register-context, write-watch | SKIPPED | hosted | | linux | SKIPPED | hosted | ## Findings - oneandonlydean (2026-10-28T09:58:42Z) asked for libc on guest_libressl3_asn1_object_tests before configure_windows_unwind. Verified: CMakeLists.txt:9 links libc, and line 10 is configure_windows_unwind. - oneandonlydean (2026-10-29T11:51:42Z) reports that they pushed this as a fix-up. Verified: head commit b8eea742 ("fix(libressl3): link ASN1 object test with libc") is authored by Dean Galvin and contains that line. - The declaration move (2026-10-28) is not re-checked here. ## Sources - https://github.com/boykopovar/AnyPS5/blob/b8eea742e326559b33e7172188a9041b99a5b20f/core/libs/prx/libSceLibreSsl3/CMakeLists.txt#L7-L10 ## Not verified - The Windows test run itself; only the hosted status is read. - Linux was skipped by hosted CI.
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!10461
No description provided.