feat(libressl3): retain EVP and EC key references #11165

Merged
atharvjairath merged 1 commit from upstream-pr/11165 into main 2026-10-27 08:21:15 +00:00
atharvjairath commented 2026-10-25 20:20:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by atharvjairath on 2026-10-25T20:20:20Z.


What

EVP_PKEY_up_ref and EC_KEY_up_ref currently throw. They now increment the caller's key reference count and return whether the resulting count exceeds one, preserving all other object bytes. Atomic updates prevent lost retains when several threads share a key. The public umbrella exposes one canonical declaration and layout for each API; tests have no duplicate declarations.

Signatures, object layouts and return behavior follow pinned LibreSSL 4.0.0 commit ce488b78e0bd994780569df718596b9776ff681a: p_lib.c, evp_local.h, ec_key.c, ec_local.h and crypto_lock.c. The EVP/EC objects have 32/64-byte LP64 layouts and signed 32-bit counters at offsets 4/48. This implementation uses C++ atomic operations instead of upstream's internal mutex. Null keys and signed-count overflow, which are undefined upstream, throw without mutation.

The unchanged progress scanner reports 3 → 5 completed exports out of 87: 3.45% → 5.75% for libSceLibreSsl3, with 81 pending exports. The merged d2i_ASN1_INTEGER remains scanner-incomplete outside the pending block; its upstream implementation is not counted as one of our two completed exports. This is two more implemented exports, not a game-compatibility measurement. No other pending export is converted to a success stub.

Independent physical-console verification remains absent. The source-based layouts and limited retain/release interoperability now have the attributed firmware-module evidence below; broader compatibility remains unverified and is recorded in the existing debt file. The module has no key constructors/destructors yet; these functions operate on caller-owned objects. Future releases must synchronize with the same counters. This PR introduces no third-party dependency or copied upstream source.

The exact overlap CLI scan and manual review of the 12 current external shared-file peers found no duplicate of either function. The peers add ERR, version, ASN.1, DH/DSA/RSA getters, X509 accessors, object comparison and digest APIs. Their source/API/CMake/debt changes are separate; no unmerged peer implementation was imported into this branch. RSA retain is excluded to avoid introducing a competing RSA layout alongside #10490.

Landing order: #10948 has merged. This PR is rebased onto main c980e6ef338b8a5e59546f922b174e4d9c6ad493 with its ASN.1 decoder, canonical declarations, libc link, fixture and debt preserved. CMake, API and debt conflicts are resolved; the retain implementation, layouts and fixture are byte-identical to the prior head. No open prerequisite remains. The accepted remaining order is #11165 before #10960; #9448 also precedes #10960 and is not a prerequisite of this PR. Neither unmerged branch was imported here.

Tested

Exact head: 5255577954c2ff77aab20e4f715edf16f2c40c4a; tree: 8fa5d4b7410916562ae4f7d465ed72271413646a; parent and tested base: c980e6ef338b8a5e59546f922b174e4d9c6ad493. Recovery backup/pr-11165-before-asn1-integration-20261027-0328 preserves prior remote 220d1eb65d7f40092e17398b4539d74c6cde8b61. Author and committer: atharvjairath <[email protected]>.

  • Linux x86-64 Release, Ubuntu 24.04/GCC 13.3 under native ARM QEMU 11.0.3: 20/20 passed, 1.78 s.
  • Windows x64 PE Release, WinLibs GCC 15.2 UCRT r7 under Wine 9/QEMU 11.0.3: 19/20 passed, 94.58 s; the upstream UI fixture timed out.
  • Complete real libc, LibreSSL and LibreSSL3 libraries were built from this checkout with pinned ZArchive/zstd/mbedTLS dependencies. The focused matrix covers the two new retains, CRYPTO_memcmp, both digest libraries, cipher metadata, AES, DES, ERR, OCSP, X509 error strings, runtime, both legacy ASN.1 modes, the merged LibreSSL3 ASN.1 decoder, TLS alerts, stack, UI methods, RSA flags/size, version and CRYPTO callbacks.
  • The new fixture checks source-defined return thresholds, repeated retains, near-limit counts, all surrounding object bytes/canaries, and four threads each retaining the same key 1,000 times. No assertions are disabled.
  • Historical negative controls on prior head 220d1eb65d failed at each named unimplemented export on Linux and Windows and passed after restoring the candidate. They were not rerun in this rebase; the retain implementation and fixture remain byte-identical.
  • Focused Linux UBSan was rerun on this head; compilation with -fno-sanitize-recover=all and execution passed for Key.cpp and its fixture. The other library implementations are not sanitizer-instrumented by that check.
  • Conventions after committing, whitespace, canonical public-header audit (368 libraries, 12,359 exports) and standalone Linux C++20 -Werror umbrella compilation (included twice) pass. The export-count increase is verified against the unchanged main module using the same scanner.

The Wine matrix retains APS5_NO_WRITE_WATCH=1 only for the existing runtime and legacy ASN.1 conversion tests. Their earlier exact-base controls and failure logs are historical and were not rerun here. The allocator, UI, retain and new LibreSSL3 ASN.1 tests use defaults. The UI fixture failed with 0xc000001d in the rebuilt libc; a main LibreSSL control without our retain implementation reproduced the same failure using the identical current libc and unchanged UI executable. No new switch, assertion change or production workaround was added. The failed matrix and control logs are retained in /private/tmp/anyps5-monitor-20261026-2020; the retain and new ASN.1 tests passed on both platforms. Native/default Windows write watching, native Windows, the full project, commercial titles and PS5 hardware remain unvalidated here. Full product CI needs maintainer dispatch.

Attributed contributor evidence (not independently reproduced here):

  • BunnyFl reports three runs of the decrypted firmware 13.42 libSceLibreSsl3.sprx natively on a PC, using unchanged Key.cpp/Key.hpp from 220d1eb65d on module-created objects. Their allocations and counters match the 32/64-byte layouts and offsets 4/48. Selected signed counts from INT32_MIN through INT32_MAX-1 matched return values, new counts and unchanged surrounding bytes. Two candidate retains followed by the module's own releases freed each object only on the third release. Null keys and concurrent retains were not tested in that report; this is neither physical-console validation nor general lifetime compatibility.
  • The same report confirms a remaining boundary difference: at INT32_MAX, the firmware module wraps to INT32_MIN and returns 0; this implementation throws without mutation. That unsupported overflow path remains explicit. The report includes controls for wrong counter offsets, return thresholds and removal of the overflow check.
  • AZLisme reports a private Linux composition of #10948 77ba69041c5e, #10960 010087af4057, this exact 220d1eb65d7f and #9448 b2583e3cf11c on frozen main ae7d59258ea7: 8/8 focused Release and 8/8 ASAN tests, including ASN.1, key references and a 19-NID EVP consumer in both library load orders (3,824 cases per order). These are attributed component results with qualified existing core artifacts and pinned source-built mbedcrypto, not tests of whole current main, Windows or physical-console compatibility. Those unmerged compositions were not imported here and the report is not an approval.
Focused reproduction

Save this harness outside the checkout. Put the repository-pinned ZArchive, zstd and mbedTLS sources under its 3rdparty/ directory, including mbedTLS's framework submodule. The mbedTLS pin is 068ff080b369adfac81509f9b57b2afabaf82dc5.

cmake_minimum_required(VERSION 3.20)
project(KeyReferenceValidation LANGUAGES CXX)
enable_testing()
set(CMAKE_CXX_STANDARD 20)
set(BUILD_TESTING ON)
set(ANYPS5_SOURCE_ROOT /src CACHE PATH "AnyPS5 source checkout")
set(LIBS_INCLUDE_DIR ${ANYPS5_SOURCE_ROOT}/core/libs)
set(ANYPS5_TEST_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests)
set(ANYPS5_WINDOWS_TEST_EXIT ${ANYPS5_SOURCE_ROOT}/cmake/WindowsTestExit.cpp)
add_compile_options(-ffunction-sections -fdata-sections)
add_link_options(-Wl,--gc-sections)
function(add_test_executable target)
    add_executable(${target} ${ARGN})
    set_target_properties(${target} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "$<1:${ANYPS5_TEST_OUTPUT_DIRECTORY}>")
    if(MINGW)
        target_sources(${target} PRIVATE "${ANYPS5_WINDOWS_TEST_EXIT}")
        target_link_options(${target} PRIVATE LINKER:--wrap=main)
    endif()
endfunction()
function(add_asan_test_options test options)
    if(ANYPS5_ENABLE_ASAN)
        set_property(TEST ${test} APPEND PROPERTY ENVIRONMENT_MODIFICATION "ASAN_OPTIONS=string_append::${options}")
    endif()
endfunction()
function(configure_windows_unwind target)
    if(MINGW)
        if(NOT EXISTS "${CMAKE_OBJCOPY}")
            message(FATAL_ERROR "Windows DWARF unwinding requires objcopy")
        endif()
        add_custom_command(TARGET ${target} POST_BUILD
                COMMAND "${CMAKE_OBJCOPY}" --rename-section .eh_frame=.ehfram --rename-section .eh_fram=.ehfram "$<TARGET_FILE:${target}>"
                VERBATIM
        )
    endif()
endfunction()
if(MINGW)
    add_compile_options(-fno-asynchronous-unwind-tables)
endif()
include(${ANYPS5_SOURCE_ROOT}/cmake/ZArchive.cmake)
set(BUILD_TESTING OFF)
add_library(libc SHARED)
add_subdirectory(${ANYPS5_SOURCE_ROOT}/core/libs/prx/libc libc)
configure_windows_unwind(libc)
if(WIN32)
    target_compile_options(libc PRIVATE "SHELL:-include ${LIBS_INCLUDE_DIR}/prx/libc/include/HostStandardStreams.hpp")
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
    target_link_options(libc PRIVATE LINKER:-z,now)
    target_link_options(libc INTERFACE LINKER:--no-as-needed)
endif()
add_subdirectory(${ANYPS5_SOURCE_ROOT}/core/libs/prx/libSceSsl ssl)
set(BUILD_TESTING ON)
add_subdirectory(${ANYPS5_SOURCE_ROOT}/core/libs/prx/libSceLibreSsl libressl)
add_subdirectory(${ANYPS5_SOURCE_ROOT}/core/libs/prx/libSceLibreSsl3 libressl3)
foreach(target IN ITEMS libSceLibreSsl libSceLibreSsl3)
    target_link_libraries(${target} PUBLIC libc)
    if(WIN32)
        target_compile_options(${target} PRIVATE "SHELL:-include ${LIBS_INCLUDE_DIR}/prx/libc/include/HostStandardStreams.hpp")
    endif()
endforeach()

Configure with cmake -S <harness> -B <build> -G Ninja -DANYPS5_SOURCE_ROOT=<checkout> -DCMAKE_BUILD_TYPE=Release, build, and run ctest --test-dir <build> --output-on-failure --timeout 30. On a native x86-64 Linux host no emulator is needed; the reported Apple Silicon run sets CMAKE_CROSSCOMPILING_EMULATOR to a native ARM QEMU 11.0.3 qemu-x86_64. Windows uses WinLibs CMake/Ninja/GCC under Wine, serial -j1 compilation, and a host CTest manifest launching all actual PE tests through QEMU/Wine. Set WINELOADERNOEXEC=1, WINEPREFIX and DLL paths for libc, both LibreSSL libraries and compiler runtimes. Apply the documented Wine setting only to guest_libressl_runtime and guest_libressl_asn1.

For the isolated sanitizer check, compile core/libs/prx/libSceLibreSsl3/src/Key.cpp and core/libs/tests/GuestLibreSsl3KeyReference.cpp with -std=c++20 -O2 -g -pthread -fsanitize=undefined -fno-sanitize-recover=all -Icore/libs, then run the resulting executable. The fixture accepts evp or ec to isolate each negative control.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5008310678 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11165). Originally posted by [atharvjairath](https://github.com/atharvjairath) on 2026-10-25T20:20:20Z. --- ### What `EVP_PKEY_up_ref` and `EC_KEY_up_ref` currently throw. They now increment the caller's key reference count and return whether the resulting count exceeds one, preserving all other object bytes. Atomic updates prevent lost retains when several threads share a key. The public umbrella exposes one canonical declaration and layout for each API; tests have no duplicate declarations. Signatures, object layouts and return behavior follow pinned **LibreSSL 4.0.0** commit `ce488b78e0bd994780569df718596b9776ff681a`: [p_lib.c](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/evp/p_lib.c), [evp_local.h](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/evp/evp_local.h), [ec_key.c](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/ec/ec_key.c), [ec_local.h](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/ec/ec_local.h) and [crypto_lock.c](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/crypto_lock.c). The EVP/EC objects have 32/64-byte LP64 layouts and signed 32-bit counters at offsets 4/48. This implementation uses C++ atomic operations instead of upstream's internal mutex. Null keys and signed-count overflow, which are undefined upstream, throw without mutation. The unchanged progress scanner reports **3 → 5 completed exports out of 87: 3.45% → 5.75% for libSceLibreSsl3**, with 81 pending exports. The merged `d2i_ASN1_INTEGER` remains scanner-incomplete outside the pending block; its upstream implementation is not counted as one of our two completed exports. This is two more implemented exports, not a game-compatibility measurement. No other pending export is converted to a success stub. Independent physical-console verification remains absent. The source-based layouts and limited retain/release interoperability now have the attributed firmware-module evidence below; broader compatibility remains unverified and is recorded in the existing debt file. The module has no key constructors/destructors yet; these functions operate on caller-owned objects. Future releases must synchronize with the same counters. This PR introduces no third-party dependency or copied upstream source. The exact overlap CLI scan and manual review of the 12 current external shared-file peers found no duplicate of either function. The peers add ERR, version, ASN.1, DH/DSA/RSA getters, X509 accessors, object comparison and digest APIs. Their source/API/CMake/debt changes are separate; no unmerged peer implementation was imported into this branch. RSA retain is excluded to avoid introducing a competing RSA layout alongside #10490. **Landing order:** #10948 has merged. This PR is rebased onto main `c980e6ef338b8a5e59546f922b174e4d9c6ad493` with its ASN.1 decoder, canonical declarations, libc link, fixture and debt preserved. CMake, API and debt conflicts are resolved; the retain implementation, layouts and fixture are byte-identical to the prior head. No open prerequisite remains. The accepted remaining order is #11165 before #10960; #9448 also precedes #10960 and is not a prerequisite of this PR. Neither unmerged branch was imported here. ### Tested Exact head: `5255577954c2ff77aab20e4f715edf16f2c40c4a`; tree: `8fa5d4b7410916562ae4f7d465ed72271413646a`; parent and tested base: `c980e6ef338b8a5e59546f922b174e4d9c6ad493`. Recovery `backup/pr-11165-before-asn1-integration-20261027-0328` preserves prior remote `220d1eb65d7f40092e17398b4539d74c6cde8b61`. Author and committer: `atharvjairath <54663702+[email protected]>`. - Linux x86-64 Release, Ubuntu 24.04/GCC 13.3 under native ARM QEMU 11.0.3: **20/20 passed**, 1.78 s. - Windows x64 PE Release, WinLibs GCC 15.2 UCRT r7 under Wine 9/QEMU 11.0.3: **19/20 passed**, 94.58 s; the upstream UI fixture timed out. - Complete real libc, LibreSSL and LibreSSL3 libraries were built from this checkout with pinned ZArchive/zstd/mbedTLS dependencies. The focused matrix covers the two new retains, CRYPTO_memcmp, both digest libraries, cipher metadata, AES, DES, ERR, OCSP, X509 error strings, runtime, both legacy ASN.1 modes, the merged LibreSSL3 ASN.1 decoder, TLS alerts, stack, UI methods, RSA flags/size, version and CRYPTO callbacks. - The new fixture checks source-defined return thresholds, repeated retains, near-limit counts, all surrounding object bytes/canaries, and four threads each retaining the same key 1,000 times. No assertions are disabled. - Historical negative controls on prior head `220d1eb65d` failed at each named unimplemented export on Linux and Windows and passed after restoring the candidate. They were not rerun in this rebase; the retain implementation and fixture remain byte-identical. - Focused Linux UBSan was rerun on this head; compilation with `-fno-sanitize-recover=all` and execution passed for `Key.cpp` and its fixture. The other library implementations are not sanitizer-instrumented by that check. - Conventions after committing, whitespace, canonical public-header audit (368 libraries, 12,359 exports) and standalone Linux C++20 `-Werror` umbrella compilation (included twice) pass. The export-count increase is verified against the unchanged main module using the same scanner. The Wine matrix retains `APS5_NO_WRITE_WATCH=1` only for the existing runtime and legacy ASN.1 conversion tests. Their earlier exact-base controls and failure logs are historical and were not rerun here. The allocator, UI, retain and new LibreSSL3 ASN.1 tests use defaults. The UI fixture failed with `0xc000001d` in the rebuilt libc; a main LibreSSL control without our retain implementation reproduced the same failure using the identical current libc and unchanged UI executable. No new switch, assertion change or production workaround was added. The failed matrix and control logs are retained in `/private/tmp/anyps5-monitor-20261026-2020`; the retain and new ASN.1 tests passed on both platforms. Native/default Windows write watching, native Windows, the full project, commercial titles and PS5 hardware remain unvalidated here. Full product CI needs maintainer dispatch. **Attributed contributor evidence (not independently reproduced here):** - [BunnyFl](https://github.com/boykopovar/AnyPS5/pull/11165#issuecomment-6405417095) reports three runs of the decrypted firmware 13.42 `libSceLibreSsl3.sprx` natively on a PC, using unchanged `Key.cpp`/`Key.hpp` from `220d1eb65d` on module-created objects. Their allocations and counters match the 32/64-byte layouts and offsets 4/48. Selected signed counts from `INT32_MIN` through `INT32_MAX-1` matched return values, new counts and unchanged surrounding bytes. Two candidate retains followed by the module's own releases freed each object only on the third release. Null keys and concurrent retains were not tested in that report; this is neither physical-console validation nor general lifetime compatibility. - The same report confirms a remaining boundary difference: at `INT32_MAX`, the firmware module wraps to `INT32_MIN` and returns 0; this implementation throws without mutation. That unsupported overflow path remains explicit. The report includes controls for wrong counter offsets, return thresholds and removal of the overflow check. - [AZLisme](https://github.com/boykopovar/AnyPS5/pull/11165#issuecomment-6403451601) reports a private Linux composition of #10948 `77ba69041c5e`, #10960 `010087af4057`, this exact `220d1eb65d7f` and #9448 `b2583e3cf11c` on frozen main `ae7d59258ea7`: 8/8 focused Release and 8/8 ASAN tests, including ASN.1, key references and a 19-NID EVP consumer in both library load orders (3,824 cases per order). These are attributed component results with qualified existing core artifacts and pinned source-built mbedcrypto, not tests of whole current main, Windows or physical-console compatibility. Those unmerged compositions were not imported here and the report is not an approval. <details> <summary>Focused reproduction</summary> Save this harness outside the checkout. Put the repository-pinned ZArchive, zstd and mbedTLS sources under its `3rdparty/` directory, including mbedTLS's framework submodule. The mbedTLS pin is `068ff080b369adfac81509f9b57b2afabaf82dc5`. ```cmake cmake_minimum_required(VERSION 3.20) project(KeyReferenceValidation LANGUAGES CXX) enable_testing() set(CMAKE_CXX_STANDARD 20) set(BUILD_TESTING ON) set(ANYPS5_SOURCE_ROOT /src CACHE PATH "AnyPS5 source checkout") set(LIBS_INCLUDE_DIR ${ANYPS5_SOURCE_ROOT}/core/libs) set(ANYPS5_TEST_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests) set(ANYPS5_WINDOWS_TEST_EXIT ${ANYPS5_SOURCE_ROOT}/cmake/WindowsTestExit.cpp) add_compile_options(-ffunction-sections -fdata-sections) add_link_options(-Wl,--gc-sections) function(add_test_executable target) add_executable(${target} ${ARGN}) set_target_properties(${target} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "$<1:${ANYPS5_TEST_OUTPUT_DIRECTORY}>") if(MINGW) target_sources(${target} PRIVATE "${ANYPS5_WINDOWS_TEST_EXIT}") target_link_options(${target} PRIVATE LINKER:--wrap=main) endif() endfunction() function(add_asan_test_options test options) if(ANYPS5_ENABLE_ASAN) set_property(TEST ${test} APPEND PROPERTY ENVIRONMENT_MODIFICATION "ASAN_OPTIONS=string_append::${options}") endif() endfunction() function(configure_windows_unwind target) if(MINGW) if(NOT EXISTS "${CMAKE_OBJCOPY}") message(FATAL_ERROR "Windows DWARF unwinding requires objcopy") endif() add_custom_command(TARGET ${target} POST_BUILD COMMAND "${CMAKE_OBJCOPY}" --rename-section .eh_frame=.ehfram --rename-section .eh_fram=.ehfram "$<TARGET_FILE:${target}>" VERBATIM ) endif() endfunction() if(MINGW) add_compile_options(-fno-asynchronous-unwind-tables) endif() include(${ANYPS5_SOURCE_ROOT}/cmake/ZArchive.cmake) set(BUILD_TESTING OFF) add_library(libc SHARED) add_subdirectory(${ANYPS5_SOURCE_ROOT}/core/libs/prx/libc libc) configure_windows_unwind(libc) if(WIN32) target_compile_options(libc PRIVATE "SHELL:-include ${LIBS_INCLUDE_DIR}/prx/libc/include/HostStandardStreams.hpp") endif() if(CMAKE_SYSTEM_NAME STREQUAL "Linux") target_link_options(libc PRIVATE LINKER:-z,now) target_link_options(libc INTERFACE LINKER:--no-as-needed) endif() add_subdirectory(${ANYPS5_SOURCE_ROOT}/core/libs/prx/libSceSsl ssl) set(BUILD_TESTING ON) add_subdirectory(${ANYPS5_SOURCE_ROOT}/core/libs/prx/libSceLibreSsl libressl) add_subdirectory(${ANYPS5_SOURCE_ROOT}/core/libs/prx/libSceLibreSsl3 libressl3) foreach(target IN ITEMS libSceLibreSsl libSceLibreSsl3) target_link_libraries(${target} PUBLIC libc) if(WIN32) target_compile_options(${target} PRIVATE "SHELL:-include ${LIBS_INCLUDE_DIR}/prx/libc/include/HostStandardStreams.hpp") endif() endforeach() ``` Configure with `cmake -S <harness> -B <build> -G Ninja -DANYPS5_SOURCE_ROOT=<checkout> -DCMAKE_BUILD_TYPE=Release`, build, and run `ctest --test-dir <build> --output-on-failure --timeout 30`. On a native x86-64 Linux host no emulator is needed; the reported Apple Silicon run sets `CMAKE_CROSSCOMPILING_EMULATOR` to a native ARM QEMU 11.0.3 `qemu-x86_64`. Windows uses WinLibs CMake/Ninja/GCC under Wine, serial `-j1` compilation, and a host CTest manifest launching all actual PE tests through QEMU/Wine. Set `WINELOADERNOEXEC=1`, `WINEPREFIX` and DLL paths for libc, both LibreSSL libraries and compiler runtimes. Apply the documented Wine setting only to `guest_libressl_runtime` and `guest_libressl_asn1`. For the isolated sanitizer check, compile `core/libs/prx/libSceLibreSsl3/src/Key.cpp` and `core/libs/tests/GuestLibreSsl3KeyReference.cpp` with `-std=c++20 -O2 -g -pthread -fsanitize=undefined -fno-sanitize-recover=all -Icore/libs`, then run the resulting executable. The fixture accepts `evp` or `ec` to isolate each negative control. </details> <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
MarcZX10 commented 2026-10-25 20:29:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T20:29:47Z.

Review: COMMENTED


Reviewed exact head 220d1eb65d7f40092e17398b4539d74c6cde8b61.

The implementation matches the pinned LibreSSL retain semantics for positive and non-positive counts: it atomically increments and returns whether the new count exceeds one. It detects signed overflow before mutation, and the focused fixture checks both documented layouts/offsets, unchanged neighboring bytes, concurrent updates, return values, and null/error behavior. The technical-debt entry clearly states the unverified console layout and future release synchronization requirement.

Checks: git diff --check upstream/main...HEAD passes; three-way merge with current main is clean; eligibility, conventions, intake, labels and report checks pass. Product build jobs are skipped by policy. The Linux/Windows focused suites and Linux UBSan results in the description are author-reported; I did not rerun the extensive dependency harness locally.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5645090300 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11165#pullrequestreview-5645090300). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T20:29:47Z. **Review:** COMMENTED --- Reviewed exact head `220d1eb65d7f40092e17398b4539d74c6cde8b61`. The implementation matches the pinned LibreSSL retain semantics for positive and non-positive counts: it atomically increments and returns whether the new count exceeds one. It detects signed overflow before mutation, and the focused fixture checks both documented layouts/offsets, unchanged neighboring bytes, concurrent updates, return values, and null/error behavior. The technical-debt entry clearly states the unverified console layout and future release synchronization requirement. Checks: `git diff --check upstream/main...HEAD` passes; three-way merge with current `main` is clean; eligibility, conventions, intake, labels and report checks pass. Product build jobs are skipped by policy. The Linux/Windows focused suites and Linux UBSan results in the description are author-reported; I did not rerun the extensive dependency harness locally.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!11165
No description provided.