Skip to content

feat(libSceLibreSsl3): implement ASN.1 value mutation and octet lifetime - #14889

Merged
oneandonlydean merged 14 commits into
boykopovar:mainfrom
Noxy-HNR:codex/libressl3-asn1-values
Nov 7, 2026
Merged

oneandonlydean merged 14 commits into
boykopovar:mainfrom
Noxy-HNR:codex/libressl3-asn1-values

Conversation

@Noxy-HNR

@Noxy-HNR Noxy-HNR commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

What

Four newly named LibreSSL3 exports currently throw: ASN1_STRING_set, ASN1_INTEGER_set, ASN1_OCTET_STRING_cmp and ASN1_OCTET_STRING_free. Implement binary/NUL-terminated string replacement, full signed 64-bit integer magnitudes, octet comparison and owned/borrowed buffer destruction through the application heap.

Contracts come from LibreSSL 4.0.0 a_string.c, a_int.c and a_octet.c, using the existing 24-byte guest Asn1String. Owned data is erased before release; NDEF string buffers remain borrowed. Invalid native dereference/overflow/alias cases throw. Console ABI and behavior are unverified; the debt entry also records the integer allocator's difference from LibreSSL's CBB allocation chain. No title unblock is claimed.

Tested

Current head e971edaa96 is a maintainer merge of main 9ade3ed806 into 23f56dae04. The ASN.1 implementation and regression test are byte-for-byte unchanged; the maintainer commit and its identity are preserved. The current-head Windows job now passed. Its log identifies e971edaa9696 and shows ASN.1 value, ASN.1 decoder, ASN.1 string and session-metadata runtime tests passing. It reports zero failures among 3,436 selected CTest entries, including skipped entries; this is not a separate full Linux run. Local results below retain their original head and scope.

Historical local verification (23f56dae04): merged main 6beaeef052 without force-pushing; the only manual conflict resolution was the debt inventory. The ASN.1 implementation and regression test are unchanged. Windows 11 x86-64, WinLibs GCC 15.2.0/Ninja, Release, -j 18: rebuilt the real modules and all four focused ASN.1 targets; guest_libressl3_asn1_values, guest_libressl3_asn1, guest_libressl3_asn1_string and guest_libressl3_asn1_object all passed in each of three runs. Conventions and whitespace checks pass. Current-head hosted checks are pending.

Historical hosted verification (973e270f90): the Windows changed-test job passed; guest_libressl3_asn1_values, both ASN.1 decoders and the allocator regression passed. The job reports zero failures among 3,337 selected CTest entries, including skipped entries. Its log identifies this exact PR head. This is not a fresh full Linux run; earlier local and Linux results below retain their stated commits and scope.

Latest rebase verification on November 2 (47fe0f6392, based on main at f6232fcfda): resolved the debt inventory conflict while preserving main's new entries. The ASN.1 implementation and its test source are byte-for-byte unchanged from 710ff5eed5, including both owned-terminator alias fixes. Windows 11 x86-64, WinLibs GCC 15.2.0, Release: rebuilt the value, decoder, allocator and newly landed time-test targets; 5/5 focused tests passed (guest_libressl_asn1, guest_libressl_asn1_allocator, guest_libressl3_asn1_values, guest_libressl3_time, guest_libressl3_asn1). The public-header audit passes for 405 libraries / 27,952 exports; current conventions, whitespace and the current-main merge preview pass. The automatic Windows job subsequently passed on this head: 2,074 tests executed and passed, 959 skipped, zero failures across 3,033 selected CTest entries. The value-mutation, decoder and allocator tests all ran and passed. This is a changed-test workflow, not the separate full build requested in the follow-up. Older results below retain their tested heads.

Prior follow-up verification (710ff5eed5): the overlap guard also covers an owned empty string, whose data pointer is its terminator. The new regression checks that alias rejection preserves the pointer and zero length. Windows Release: the same four focused ASN.1 tests passed (4/4), and conventions and whitespace checks passed. The prior nonempty terminator fix in 155b280226 is preserved. Linux was not rerun for this follow-up.

Windows 11 x86-64, WinLibs MinGW GCC 15.2.0, Release, configured from upstream 0580e5c951 with BUILD_TESTING=ON.

  • Built guest_libressl3_asn1_values_tests, guest_libressl3_asn1_tests and guest_libressl_asn1_tests through CMake.
  • ctest --test-dir <build> -R '^guest_libressl(3_asn1_values|3_asn1|_asn1|_asn1_allocator)$' --output-on-failure: 4/4 passed.
  • Recording application allocator checks binary data, null-data zero fill, terminators, replacement/borrowed ownership, erasure before free, allocation failures, invalid lengths, comparison order and 18 signed integer boundary values including INT64_MIN/MAX.
  • python core/libs/tests/test_public_headers.py --audit-only: 399 libraries / 26,743 exports passed.
  • python tools/check_conventions.py --base origin/main and git diff --check: passed.
  • Built nid_patcher and successfully patched a copy of the resulting PRX with the libc export-preservation option.

The prior head was rebased onto 198e13c75e. The current rebase onto f6232fcfda includes newer upstream library and build inputs; the focused rebuild and tests above cover that integration.

No Linux, console or retail-title runtime test was performed. The full project build/test suite was not run.

tools/pr_overlap.py --repo boykopovar/AnyPS5 --base main --branch HEAD was rerun against 1,777 open PRs. It returned exit 2 because several other heads conflict with main, so this is not an automatic overlap pass. Shared declarations, build registrations and debt diffs were inspected manually for #10461, #10631, #10960, #11146, #12754, #13486, #14212, #14483, #14499, #14612, #14992, #15031, #15045 and #15119, along with the adjacent-edit findings. No other implementation of these four exports was found; the report also compares this local rebase against this PR's own previous head. Other PRs still touch shared debt/build/declaration files, so integration may require another rebase as those land.

Companion PR #14890 changes adjacent placeholder declarations in the same shared files. A local git merge-tree check reports conflicts if the two branches are combined. Merge this ASN.1 contribution first; the BIO PR declares this merge-order dependency and will need a rebase afterward.

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

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Progress report (f0c4b54 → d06e425)

📈 System libraries: 31.1% (+0.01%, +4 implemented functions)

✅ 4 implemented
Library Name
libSceLibreSsl3 ASN1_INTEGER_set_nid_postfix
libSceLibreSsl3 ASN1_OCTET_STRING_cmp_nid_postfix
libSceLibreSsl3 ASN1_OCTET_STRING_free_nid_postfix
libSceLibreSsl3 ASN1_STRING_set_nid_postfix

Changed libraries (implemented exports)

Library Before After Change
libSceLibreSsl3 81/284 (28.52%) 85/284 (29.93%) +1.41%

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 14212 docs/dev/debt/libSceLibreSsl3.md L22-23, L66
PR 15449 docs/dev/debt/libSceLibreSsl3.md L66, L216
PR 15544 docs/dev/debt/libSceLibreSsl3.md L66
PR 15591 core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp L557-562
docs/dev/debt/libSceLibreSsl3.md L66, L203-204
PR 16249 core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp L192-203
core/libs/prx/libSceLibreSsl3/include/Api.hpp L274-276
docs/dev/debt/libSceLibreSsl3.md L66, L83-84
PR 16529 core/libs/prx/libSceLibreSsl3/include/Api.hpp L344-345
PR 16535 core/libs/prx/libSceLibreSsl3/include/Api.hpp L370-371
docs/dev/debt/libSceLibreSsl3.md L202-203
PR 16543 core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp L196-203
core/libs/prx/libSceLibreSsl3/include/Api.hpp L275-276
docs/dev/debt/libSceLibreSsl3.md L83-84
PR 16586 docs/dev/debt/libSceLibreSsl3.md L66
PR 16588 docs/dev/debt/libSceLibreSsl3.md L66
PR 16589 docs/dev/debt/libSceLibreSsl3.md L66

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 12315 core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/include/Api.hpp
docs/dev/debt/libSceLibreSsl3.md
PR 14465 core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp
core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/include/Api.hpp
docs/dev/debt/libSceLibreSsl3.md
PR 14499 core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp
core/libs/prx/libSceLibreSsl3/include/Api.hpp
docs/dev/debt/libSceLibreSsl3.md
PR 14612 core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp
core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/include/Api.hpp
docs/dev/debt/libSceLibreSsl3.md
PR 15163 core/libs/prx/libSceLibreSsl3/include/Api.hpp
docs/dev/debt/libSceLibreSsl3.md
PR 15514 core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp
core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/include/Api.hpp
docs/dev/debt/libSceLibreSsl3.md
PR 15826 core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp
core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/include/Api.hpp
docs/dev/debt/libSceLibreSsl3.md
PR 15831 core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp
core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/include/Api.hpp
docs/dev/debt/libSceLibreSsl3.md
PR 15854 core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp
core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/include/Api.hpp
docs/dev/debt/libSceLibreSsl3.md

@Noxy-HNR
Noxy-HNR marked this pull request as ready for review November 2, 2026 00:28
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Thanks for this. Two points on a2565e84a7caa006831c4143fae7b7d2ceda707f:

  1. The new debt entry says overlapping owned input throws, but the guard excludes the terminator. After setting a string to "x", passing string.data + string.length back with explicit length 1 reaches memcpy after freeing that allocation; the isolated exact-function probe reports an ASan use-after-free. This alias case is undefined upstream too, so I am asking for accurate debt wording, not different supported-call semantics: please narrow the overlap claim to what is checked, or extend the intended protection and cover the boundary in the test.

  2. The new implementation is compiled directly under core/ at this registration. Please clarify whether this is an independently written ABI implementation using the cited contracts, or adapted LibreSSL source. The latter has the same placement question as the held contributions: the contribution rule puts third-party code in a source-built submodule under 3rdparty/. The placement decision needs to be consistent before this is ready.

@Noxy-HNR

Noxy-HNR commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

@oneandonlydean thanks, both points addressed in 155b280226:

  1. The overlap guard now treats owned data as covering its terminator byte too, so the data + length case you describe throws before anything is released. The new regression in tests/Asn1Values.cpp sets "x", passes string.data + string.length with length 1, and checks that it throws and leaves the string unchanged; it aborts without the fix. The debt entry now says "overlapping the owned data or its terminator byte", which is what is checked. guest_libressl3_asn1_values and the other 38 guest_libressl tests pass on Linux.

  2. It is an independently written implementation of the documented ABI, not adapted LibreSSL source. Nothing from a_string.c, a_int.c or a_octet.c is copied: it works on the existing 24-byte Asn1String and the application heap, encodes the integer magnitude itself in a fixed eight-byte buffer instead of LibreSSL's CBB code, and adds its own guards where LibreSSL is undefined. The LibreSSL 4.0.0 links are cited only as the behavioural contract (return values, cleared fields, the negative-integer type), the same way the existing IntegerDecoder and key getters cite it. So there is no third-party code to move under 3rdparty/.

@Noxy-HNR

Noxy-HNR commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

@oneandonlydean a small follow-up in 710ff5eed5163494cdc5ac652c80f5c793ee84ba preserves 155b280226 and also covers an owned empty string. Its data pointer is the terminator itself, so the guard now includes zero-length owned buffers. The regression checks that passing that pointer with explicit length 1 throws and preserves the pointer and zero length.

Windows Release: the updated value test plus the existing ASN.1 decoder/allocator tests pass, 4/4. Conventions and whitespace checks pass. The body records this follow-up separately from the previous validation.

The implementation provenance is as clarified above: this is independently written C++ for the existing AnyPS5 guest types and application heap, informed by the pinned public contracts. No LibreSSL source files or CBB implementation were imported. Please let us know if further placement changes are required under the project's policy.

@Noxy-HNR
Noxy-HNR force-pushed the codex/libressl3-asn1-values branch from 710ff5e to 47fe0f6 Compare November 3, 2026 05:03
@Noxy-HNR

Noxy-HNR commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main at f6232fcfda; the new head is 47fe0f6392. This resolves the debt conflict while preserving main's new entries. The ASN.1 implementation and test source are unchanged from 710ff5eed5, including both owned-terminator alias fixes.

Windows 11, WinLibs GCC 15.2.0, Release: rebuilt the relevant targets and passed 5/5 tests (value mutation, both ASN.1 decoders, the allocator case, and the newly landed time test). The public-header audit passes for 405 libraries / 27,952 exports. Current conventions, whitespace and the current-main merge preview pass.

The overlap scan returned exit 2 because some other branches conflict with main. I inspected the reported shared declarations, build registrations and debt changes; no other implementation of these four exports was found. The description records the comparisons and the remaining shared-file integration limits.

Could a maintainer re-review this head and start a fresh full Build run on main with pr=14889? The previous head's hosted result does not validate this rebase. This PR and #14890 need separate build runs at their current heads because their combination still conflicts; #14890 remains after this PR and #12945.

@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ AMD GPU test: passed

PR head 47fe0f6 merged onto main 4639eff · tested 2026-11-05 11:09 UTC · 14 min

GPU AMD Radeon RX 6300 (RADV NAVI24), driver Mesa 25.2.8-0ubuntu0.24.04.4, Vulkan 1.4.318
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-42-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 1,175 passed · 5 failed (0 new, 4 also fail on main, 1 unstable on main) · 8 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 1,188 of 3,962 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (573 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 120.4 s, ⚠️ public_headers 73.8 s, ⚠️ agc_driver_image_sample_unnormalized 57.0 s, ⚠️ agc_driver_lazy_resolved_abi 46.3 s, ⚠️ agc_driver_sample_multisample_target 39.3 s
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)
agc_driver_pipeline_journal: failed in 9 of the last 10 main runs
Failing on main too (4, not counted against this PR)
agc_driver_image_table
agc_driver_native_depth_bda_clear
agc_driver_native_multisample_depth
agc_driver_submit_progress
Validation IDs already present on main (4 IDs in 490 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (490 tests): agc_driver_address_draw_space_reuse, agc_driver_address_passes, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_array_layer_target, agc_driver_bc_block_copy, agc_driver_bda_anchor_reads, agc_driver_bda_span_reads, and 482 more
VUID-vkCmdCopyImage-srcImage-01548 (4 tests): agc_driver_depth_clear_hle, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-vkCmdCopyImage-srcImage-01551 (4 tests): agc_driver_depth_clear_hle, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (2 tests): agc_driver_prepared_exports, agc_driver_srgb8_color_target
Skipped (8)
agc_driver_copied_writer_label_order: skipped, the device reports a minStorageBufferOffsetAlignment of 4, so the dispatch binds its record at +0x1004 in place and nothing is written back; the test needs an alignment above 4
agc_driver_float16_unused_nan_payloads: skipped, the device has no native f16 conversions with RTE rounding and kept f16 denormals
agc_driver_gcn_display_present: skipped, no display: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
agc_driver_linear_target_direct_write_completion: skipped, the device does not keep host imports write-watched, so no completion stamp over the target is tracked
agc_driver_ngg_vertex_wave_reduction: skipped, s3 describes a 32-lane wave only on 32-lane subgroups, and the device has 64 lanes
agc_driver_recorded_draw_staging: skipped, the device does not keep host imports write-watched, so the target is never resident
agc_driver_scattered_runs: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_sparse_dma_buf_import: skipped, host imports are unavailable: /dev/udmabuf is not accessible
Reproduce
git fetch origin 47fe0f6392fff20e13dfaa29c05befd8516d4f75 4639eff7f4c23325a916875a0e37f1e312fa18f4
git checkout 4639eff7f4c23325a916875a0e37f1e312fa18f4 && git merge --no-ff 47fe0f6392fff20e13dfaa29c05befd8516d4f75
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 12 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 16 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Nov 5, 2026
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 6, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 6, 2026
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Nov 6, 2026
# Conflicts:
#	docs/dev/debt/libSceLibreSsl3.md
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 6, 2026
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Nov 7, 2026
Fix-up on Noxy-HNR's change: take main's wording for the libtls note and recount the LibreSSL additional export total on the merged tree.
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Nov 7, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Hi @Noxy-HNR, thanks for the ASN.1 value work. We merged the latest main on top to clear the conflict in docs/dev/debt/libSceLibreSsl3.md: the additional-exports line now reads 141 still-unimplemented callable exports, 131 named and 10 known only by NID, recounted on the merged tree, and your rewritten paragraph on the formerly NID-only names is kept as you wrote it. Nothing else in your changes was touched. Thanks!

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 7, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Hi @Noxy-HNR, thanks for the ASN.1 value work. We merged the latest main into your branch (d06e425) so it is up to date for merging; it merged cleanly and none of your changes were touched. The debt doc's additional-exports line (141 still-unimplemented callable exports, 131 named and 10 known only by NID) was recounted on the merged tree and still matches. Thanks!

@oneandonlydean
oneandonlydean merged commit 0c598f5 into boykopovar:main Nov 7, 2026
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants