feat(libSceLibreSsl): implement sk_num, sk_value, sk_pop and sk_pop_free #10373
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10373"
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 alvaroelpob on 2026-10-23T19:56:44Z.
What
Implements
sk_num,sk_value,sk_popandsk_pop_freein libSceLibreSsl, which threw and were declared without parameters.The module is LibreSSL 2.5.4 (firmware 13.40 measurements in #8981). Signatures, the
_STACKlayout and the results follow that release'sstack.handstack.c:int sk_num(const _STACK*)num(unchecked, so a negative count is returned as is)void* sk_value(const _STACK*, int)[0, num), otherwisedata[i]void* sk_pop(_STACK*)num, leavingdataandnum_allocas they arevoid sk_pop_free(_STACK*, void (*)(void*))dataand the stackThe layout is 32 bytes (
numat 0,dataat 8,sortedat 16,num_allocat 20,compat 24), checked withstatic_asserts.sk_pop_freefrees through the guestfree, as the module would through libc. The free function is called with the guest ABI.LibreSSL faults in a few cases: a null
dataarray it would read through, and a null free function given a non-null element. Those throw. No export of this module creates a stack yet, so for now only stacks built by the caller reach these functions.The debt entry records the source and what is unverified, and the pending-export count drops by 4 (342 to 338 on current
main).Tested
Ubuntu (WSL2, kernel 6.18), GCC 15.2.0, Release, full build with
BUILD_TESTING=ONonmain3c44638fc. There is one commit per function, in the ordersk_num,sk_value,sk_pop,sk_pop_free. Each commit adds that function with its test block and debt update. Each was built and itsguest_libressl_stacktest andcheck_conventions.pyrun on its own.guest_libressl_stacktest: null stacks for all four exports;sk_numon a stack holding a null element and on a negative count;sk_valuefor in-range, negative and out-of-range indices, including an element pastnumthat must not be returned;sk_popdown to empty, checking thatnumdrops whilenum_allocanddatastay as they were, and that a negative count stays unchanged;sk_pop_freecalls the function only for non-null elements, in order, and frees the stack; the null free function and null element array cases throw. Onmainthe first call throws.ctest --test-dir build -R guest_libressl: 6/6 pass.ctest -j16at the last commit: 1992/1993 pass.agc_driver_multisample_retirementfails the same way onmainon this machine.main1e740a23a3(after #9033), head 0bc03c028f: the conflicts were only theadd_librarysource list, the end of the test block, the pending-export count and the last debt entry; both sides are kept and the count is 357 minus this PR's exports. Full build andctest -j16: 2043/2044 pass;agc_driver_multisample_retirementfails the same way on thatmain.check_conventions.py --base upstream/mainpasses.maine7e3e9c198, head 64df489045, to resolve the conflict from #9529 on the sharedCMakeLists.txtand debt-file lines; both sides are kept and the count is 353 minus this PR's exports. 64df489045 (refactor(libSceLibreSsl): declare the stack exports in the public header) puts the real signatures and their structs inlibSceLibreSsl/include/Api.hppand drops the test's redeclarations, whichpublic_headersrequires since #10706. Full build andctest -j16: 2202/2203 pass;agc_driver_multisample_retirementfails the same way on thatmain.check_conventions.py --base upstream/mainpasses.mainae7d59258e(after #9949), head 3602624126, to resolve the conflicts withmainon the sharedCMakeLists.txtand debt-file lines; both sides are kept and the count is 342 minus this PR's exports. Full build andctest -j16: 2275/2276 pass;agc_driver_multisample_retirementfails the same way on thatmain.check_conventions.py --base upstream/mainpasses.sk_pop_freefrees the element array and then the stack, and starts the pop test withsortedset and checks it stays set; dropping the array free, swapping the frees or clearingsortedinsk_popfailsguest_libressl_stack. Full build andctest -j16onmainae7d59258e: 2275/2276 pass;agc_driver_multisample_retirementfails the same way on thatmain.check_conventions.py --base upstream/mainpasses.main2dbe9b99f5(after #9745, #9870 and #11111), head 7ed657680a, to resolve the conflicts withmainon the sharedCMakeLists.txtand debt-file lines; both sides are kept and the count is 340 minus this PR's exports. Full build andctest -j16: 2370/2371 pass;agc_driver_multisample_retirementfails the same way on thatmain.check_conventions.py --base upstream/mainpasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-23T19:56:51Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T19:58:35Z.
Review: APPROVED
Reviewed the exact head dce8b38c2503824819f2e010a02ef5095aef8399. The ABI/layout and edge-case results for sk_num, sk_value, sk_pop and sk_pop_free match the pinned LibreSSL 2.5.4 source, including null element handling and freeing the element array and stack through the guest allocator. The added tests cover range/count and ownership cases, and the debt entry clearly records the unverified console behavior. Hosted conventions, eligibility, intake, labels and report checks pass; product and relinker jobs were skipped by path policy. I reviewed the reported local test results but did not run the test locally.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T20:00:12Z.
Review: DISMISSED
Follow-up to my approval: a pairwise merge check with current open #9529 (
git merge-tree --write-tree upstream/pr/9529 upstream/pr/10373) reports content conflicts incore/libs/prx/libSceLibreSsl/CMakeLists.txtanddocs/dev/debt/libSceLibreSsl.md. This PR currently saysDepends on: none, so the integration order is not recorded. CONTRIBUTING requires coordination for overlapping shared-file changes and a declared dependency. Please coordinate with #9529’s author, update the checklist to reflect the agreed order (the older #9529 first is a straightforward option), and confirm the combined CMake/test registration and debt count will be retained. The four function implementations still look consistent with the pinned LibreSSL source; this request is for the reproducible merge conflict and missing ordering, not those semantics.Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-26T05:59:52Z.
Review: APPROVED
Reviewed head 3602624 (base
ae7d592), merged locally onto current main14c99b5(clean). WSL2 Ubuntu 24.04, GCC 13.3, Release.What I ran:
ctest -R '^guest_libressl'12/12,guest_libressl_stack3 runs all pass,ctest -R '^public_headers'65/65.tools/check_conventions.pypasses on the head (baseae7d592) and on the merge (base main).include/openssl/stack.hprintssizeof=32 num=0 data=8 sorted=16 num_alloc=20 comp=24, same as yourstatic_asserts.Stack.cppagainst 2.5.4crypto/stack/stack.c(sk_num,sk_value,sk_popthroughsk_delete,sk_pop_freethroughsk_free). Same results on every input that doesn't fault there. The throws only fire where 2.5.4 would dereference or call NULL.sk_num(NULL)returning 0,index > numinsk_value,sk_popnot loweringnum,sk_popreturningdata[0], and releasing NULL elements all fail the test.The merge-order points from the earlier change request look done on this head: #9529 merged first, line 1 of
CMakeLists.txtkeeps main'sError.cppandOcsp.cppand only appendsStack.cpp, theguest_libressl_ocspblock is kept, and the 338 count matches the 338NotImplemented_nid_no_patchstubs left inExport.cpp.Two optional test notes, not blocking:
free_nid_postfix(stack->data);or swapping the two frees still passes. A counting heap like the one inlibSceLibreSsl/tests/Asn1.cpp(Allocator()) could assert both pointers get freed, array first.sortedisn't pinned after a pop. Addingstack->sorted = 0;tosk_popstill passes, sinceTestPopstarts at 0 and never reads it. Starting the stack withsorted = 1and checking it after the pops would catch that.Limits: no console or module here. BunnyFl's 13.42 differential above covers the module side.