Repository navigation
fix(libSceLibreSsl): read the X509_VERIFY_PARAM_set1_host name through checked copies - #21634
Merged
oneandonlydean merged 1 commit intoNov 16, 2026
Conversation
…h checked copies X509_VERIFY_PARAM_set1_host measured the guest name with strlen, scanned it with memchr and duplicated it with strndup, all in place. It now reads the name through GuestCopyIn in page-bounded chunks, up to the terminator or the counted length, keeps the embedded-NUL refusal and errno, and duplicates the host copy. An unreadable name throws, as null verify parameters do, and leaves the host list as it was. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PrivacyOnion
approved these changes
Nov 16, 2026
PrivacyOnion
left a comment
Contributor
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 1cf2124a59:
- Conventions:
tools/check_conventions.pypassed;git diff --checkclean. - Build:
guest_libressl_x509_store_testsbuilt cleanly. - CTest (
guest_libressl_x509_store,guest_libressl_x509_store_allocator):1/2 Test #4179: guest_libressl_x509_store ............. Passed 0.04 sec 2/2 Test #4180: guest_libressl_x509_store_allocator ... Passed 0.04 sec 100% tests passed, 0 tests failed out of 2 - Negative control: with
core/libs/prx/libSceLibreSsl/src/X509Store.cppreverted tomainand the new tests kept, the suite fails:Restoring the change makes it pass again.1/2 Test #4180: guest_libressl_x509_store_allocator ... Passed 0.03 sec 2/2 Test #4179: guest_libressl_x509_store .............***Exception: SegFault 0.51 sec 50% tests passed, 1 tests failed out of 2 - Code reading:
- Verified
ReadHostNameincore/libs/prx/libSceLibreSsl/src/X509Store.cpp:169-187bounds eachGuestCopyIn_nid_no_patchcall toPage - address % Page(at most 4096 bytes) andlength - host.size()when counted, preventing page-boundary overreads and buffer overflows. - Verified
ReadHostNamesaves and restoreserrnoaroundGuestCopyIn_nid_no_patch(X509Store.cpp:177-179) and throwsstd::invalid_argumenton unreadable memory beforeX509_VERIFY_PARAM_set1_host_nid_postfixmodifiesid->hosts. - Verified NUL handling in
ReadHostName(X509Store.cpp:181-183): whenlength == 0(!counted), stops at the first NUL and returnstrue; whenlength > 0(counted), returnsfalseon any embedded NUL soX509_VERIFY_PARAM_set1_host_nid_postfixreturns0without clearingid->hosts. - Verified empty and null name handling in
X509_VERIFY_PARAM_set1_host_nid_postfix(X509Store.cpp:277-287):name == nullptror an empty NUL-terminated string leaveshost.empty() == true, freesid->hosts, setsid->hosts = nullptr, and returns1. - Verified LP64/LLP64 type safety (
std::min<std::size_t>,std::uintptr_t,std::size_t), debt fragmentdocs/dev/debt/changes/fix-libressl-x509-set1-host-guest-copy.md, and multi-page/unreadable/embedded-NUL test coverage incore/libs/prx/libSceLibreSsl/tests/X509Store.cpp:205-220.
- Verified
Looks Good To Me
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
X509_VERIFY_PARAM_set1_hostmeasured the guest name withstd::strlenwhen the length was 0, scanned it withstd::memchrfor an embedded NUL, and duplicated it withstrndup, all in place. So an unreadable name crashed the host.The name is now read through
GuestCopyIn_nid_no_patch. A newReadHostNamedoes it in chunks that never cross a 4 KiB boundary:strlendid. A name that ends right before an unreadable page still works.memchrdid.The duplicate is taken from the host bytes with the same
strndup, so the list still owns guest-heap strings thatX509_STORE_freereleases. An unreadable name throwsstd::invalid_argument, as null verify parameters already do, and leaves the list as it was.errnois kept.What stays the same: a null or empty name clears the list and returns 1; a set replaces the list; the counted form needs no terminator.
Tested
Linux (Ubuntu 26.04.1, kernel 7.0), GCC 15.2, Ninja, Release,
-DBUILD_TESTING=ON:guest_libressl_x509_storegains these cases inHosts(), witherrnoheld at 71:0x10) name with a length of 0 and with a length of 4 throws,errnostays 71, and the list still holds the previouskept.example;guest_libressl_x509_store*tests pass, 3 runs of 3.main'sX509Store.cppand the new cases,guest_libressl_x509_storeends infatal SIGSEGV (code 1) at address 0x0000000000000010.tools/check_conventions.pypasses on the branch and this body.X509Store.cpp(none touchesset1_host); this branch merges cleanly with each.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)