fix(libSceLibreSsl3): keep RSA_free from binding to its own export #22877
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22877"
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 Herolias on 2026-11-18T13:21:37Z.
What
RSA_free(RSA_free_nid_disambig1_nid_postfixinsrc/RsaCrypto.cpp, added in #22804) hands a key whose method pointer is set to libSceLibreSsl'sRSA_free_nid_postfixexport. After NID patching that import is named5zpup0URQoc, which libSceLibreSsl3 also exports as its ownRSA_free. When libSceLibreSsl3 comes before libSceLibreSsl in the lookup scope, the import binds to libSceLibreSsl3's own export, which then calls itself forever.patched_self_importshas failed on Linux since #22804 withlibSceLibreSsl3.prx imports 5zpup0URQoc, a name it also exports, so the import can bind to its own export. The Windows job is the only one PR CI runs, so CI does not show it.RSA_freebody inLibreSslRsaFree_nid_no_patch, which its export and libSceLibreSsl3'sRSA_freeboth call. This is the split6c5bee0282(#13730) made for the other forwarders. The declaration follows libSceLibreSsl's existing cross-library bodies such asLibreSslAsn1StringFree_nid_no_patch(extern "C", noAPS5_VABI).invalid_argumentkeeps the textRSA_free_nid_postfix: null methodthat__func__produced before, as6c5bee0282did forFT_Stroker_Export. libSceLibreSsl's own callers still call the export. No debt entry changes: #22804'sRSA_freeentry ("A key whose method pointer is set goes to libSceLibreSsl'sRSA_free") stays true.RsaPublicKeyBio.cppcalls only libSceLibreSsl3's ownRSA_new,RSA_freeandBN_clear_freeand libSceLibreSsl'sLibreSslPutError_nid_no_patchbody.patched_self_importsnow passes over all 413 patched libraries.Tested
Fedora Linux 44, GCC 16.2.1, GNU ld 2.46.1, CMake 4.3.0, Ninja 1.13.2, Release build with
-DBUILD_TESTING=ON, onmainat41bb4ae756. No title, no console and no Windows host.patched_self_importspasses: "No patched library imports a name it exports (413 libraries)". In the patched modules, libSceLibreSsl defines5zpup0URQocandLibreSslRsaFree_nid_no_patch. libSceLibreSsl3 defines5zpup0URQoc, importsLibreSslRsaFree_nid_no_patch, and no longer imports5zpup0URQoc.85f73c1daf:main's copies of the three changed files andlibsrebuilt,patched_self_importsfails with the single line quoted above.main'sRsaCrypto.cpp, it fails the same way.nm -Dagainst thatmainbuild: libSceLibreSsl gains one defined name,LibreSslRsaFree_nid_no_patch. libSceLibreSsl3 defines the same names as onmain. Its only import changes areLibreSslRsaFree_nid_no_patchadded and5zpup0URQocremoved.ctest -R 'libressl|^patched_self_imports$': 184 of 184 pass. Among them,guest_libressl3_rsa_public_key_bio'sTestParentFreefrees a libSceLibreSsl key through libSceLibreSsl3'sRSA_free, which is the changed call. The guest tests load the unpatched libraries, so they cannot show the self-binding;patched_self_importsdoes.mainat27beeee0a8, which adds #22845'sd2i_RSA_PUBKEY, the build passes and the same 184 tests pass,patched_self_importsincluded.tools/select_tests.pyselects 1426 of 6123 tests for this change, and all 1426 pass.x86_64-w64-mingw32-g++16.2.1 (Fedora MinGW)-fsyntax-onlywith-D_UCRT -D__MSVCRT_VERSION__=0xE00passes forRsa.cppandRsaCrypto.cpp. Nothing ran on Windows.python3 tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.py --branchfails closed on #11466, #15278, #15279 and #15280, which all conflict withmain. I applied each one's hunks in the shared files (libSceLibreSslApi.hpp, andRsa.cppfor #11466) tomainand to this branch, and the rejected hunks are identical, so this branch adds no conflict with them. #11466 showsRSA_freeas a shared export because it re-adds theRSA_freethatmainalready has.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)