feat(libSceLibreSsl3): implement X509_get0_extensions, X509_get_ext_count and X509_get_ext #10493
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10493"
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-24T03:24:14Z.
What
Implements
X509_get0_extensions,X509_get_ext_countandX509_get_extin libSceLibreSsl3, which threw and were declared without parameters.The module is LibreSSL 4.0.0 (firmware 13.40 measurements in #8981). Signatures, layouts and results follow that release's
x509_local.h,x509_set.c,x509_ext.c,x509_v3.candstack_local.h,stack.c:const STACK_OF(X509_EXTENSION)* X509_get0_extensions(const X509*)cert_info->extensionsint X509_get_ext_count(const X509*)X509v3_get_ext_count), otherwisenumX509_EXTENSION* X509_get_ext(const X509*, int loc)locorloc >= num(sk_value), otherwisedata[loc]The layouts are 216 bytes for
X509, 104 forX509_CINF(extensionsat 72) and 32 for the stack (num,data,sorted,num_alloc,comp). They were checked withstatic_asserts and againstoffsetoffrom the 4.0.0 headers compiled on x86-64. LibreSSL dereferences the certificate and itscert_infowithout checking them, and the entry array for an index in range, so a null for any of these throws. No export of this module creates a certificate yet, so for now only certificates built by the caller reach these functions.#10078 implements the
X509_EXTENSION_get_*getters in libSceLibreSsl. This PR is in libSceLibreSsl3 and touches none of them.The debt entry records the source and what is unverified. The pending-export count drops from 84 to 81, and the three names join the exclusion list.
Tested
Ubuntu 26.04 (WSL2, kernel 6.18), GCC 15.2.0, Release, full build with
BUILD_TESTING=ONonmain379b1dca3. There is one commit per function, and each adds that function with its test block and debt update. Each was built and itsguest_libressl3_x509_extensionstest andcheck_conventions.pyrun on its own.guest_libressl3_x509_extensionstest.X509_get0_extensionsreturns null and then the stack, not the field before it.X509_get_ext_countreturns 0 for a null and for an empty stack, then 3.X509_get_extreturns null without a stack, the first and second entries of a two-entry stack, and null for indexes 2, -1,INT_MINandINT_MAXand for a null slot. The fixtures are the publicLibreSsl3ExtensionsCertInfoandLibreSsl3ExtensionsX509.ctest -j16at the last commit: 2005/2006 pass.agc_driver_multisample_retirementfails the same way onmainon this machine.maine7e3e9c198, head 6ced24908f. The branch still merged cleanly, but after #10706public_headersfails on the merge: the exports kept their(void)stubs ininclude/Api.hppand the test redeclared them. 6ced24908f (refactor(libSceLibreSsl3): declare the X509 extension exports in the public header) puts the real signatures and their structs inlibSceLibreSsl3/include/Api.hppand drops the test's redeclarations. Full build andctest -j16: 2202/2203 pass;agc_driver_multisample_retirementfails the same way on thatmain.check_conventions.py --base upstream/mainpasses.main6e775f452a, head 70887669ae, to resolve the conflicts withmainon the sharedCMakeLists.txtand debt-file lines; both sides are kept and the count is 84 minus this PR's exports. Review fix 70887669ae drops the throw checks for unsupported inputs and builds the tests on the public structs;guest_libressl3_x509_extensionspasses. Full build andctest -j16: 2268/2269 pass;agc_driver_multisample_retirementfails the same way on thatmain.check_conventions.py --base upstream/mainpasses.num, so bounding onnumAllocfailsguest_libressl3_x509_extensions, and the debt entry says a null entry array throws. Full build andctest -j16onmain6e775f452a: 2268/2269 pass;agc_driver_multisample_retirementfails the same way on thatmain.check_conventions.py --base upstream/mainpasses.main74acfad65b(after #10948), head b88d2c3a1b, to resolve the conflicts withmainon the sharedCMakeLists.txtand debt-file lines; both sides are kept and the count is 83 minus this PR's exports. Full build andctest -j16: 2431/2432 pass;agc_driver_multisample_retirementfails the same way on thatmain.check_conventions.py --base upstream/mainpasses.mainf2d874c1fd(after #10948, #13267, #13831, #13897 and #14171), head 54cd11170e, to resolve the conflicts on the pending-export line of the debt file: the count and the exclusion list keepmain's names and add this PR's, and the count, 74, matches the stubs inExport.cpp. Full build andctest -j16: 3157/3157 pass.check_conventions.py --base upstream/mainpasses.main4939814d79(after #9535 and #9970), headc21ce49e51, to resolve the conflicts on the sharedExport.cpp,Api.hppand debt-file lines; both sides are kept.mainsays 76 pending exports with 74 stubs left, so the count is set to the 71 stubs left inExport.cpp. Full build andctest -j16: 3538/3538 pass.check_conventions.py --base upstream/mainpasses.mainb11c7bf84f(after #10557), head7db5eca55c, to resolve the conflicts on the sharedCMakeLists.txt,Api.hppand debt-file lines; both sides are kept,X509_PUBKEY_get0_paramstays in the exclusion list, and the count is set to the 70 stubs left inExport.cpp. Full build andctest -j16: 3883/3883 pass.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-24T03:25:48Z.
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-24T12:09:09Z.
Review: APPROVED
Reviewed exact head
f237ce7d1104be00efc7060b3bdec42423aa5edeagainst the pinned LibreSSL 4.0.0 source named in the PR. The exported signatures, null-stack/count behavior, negative and out-of-range handling, and unchecked in-range element access match the cited implementation; layout assertions cover the stated x86-64 offsets. The new tests exercise populated/empty stacks, invalid indexes, null elements, and null certificate/info/array cases. The author reports per-commit focused tests and a full build/test run with one unrelated baseline failure; I did not reproduce those runs locally. Hosted conventions, intake, eligibility, labels, and report pass; platform/product jobs were skipped.Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T19:29:00Z.
Review: APPROVED
Reviewed head
70887669ae67merged ontomainae7d59258e(clean, tree3f62a47c10). Linux x86-64, GCC 13.3, Release.What I ran:
guest_libressl3_x509_extensions_tests;guest_libressl3_x509_extensionspasses 3 of 3 runs.check_conventions.py --base origin/mainpasses.X509Extensions.cpp: extensions read at offset 64 or 80, count returnsnumAlloc, count returns -1 for a null stack,loc > num, no negative check,data[loc + 1], non-null for a null stack. All 8 fail the test.libcrypto.a: the sameX509*goes to the real functions and to these exports. Cases: a v3 cert with 6 extensions (parsed from DER), a v1 cert (null stack),X509_newwith an extension added then deleted (empty stack), a bareX509_new, andX509_newwith 1 extension. Count, andget_extatINT_MIN, -2, -1, 0, 1, n-1, n, n+1,INT_MAX: identical pointers in every case. 2.5.4 has noX509_get0_extensions, so I compared that one againstx->cert_info->extensions.offsetoffrom the 4.0.0x509_local.handstack_local.h:X509216,X509_CINF104 withextensionsat 72, stack 32 withdataat 8. All match thestatic_asserts. 2.5.4 has the sameX509_CINFand stack layout, so the 2.5.4 run reads the same fields.X509_get0_extensions(x509_set.c),X509_get_ext_count/X509_get_ext(x509_ext.c),X509v3_get_ext_count/X509v3_get_ext(x509_v3.c) andsk_value(stack.c): matches.Two small non-blocking things:
GuestLibreSsl3X509Extensions.cpp:43:slots[2]is null, so a bound onnumAllocinstead ofnumstill passes. I tried that mutation and the test stays green. The case is real:sk_deleteonly doesnum--, so afterX509_delete_extthe deleted pointer stays atdata[num]. My 2.5.4 probe saw exactly that:num0 and the freed extension still indata[0]. A non-null third slot (say&third) makes theX509_get_ext_nid_postfix(&certificate, 2) == nullptrcheck withnum2 catch it.X509Extensions.cpp:37throws only on a nulldataarray; a null entry returns null, which matchessk_valueand what test lines 58-59 check. Maybe "a null entry array".Not run: Windows, a title, LibreSSL 4.0.0 as a library (its sources and headers only).