Repository navigation
feat(libSceLibreSsl): implement numeric ERR formatting and newest peeking - #9535
Conversation
Progress report (66e1f7f → b8dc89c)📈 System libraries: 26.3% (+0.01%, +4 implemented functions) ✅ 4 implemented
⚪ 2 behaviourally empty (constant return or throw)
Changed libraries (implemented exports)
|
MarcZX10
left a comment
There was a problem hiding this comment.
There is a concrete error-string lifecycle regression in ErrorQueue.cpp: ERR_free_strings stores StringState::Freed, but LibreSslLoadErrorStrings_nid_no_patch only transitions Uninitialized to Loaded. Therefore, after the supported sequence ERR_free_strings(); ERR_load_crypto_strings();, string loading is still disabled and later format calls continue to return numeric lib()/func()/reason() fallbacks for known errors. The free-first test currently asserts that fallback, so it hides the failed reload.
Please make the explicit load operation restore the loaded state after freeing (with a thread-safe transition), or make free a no-op for the compiled-in static tables, and add a regression assertion that a known error string is available after free then load. This behavior is separate from whether applications need to call these legacy APIs during normal operation; both exports are implemented here and the upstream API documents loading after removal as registration.
The ancestry and declared Depends on: #9529 are consistent. Hosted eligibility, conventions, intake, labels and report checks pass. All product/relinker platform jobs are skipped; the PR reports Windows builds/tests and a full-suite run with disclosed baseline failures, which I did not rerun locally. I’m requesting changes for the lifecycle issue only.
|
I checked the requested reload against the exact historical contract pinned here. LibreSSL 3.4.1 does not restore strings after this sequence:
I also built the official LibreSSL 3.4.1 release's static libcrypto outside the repository using WinLibs GCC 15.2. The relevant three source files ( #include <openssl/err.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv) {
char buffer[256];
if (argc == 1) {
ERR_load_crypto_strings();
ERR_error_string_n(0x20fff043UL, buffer, sizeof(buffer));
puts(buffer);
}
ERR_free_strings();
ERR_load_crypto_strings();
ERR_error_string_n(0x20fff043UL, buffer, sizeof(buffer));
puts(buffer);
return strcmp(buffer, "error:20FFF043:lib(32):func(4095):reason(67)") != 0;
}Running without arguments prints the named BIO error followed by the numeric fallback. Running with Pushed 3f66ff0 to make the deliberate contract clearer: both lifecycle tests now check formatting immediately after free, after one explicit load, and after a repeated free/load cycle, with queue preservation checked too. The debt file and PR description now state the one-time loading behavior. All five focused LibreSSL/patched-library tests passed (0.23 s), as did strict compiler and convention checks. The runtime implementation continues to match the pinned upstream behavior; PS5 equivalence remains unverified. Could you reconsider the lifecycle change request against this historical source and reproduction? |
MarcZX10
left a comment
There was a problem hiding this comment.
Correction to my earlier review: I rechecked the pinned LibreSSL 3.4.1 source and the updated release-source reproduction. The one-time loader uses pthread_once, and ERR_free_strings deletes the table without resetting that guard, so retaining numeric fallbacks after free followed by explicit load is consistent with this compatibility target. The new head documents and tests this historical behavior. I withdraw my earlier request for a lifecycle change; sorry for the incorrect finding. The PR remains dependent on #9529 as declared.
MarcZX10
left a comment
There was a problem hiding this comment.
Correction: the newly pushed LibreSSL-based test and documentation confirm the one-time loading behavior against the pinned source; the earlier concern is resolved. The dependent #9536 now also has a complete parent implementation and its declared Depends on chain is consistent. I have no additional code finding on the updated ERR change.
MarcZX10
left a comment
There was a problem hiding this comment.
The updated head and pinned LibreSSL 3.4.1 source/reproduction resolve my earlier concern: the historical one-time loader is not reset by ERR_free_strings, and the new lifecycle assertions and debt note accurately document that behavior. I found no remaining blocking issue in the reviewed diff. The PR declares Depends on #9529; hosted eligibility, conventions, labels and report checks pass, while product builds are skipped. The author reports focused Windows tests and compiler/convention checks, but no PS5/title, Linux or macOS run.
MarcZX10
left a comment
There was a problem hiding this comment.
One review-state note: GitHub still records my original CHANGES_REQUESTED review because the repository endpoint did not permit dismissing it, although my later review comments and approval explicitly withdraw that finding. The latest review is APPROVED after source verification; no further action is requested on the lifecycle point.
MarcZX10
left a comment
There was a problem hiding this comment.
The pinned LibreSSL 3.4.1 source and the updated release-source reproduction resolve my earlier concern. The one-time loader is not reset by ERR_free_strings, and the new lifecycle tests/documentation match that contract. I found no remaining blocking issue. Depends on #9529 is declared. Current eligibility, conventions, labels and report checks pass; product checks are skipped, and the author reports focused Windows tests and compiler/convention checks.
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
MarcZX10
left a comment
There was a problem hiding this comment.
Rechecked the current ERR string lifecycle change against the pinned LibreSSL 3.4.1 source. The added loaded-first/free-first process tests correctly cover the pthread_once behavior and preserve numeric fallbacks after free/reload; the prior concern is resolved. #9529 remains open as the declared predecessor. Eligibility, conventions, intake, labels and report checks pass; product/relinker builds were skipped. I did not run local tests.
jotitadev
left a comment
There was a problem hiding this comment.
Linux run, since the description says only Windows was used. The full build and the ERR tests pass, and they run clean under ASan and UBSan.
Machine: Linux, Ubuntu 26.04, GCC 15.2.0, Python 3.14, x86-64. Head 3f66ff0de merged with git merge --no-commit onto current main d6eafa54d (clean), 3rdparty/libressl-openbsd initialized at 078b3d1df.
- Release (Ninja,
BUILD_TESTING=ON,ANYPS5_RELINKER_ONLY=OFF): the full build passes, includingGenerateErrorStrings.pyproducingErrorStrings.incwith Python 3.14.guest_libressl_error,guest_libressl_errors,guest_libressl_free_strings,guest_libressl_free_strings_firstandpatched_librariespass (5/5). - ASan + UBSan (
-fsanitize=address,undefined -fno-sanitize-recover=undefined -O1 -g,ANYPS5_ENABLE_ASAN=ON, leak detection off):guest_libressl_error_string_testswith no argument,freeandfree-first, andguest_libressl_error_tests, all exit 0 with no reports.
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
|
I rechecked the current head against today’s upstream |
|
@Felipebmaitan, a full CI run with this head (
Could you move the generation next to the target, or wrap it in an |
|
Refreshed existing stack head Owned order: #9535 → #9536 → #9571. #9529/#11165 are merged. For #9571, #9446 remains an external prerequisite; its author has not confirmed the proposed order. Its inherited BN integration is preserved, not treated as new agreement or validation of the firmware differences reported on #9446. Ubuntu 24.04 amd64 container through Docker on Apple Silicon; GCC 13.3.0, CMake 3.28.3, Ninja, Python 3.12.3, Release. Actual source-built libc/libkernel/LibreSSL/LibreSSL3 and pinned bundled dependencies, using the component harness below. This is not full root configuration or native Windows/macOS/console evidence. The initial CMAC build was clean; final stack heads were reconfigured/rebuilt incrementally. Docker logs userfaultfd unavailable (Operation not permitted), using libc's existing memory-comparison fallback. Native commands set Native focused CTest outputConventionsWhitespaceStandalone public headersGenerator recoveryGenerator SHA256 beforeGenerator SHA256 afterPublic definitions and NIDsScoped registration auditAll scoped executables are registered. This is not a full-root registration pass: the component harness omits the root registrations of nine unrelated libc fixtures, which the global checker reports as unrun ( External reproduction harnessSave this outside the repository; mount the exact head at cmake_minimum_required(VERSION 3.20)
project(LibreSslStackValidation LANGUAGES C CXX)
enable_testing()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(LIBS_INCLUDE_DIR /src/core/libs)
set(ANYPS5_TEST_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests)
set(PATCHED_DIR ${CMAKE_BINARY_DIR}/patched)
function(add_test_executable target)
add_executable(${target} ${ARGN})
set_target_properties(${target} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${ANYPS5_TEST_OUTPUT_DIRECTORY})
endfunction()
function(configure_windows_unwind target)
endfunction()
function(add_asan_test_options)
endfunction()
add_compile_options(-ffunction-sections -fdata-sections)
add_link_options(-Wl,--gc-sections)
include(/src/cmake/ZArchive.cmake)
set(BUILD_TESTING OFF)
add_library(libc SHARED)
add_subdirectory(/src/core/libs/prx/libc libc)
target_include_directories(libc PRIVATE ${LIBS_INCLUDE_DIR})
target_link_options(libc PRIVATE LINKER:-z,now)
target_link_options(libc INTERFACE LINKER:--no-as-needed)
add_subdirectory(/src/core/libs/prx/libkernel kernel)
add_subdirectory(/src/core/libs/prx/libSceSsl ssl)
set(BUILD_TESTING ON)
add_subdirectory(/src/core/libs/prx/libSceLibreSsl libressl)
add_subdirectory(/src/core/libs/prx/libSceLibreSsl3 libressl3)
foreach(target libSceLibreSsl libSceLibreSsl3)
target_link_libraries(${target} PUBLIC libc PRIVATE libkernel)
endforeach()
include(/src/core/libs/prx/libSceLibreSsl/ErrorQueue.cmake)
if(EXISTS /src/core/libs/prx/libSceLibreSsl/MemoryBio.cmake)
include(/src/core/libs/prx/libSceLibreSsl/MemoryBio.cmake)
endif()
if(EXISTS /src/core/libs/prx/libSceLibreSsl/Cmac.cmake)
include(/src/core/libs/prx/libSceLibreSsl/Cmac.cmake)
endif()
file(GLOB patcherSources /src/core/libs/nid/src/*.cpp)
add_executable(nid_patcher ${patcherSources})
target_include_directories(nid_patcher PRIVATE /src/core/libs/nid/include)
foreach(target libc libkernel libSceLibreSsl libSceLibreSsl3)
set_target_properties(${target} PROPERTIES PREFIX "" SUFFIX .prx BUILD_RPATH "$ORIGIN" BUILD_WITH_INSTALL_RPATH ON INSTALL_RPATH "$ORIGIN")
add_custom_command(OUTPUT ${PATCHED_DIR}/${target}.prx
COMMAND ${CMAKE_COMMAND} -E make_directory ${PATCHED_DIR}
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${target}> ${PATCHED_DIR}/${target}.prx
COMMAND $<TARGET_FILE:nid_patcher> ${target} ${PATCHED_DIR}/${target}.prx
DEPENDS ${target} nid_patcher)
list(APPEND patched ${PATCHED_DIR}/${target}.prx)
endforeach()
add_custom_target(focused_patched ALL DEPENDS ${patched})
if(BIO_CONTROL)
get_target_property(sslSources libSceLibreSsl SOURCES)
list(REMOVE_ITEM sslSources /src/core/libs/prx/libSceLibreSsl/src/Bio.cpp)
set_property(TARGET libSceLibreSsl PROPERTY SOURCES ${sslSources})
target_sources(libSceLibreSsl PRIVATE /validation/BioNoGrowthWipe.cpp)
endif()
The optional control replaces only the single Complete overlap output (limitations retained)Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
No full-product/whole-suite, new Windows, sanitizer, title, PS5, or hosted product-CI pass is claimed. Maintainer-dispatched full Linux/Windows CI and current-head review remain outstanding. AI-assisted: yes. |
|
@Felipebmaitan the ERR formatting and queue changes read right to me against the pinned 3.4.1 source. One build-scope request: the generated Could you put the submodule check, the generator and that dependency under |
|
@oneandonlydean The build-scope request in #9535 (comment) is present in published head Runtime The combined source-built Linux component suite passes 39 native + 3 patched cases, including ERR queue/lifecycle, BIO/CMAC and current main regressions. Canonical audit (393 libraries/24,536 exports), standalone headers, conventions and scoped registrations pass. This is an amd64 Docker run on Apple Silicon, not native Windows/macOS runtime, full root CI or console evidence. This unchanged lower head was not independently rebuilt in this refresh; exact commands, harness, scope limits and combined-head evidence are in the current-main validation response. The PR template now distinguishes that evidence from historical prerequisite runs. Acceptance of the test-input submodule remains a maintainer decision. AI-assisted: yes. |
|
@oneandonlydean Addressed the remaining maintainer request on the existing stack, refreshed bottom-up without force-pushing or dropping maintainer ancestry:
This PR: The BIO test change removes exactly the ex-data assignment, Exact head
The harness imports actual repository library/test fragments, source-building pinned dependencies; it is not the full root/product suite. Docker denies userfaultfd, invoking libc's existing comparison fallback. No new local Windows/macOS runtime, sanitizer, title or physical-console run was performed; no skipped/pending hosted job is counted as passed. Firmware-module evidence remains PC execution with stand-in imports. Earlier no-Python fragment and bounded BIO negative-control evidence is historical; those settled checks were not rerun, and neither production BIO nor the wipe assertions changed. Hosted CI for Owned order remains #9535 → #9536 → #9571. External blocker only for CMAC: the #9446 author has not confirmed the proposed #9446-before-#9571 order in the linked request; no change or agreement is attributed to that branch. Its independent BN firmware/rebase work is not claimed fixed. No merge or replacement PR. AI-assisted: yes. Native focused testsPatched focused testsERR fixture recoveryPreservation/count/NID auditHeadersScoped registrationsConventionsOverlap output: exit 2, including incomplete comparisonsOther open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
Reproduction harness and test commandsConfigure: cmake_minimum_required(VERSION 3.20)
project(LibreSslStackValidation LANGUAGES C CXX)
enable_testing()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
option(LIBRESSL_TESTING "Build focused tests" ON)
set(LIBS_INCLUDE_DIR /src/core/libs)
set(ANYPS5_TEST_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests)
set(PATCHED_DIR ${CMAKE_BINARY_DIR}/patched)
function(add_test_executable target)
add_executable(${target} ${ARGN})
set_target_properties(${target} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${ANYPS5_TEST_OUTPUT_DIRECTORY})
endfunction()
function(configure_windows_unwind target)
endfunction()
function(configure_host_test_executable target)
endfunction()
function(add_asan_test_options)
endfunction()
add_compile_options(-ffunction-sections -fdata-sections)
add_link_options(-Wl,--gc-sections)
include(/src/cmake/ZArchive.cmake)
set(BUILD_TESTING OFF)
add_library(libc SHARED)
add_subdirectory(/src/core/libs/prx/libc libc)
target_include_directories(libc PRIVATE ${LIBS_INCLUDE_DIR})
target_link_options(libc PRIVATE LINKER:-z,now)
target_link_options(libc INTERFACE LINKER:--no-as-needed)
add_subdirectory(/src/core/libs/prx/libkernel kernel)
add_subdirectory(/src/core/libs/prx/libSceSsl ssl)
set(BUILD_TESTING ${LIBRESSL_TESTING})
add_subdirectory(/src/core/libs/prx/libSceLibreSsl libressl)
add_subdirectory(/src/core/libs/prx/libSceLibreSsl3 libressl3)
foreach(target libSceLibreSsl libSceLibreSsl3)
target_link_libraries(${target} PUBLIC libc PRIVATE libkernel)
endforeach()
include(/src/core/libs/prx/libSceLibreSsl/ErrorQueue.cmake)
if(EXISTS /src/core/libs/prx/libSceLibreSsl/MemoryBio.cmake)
include(/src/core/libs/prx/libSceLibreSsl/MemoryBio.cmake)
endif()
if(EXISTS /src/core/libs/prx/libSceLibreSsl/Cmac.cmake)
include(/src/core/libs/prx/libSceLibreSsl/Cmac.cmake)
endif()
add_custom_target(libs)
include(/src/core/libs/prx/libSceLibreSsl/ProtocolSelection.cmake)
file(GLOB patcherSources /src/core/libs/nid/src/*.cpp)
add_executable(nid_patcher ${patcherSources})
target_include_directories(nid_patcher PRIVATE /src/core/libs/nid/include)
foreach(target libc libkernel libSceLibreSsl libSceLibreSsl3)
set_target_properties(${target} PROPERTIES PREFIX "" SUFFIX .prx BUILD_RPATH "$ORIGIN" BUILD_WITH_INSTALL_RPATH ON INSTALL_RPATH "$ORIGIN")
add_custom_command(OUTPUT ${PATCHED_DIR}/${target}.prx
COMMAND ${CMAKE_COMMAND} -E make_directory ${PATCHED_DIR}
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${target}> ${PATCHED_DIR}/${target}.prx
COMMAND $<TARGET_FILE:nid_patcher> ${target} ${PATCHED_DIR}/${target}.prx
DEPENDS ${target} nid_patcher)
list(APPEND patched ${PATCHED_DIR}/${target}.prx)
endforeach()
add_custom_target(focused_patched ALL DEPENDS ${patched})
add_dependencies(libs focused_patched)set -eu
layer=$1
LD_LIBRARY_PATH=/validation/build:/validation/build/kernel:/validation/build/libressl:/validation/build/libressl3 ctest --test-dir /validation/build -R '^(guest_libressl|guest_crypto_memcmp)' -E '(_patched|_nid)$' --output-on-failure --no-tests=error > /evidence/$layer-native.log 2>&1
LD_LIBRARY_PATH=/validation/build/patched ctest --test-dir /validation/build -R '^guest_libressl_((bio|cmac)_patched|protocol_nid)$' --output-on-failure --no-tests=error > /evidence/$layer-patched.log 2>&1
python3 /src/tools/check_test_registration.py --list /validation/build > /evidence/$layer-registrations.txt
ninja -C /validation/build -t commands libressl/libSceLibreSsl.prx libressl3/libSceLibreSsl3.prx > /evidence/$layer-runtime-commands.txt
! grep -q GenerateErrorStrings.py /evidence/$layer-runtime-commands.txt
test "$(grep -c -- '-c /src/core/libs/prx/libSceLibreSsl/src/Error.cpp' /evidence/$layer-runtime-commands.txt)" = 1
sha256sum /validation/build/prx/libSceLibreSsl/ErrorStrings.inc > /evidence/$layer-fixture.log
rm /validation/build/prx/libSceLibreSsl/ErrorStrings.inc
cmake --build /validation/build --target libSceLibreSsl libSceLibreSsl3 >> /evidence/$layer-fixture.log 2>&1
test ! -e /validation/build/prx/libSceLibreSsl/ErrorStrings.inc
cmake --build /validation/build --target guest_libressl_error_string_tests >> /evidence/$layer-fixture.log 2>&1
sha256sum /validation/build/prx/libSceLibreSsl/ErrorStrings.inc >> /evidence/$layer-fixture.log
LD_LIBRARY_PATH=/validation/build:/validation/build/kernel:/validation/build/libressl:/validation/build/libressl3 ctest --test-dir /validation/build -R '^guest_libressl_(errors|free_strings|free_strings_first)$' --output-on-failure --no-tests=error >> /evidence/$layer-fixture.log 2>&1
tail -5 /evidence/$layer-native.log
tail -5 /evidence/$layer-patched.log |
|
@BunnyFl, your 13.42 native module check found that the three direct ERR string lookups returned NULL for all 917 codes. If you still have that harness, could you check whether the direct AI-assisted: yes (Codex). |
|
@B-Howell Thanks for asking with the exact shape of the answer you needed. Neither loader changes those results: in firmware 13.42 the body of each one is a single They are not in this pull request's library.
Both loader bodies, in full. The byte at The three lookups are by contrast real functions — Measured, not only read. I still had the harness, so I ran the exports of
Three identical runs, same result each time. The before/after you asked for, on real table rows.
For The other loaders, since it is the obvious next question. Not covered:
🤖 Generated with Claude Code |
What
Numeric ERR formatting, queue peeking and test-only names fixture. Refreshed onto fetched main
4ac683fe026c3368e508ace9745d3017e12a1207without rewriting published history. Pending exports independently recounted after integration: 287 inlibSceLibreSsl/Export.cpp(literal calls and direct exported stub bodies agree). Published ERR numeric-before/after-load/free behavior, test-only generation/Python/submodule scope, shared queue and registrations are preserved. All main implementation sources and the old/main public-definition/NID union are retained.Tested
Exact head
b8dc89c0f887e725b97ad2ea112fb6eded347e27, main integration base4ac683fe026c3368e508ace9745d3017e12a1207. Ubuntu 24.04.5 amd64 Docker container on Apple Silicon, GCC 13.3.0, CMake 3.28.3, Ninja 1.11.1, Python 3.12.3, Release.44af6828fdc064ca16f94aeb07ac913651d2bfce0f5ecbeee6b9b476e6be24e3); all three lifecycle cases pass again. Runtime Ninja graphs exclude the generator and compilesrc/Error.cpponce.python3 tools/check_conventions.py --base origin/mainand whitespace pass in an isolated Git context pinningorigin/mainto the integration base above, without changing shared tracking refs.The harness imports actual repository library/test fragments, source-building pinned dependencies; it is not the full root/product suite. Docker denies userfaultfd, invoking libc's existing comparison fallback. No new local Windows/macOS runtime, sanitizer, title or physical-console run was performed; no skipped/pending hosted job is counted as passed. Firmware-module evidence remains PC execution with stand-in imports. Earlier no-Python fragment and bounded BIO negative-control evidence is historical; those settled checks were not rerun, and neither production BIO nor the wipe assertions changed. Hosted CI for
b8dc89c0f887e725b97ad2ea112fb6eded347e27:windows,conventions,library-portability,eligibility,labelsandreportsucceeded.linux,relinker,relinker-asan,register-contextandwrite-watchwere skipped; an earlier conventions run was cancelled. GitHub reports CLEAN / MERGEABLE. Skipped jobs are not counted as executed. Current-head maintainer re-review remains pending. Exact logs, harness, audits and overlap limitations are in the latest validation reply.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)