feat(libSceLibreSsl3): implement custom BIO methods and field accessors #14890
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14890"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Noxy-HNR on 2026-11-01T22:47:17Z.
What
Implement 14 newly named LibreSSL3 BIO exports: method allocation/free, write/read/control/create/destroy callback installation, and data/init/shutdown/flag accessors.
The 80-byte method and 112-byte BIO layouts follow LibreSSL 4.0.0 bio_local.h, with behavior from bio_meth.c and bio_lib.c. Methods use the application heap and borrow their names. Callback pointers retain the guest System V ABI, and control arguments/results use 64-bit guest
longon Windows. Null objects that upstream dereferences throw.This supplies the method/field API, without implementing BIO construction, chaining or network I/O. BunnyFl's firmware 13.42 disassembly review confirms the method size/allocation and the field offsets these 14 exports touch. Other firmware and complete construction, chaining and I/O remain unverified; older libSceLibreSsl BIO objects require a bridge before use with these layouts. These limits are recorded in the library's debt file; no title unblock is claimed.
Tested
Current-head verification (
6aa57fb3d42b700347cfda91768bbd45ab536e82): merged upstream main9b0fdbfb24, preserving maintainer merge6e2564e106. Only the debt inventory needed manual resolution: 131 remaining stubs (121 named, 10 unknown); BIO implementation, layout header and tests are unchanged. Windows x86-64, WinLibs GCC 15.2.0/Ninja, Release, full configuration (BUILD_TESTING=ON, relinker-only OFF): focusedguest_libressl3_bio_teststarget built with-j 18;guest_libressl3_biopassed three runs. Conventions and whitespace checks pass. Independent different-model static and validation-log review found no substantive issues. Fresh automatic Build run is queued for this exact head; no hosted pass is claimed. Full-build dispatch was attempted and rejected with HTTP 403 (admin rights required), so maintainer dispatch is pending. No full suite, Linux, console or title run was performed for this head.Historical local verification (
cefbec3c32): merged mainad8e79fd81without force-pushing. Only the debt document required manual resolution; the BIO implementation, layout header and regression test are unchanged. The remaining-export inventory matches 146 rows (136 named and 10 unknown), retaining main's three session-metadata removals. Windows 11 x86-64, WinLibs GCC 15.2.0/Ninja, Release,-j 18: BIO, ASN.1, ASN.1 string, key reference, stack, time and session-metadata CTests all passed in each of three runs. Current conventions and whitespace checks pass. New hosted checks are running.Historical local verification (
d7ba0ad6e3): merged main6beaeef052without force-pushing; the only manual conflict resolution was the debt inventory. The BIO implementation, layout header and regression test are unchanged. Windows 11 x86-64, WinLibs GCC 15.2.0/Ninja, Release,-j 18: rebuilt the real module and six related targets; BIO, ASN.1, ASN.1 string, key reference, stack and time CTests all passed in each of three runs. Conventions and whitespace checks pass. Current-head hosted checks are pending.Historical hosted verification (
a94dbfe749): the Windows changed-test job passed;guest_libressl3_bio, ASN.1, stack and time tests 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 (
ba5711574d, based onmainatf6232fcfda): resolved the debt conflict while retaining main's new time entry and the attributed firmware 13.42 evidence. The BIO implementation, layout header and test source are byte-for-byte unchanged from4300582b7f. Windows 11 x86-64, WinLibs GCC 15.2.0, Release: rebuilt BIO, ASN.1, allocator, stack, time and filesystem targets; 7/7 focused tests passed (guest_libressl3_bio,guest_libressl3_asn1,guest_libressl_asn1,guest_libressl_asn1_allocator,guest_libressl3_stack,guest_libressl3_time,guest_filesystem). 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. BIO, both ASN.1 decoders, the allocator case, stack, time and filesystem all ran and passed. This is a changed-test workflow, not the separate full build requested in the follow-up. At that historical run, #14889 and #12945 were open. #12945 has since merged; #14889 remains the declared integration prerequisite.Prior verification on November 2: Windows 11 x86-64, WinLibs MinGW GCC 15.2.0, Release. Rebuilt the BIO, ASN.1, stack and filesystem targets on
4300582b7f: 4/4 passed. The same four tests pass on a clean local merge withmainatb28bb77217(tree274bbd6f9973a8202acbd8aeb6887b7bad85d294). Clean main's filesystem test also passes.The earlier hosted Windows job failed only
guest_filesystemamong 2,936 selected tests (exit0xc0000409); BIO passed. After the PR was closed and reopened, the fresh Windows job passed at the previous head,4300582b7f. The original failure was not reproduced or attributed to a specific cause. BunnyFl's re-approval applies to that previous head and reports passing BIO, public-header and filesystem checks. The rebased head still needs fresh hosted verification; the current local results are above.Original verification:
Windows 11 x86-64, WinLibs MinGW GCC 15.2.0, Release, on an independent branch from upstream
0580e5c951withBUILD_TESTING=ON. The ASN.1 value contribution was absent from this build.Built
guest_libressl3_bio_tests,guest_libressl3_asn1_testsandguest_libressl3_stack_teststhrough CMake.ctest --test-dir <build> -R '^guest_libressl3_(bio|stack|asn1)$' --output-on-failure: 3/3 passed.The new runtime test installs and calls guest write/read/control/create/destroy callbacks, transfers binary data, and checks a control value/result wider than 32 bits. It checks zero initialization, null callback replacement, borrowed names, allocation failure, exact field writes with surrounding guards, signed int values/flag masks and null-object exceptions. Method free does not invoke callbacks.
python core/libs/tests/test_public_headers.py --audit-only: 399 libraries / 26,743 exports passed.python tools/check_conventions.py --base origin/mainandgit diff --check: passed.nid_patchersuccessfully patched a copy of the resulting PRX with the libc export-preservation option.Historical head
ba5711574dis rebased ontof6232fcfdaand merges cleanly with that main. The conflict resolution changes debt text only; no BIO implementation, layout or test behavior changed. The older results below retain their measured bases; hosted results are not being carried forward as validation of the new head.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 HEADwas rerun against 1,778 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 14 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 #14889 implements a separate ASN.1 API. The two new heads still conflict inAdditionalExports.cppandApi.hpp, so #14889 remains first and this BIO PR must be rebased afterward. There is no runtime dependency between those features.#12945 (
BIO_up_ref) is now merged into main and included here. This branch reuses the single 112-byteLibreSsl3Biodeclaration ininclude/Key.hpp;include/Bio.hppincludes it and only defines the method/callback types and field assertions. The duplicate-layout integration work is complete, and the refreshed key-reference and BIO tests pass. #14889 remains the declared integration-order prerequisite.Checklist
Based on current
main; no other open PR implements the same functionsOne 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 fileNo notes, investigation
.mdfiles 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: #14889
Fixes: none
Unblocks: none
GPUs tested: n/a
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-02T12:10:34Z.
Review: APPROVED
Looks right, and the layouts match the PS5 module, not only LibreSSL 4.0.0.
Firmware 13.42's
system/common/lib/libSceLibreSsl3.sprx(sha256ee2c529c87fe21b7ef1e5f13d10c47ee90944f52a1f848fe0995e031817c2c3a), disassembly only:BIO_meth_new(0x59d60)calloc(1, 0x50)calloc_nid_postfix(1, …)BIO_meth_free(0x59d90)freefree_nid_postfixBIO_meth_set_write/read/ctrl/create/destroy+0x10/+0x18/+0x30/+0x38/+0x40, return 1write/read/control/create/destroyat the same offsets, return 1BIO_set_init(0x5c410)mov [rdi+0x20], esiinitializedat 0x20BIO_get_shutdown/set_shutdown[rdi+0x24]shutdownat 0x24BIO_set_flags/clear_flagsor [rdi+0x28], esi/and [rdi+0x28], ~esiflagsat 0x28BIO_get_data/set_data(0x5c3e0/0x5c3f0)[rdi+0x38]dataat 0x38None of the 13.42 accessors checks for null, so throwing on a null object is the documented divergence from a fault, as the entry says.
Tested on Windows 11, WinLibs GCC 15.2.0, Release, with head
10cc291ea8merged ontomain:guest_libressl3_bio,public_headersandcheck_conventions.py --base upstream/mainpass.Non-blocking: the debt entry says the console layout is unverified. The table above settles the offsets these 14 exports touch for 13.42, so that part could be narrowed to what's still open (construction, chaining, I/O, and the bridge from the older libSceLibreSsl BIOs).
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-02T17:44:01Z.
Review: APPROVED
Edited 2026-11-05: corrected. The first version of this review said
guest_filesystemhad passed 25 repeated runs alone and 15 in parallel onmain; those runs left no log, so that line is removed and the repeats were redone below. It also misdescribed the hosted log (more output follows the junctions, quoted below), and it called the hosted abort "runner-side or flaky" without having tested any cause. I don't know what caused it.Re-approving at
4300582b7f. From10cc291ea8(my first review) to4300582b7f,git diff --statshows one changed line, indocs/dev/debt/libSceLibreSsl3.md. Its new wording matches what the 13.42 disassembly showed: method size 0x50 throughcalloc, and the offsets of the five setters and seven accessors.Run on 2026-11-02, Windows 11, WinLibs GCC 15.2.0, head
4300582b7fmerged ontomaina4eca2a056:guest_libressl3_bio,public_headersandguest_filesystempassed, one run each.Rerun on 2026-11-05 at the current head
ba5711574dmerged ontomain6a337633c6, Windows 11 Pro 10.0.26300, WinLibs GCC, Release, withguest_libressl3_bio_testsandguest_filesystem_testsrebuilt before each run:guest_libressl3_bio,public_headersandguest_filesystempass, one run each.guest_filesystemwithctest --repeat until-fail:25: 25 of 25 pass on the merge, and 25 of 25 onmain6a337633c6.The hosted abort (job 125404179173 of run 41482291203, head
4300582b7f):guest_filesystemexits with0xc0000409. These are the log's last lines before the abort:I haven't reproduced it on this machine in the runs above.
AI-assisted: yes (Claude Code)
Pull request closed