Skip to content

fix(libSceLibreSsl3): copy X509V3_EXT_d2i extension guest pointer safely - #22890

Open
Gruzzberry wants to merge 1 commit into
boykopovar:mainfrom
Gruzzberry:fix-x509v3extd2i
Open

Gruzzberry wants to merge 1 commit into
boykopovar:mainfrom
Gruzzberry:fix-x509v3extd2i

Conversation

@Gruzzberry

Copy link
Copy Markdown
Contributor

What

X509V3_EXT_d2i reads the caller's X509_EXTENSION through a checked guest copy and throws std::invalid_argument (as for a null pointer) when it is unreadable. Valid-pointer behaviour is unchanged.

Tested

g++ -std=c++20 -fsyntax-only of X509V3ExtD2i.cpp with the repo include dirs: clean. tools/check_conventions.py --base upstream/main: passed. Duplicate check: script comparing against every open PR's changed files: clean. Not run on a title.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the prx label Nov 18, 2026
@maskym

maskym commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Windows result for head 0d2af5365f, merged alone into main 7b2370120c (the PR's Tested section names no Windows run).

Host: Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release, BUILD_TESTING=ON, Ninja. main itself fails to compile one test on Windows at this commit (UploadCacheReadOnlyFlush.cpp:177, setenv; #19899 fixes it), so the tree was built with ninja -k 0. This PR adds no other build failure.

nkwebkit_displayliststateitems, the test this PR adds or extends, passes 3 of 3 runs. Not run on a PS5.

AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine.

This was referenced Nov 21, 2026
@kiwe147

kiwe147 commented Nov 21, 2026

Copy link
Copy Markdown

Tested head 0d2af5365f, applied with git apply on main fd4aeed483 together with the other 29 PRs of one batch (#16191, #16207, #17573, #18945, #20978, #21054, #22002, #22003, #22042, #22078, #22822, #24354, #24484, #12860, #18915, #19999, #22160, #22891, #23488, #23751, #24051, #24578, #14506, #19462, #22206, #22291, #22627, #24048, #24424). All applied without conflicts and the whole tree built.

Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. GPUs: NVIDIA GeForce RTX 3080 (driver 621.24) and the AMD Radeon iGPU of the CPU (gfx1036, driver 32.0.21036.18). No validation layer. iGPU run: ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ANYPS5_GPU="AMD Radeon", agc_/video tests only.

tests RTX 3080 iGPU
none: no test of its own in this PR - -

Whole batch: the full ctest -j 12 (6526 tests) on the RTX 3080 has 15 failing tests; the 4 that also fail on main fd4aeed483 are agc_driver_stencil_plane_memory, agc_driver_msaa_dcc_unwatch, agc_storage_write_back_host_retile, and pr_overlap_names, which needs a newer Python than my 3.10. Intermittent in this run (pass when rerun alone, or known flaky): agc_driver_store_over_untracked. Traced to other PRs of the batch, each by reverting it and testing again: #12860 (guest_user_service_account_name_limits, guest_user_service_age_level_guest_bounds, guest_user_service_initial_user_bounds, guest_user_service_kratos), #22891 (nkwebkit_securityorigin), #18915 (public_headers); none is in this PR's area. Failing tests I could not trace to a single PR (reverting the likely candidates did not clear them): guest_apr_read_longeof, guest_filesystem, guest_kernel_rename, guest_windows_directory_link_types, tools_patch_advisor_json, tools_suggest_patches. The 2125 agc_/video tests on the iGPU have 2 failing: agc_driver_stencil_plane_memory, agc_driver_store_over_untracked (agc_driver_stencil_plane_memory also fails on main).

This is one combined tree, not a run of this PR alone.

AI-assisted: yes (Claude Code)

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

The changed function copies the top-level extension through the guest-memory helper before reading it; no verified blocking defect was found in the inspected change.

What I ran

Reviewed head 0d2af5365fce6e8c8033b94f1c12611348565520 against the prepared diff; no build or test command was run. The author reports a syntax-only compile and convention check in the PR description; these were not run during this review.

Read description.md, commits.md, manifest.json, diff.patch, the complete changed file core/libs/prx/libSceLibreSsl3/src/X509V3ExtD2i.cpp, core/libs/prx/libSceLibreSsl3/include/Api.hpp (lines 80–115), core/libs/prx/libSceLibreSsl3/tests/X509V3ExtD2i.cpp (lines 1–180 and 300–370 and 405–450), core/libs/prx/libSceLibreSsl3/src/X509Crl.cpp (lines 350–374), and core/libs/prx/libc/src/General.cpp (lines 980–1010). No changed files were excluded; files.json was not listed in the prepared bundle.

Results

Check Result Note
Source review passed Changed file read in full
Build and tests not run Author-reported checks not independently run
Runtime guest-memory behavior not run No runtime test performed

Findings

Blocking

None.

Non-blocking

None.

Not verified

The author-reported syntax-only compile, convention check, and duplicate check were not independently verified. Runtime behavior for unreadable guest pointers was not exercised. The prepared bundle did not include files.json, so its reviewed/excluded listing could not be checked directly.

To get this to a good state

Nothing is required.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

The top-level copy is right and throwing on an unreadable extension matches the null check and the library convention, so no change there. Two things before this can go in. Please add a case to tests/X509V3ExtD2i.cpp that passes an unreadable extension pointer and expects std::invalid_argument. Also, the guard stops at the outer struct: extension->object->length, OBJ_obj2nid and Decode (encoded->length and encoded->data) still read the nested guest pointers directly, so a bad object or value pointer still crashes the host. Copying those headers through the same checked path would make the fix complete; GuestPtr(p).CopyIn with APS5_INVALID_ARG_EX, as in EcAsn1.cpp, would also replace the manual errno save and restore.

@ligmaSec ligmaSec left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Built the submitted X509 extension decoder and ran the existing exact X509V3ExtD2i fixture on Linux. It passed the extension decoding and error cases with the pinned project libraries. I traced the added guest copy before the extension fields are used.

AI-assisted: yes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants