Skip to content

fix(libSceNpEulaDialog): return ARG_NULL when open param is unreadable - #22002

Closed
Kikoarl wants to merge 1 commit into
boykopovar:mainfrom
Kikoarl:fix/libSceNpEulaDialog-open-param-unreadable
Closed

Kikoarl wants to merge 1 commit into
boykopovar:mainfrom
Kikoarl:fix/libSceNpEulaDialog-open-param-unreadable

Conversation

@Kikoarl

@Kikoarl Kikoarl commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

What

Safely probe the guest parameter pointer with GuestCopyIn_nid_no_patch in sceNpEulaDialogOpen before transition, preserving caller errno and returning COMMON_DIALOG_ERROR_ARG_NULL (0x80B8000D) if unreadable.

Tested

  • Unit tests in tests/guest_np_eula_dialog_tests verifying unreadable parameter refusal and errno preservation.
  • Passes python3 tools/check_conventions.py --base origin/main.

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: none
  • AI-assisted: yes

@PrivacyOnion PrivacyOnion 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.

Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 062a017e46:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_np_eula_dialog_tests built cleanly.
  • CTest (guest_np_eula_dialog):
    1/1 Test #4595: guest_np_eula_dialog .............   Passed    0.45 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNpEulaDialog/Export.cpp reverted to main and the new tests kept, the suite fails:
    1/1 Test #4595: guest_np_eula_dialog .............Subprocess aborted***Exception:   0.13 sec
    0% tests passed, 1 tests failed out of 1
    
    Restoring the change makes it pass again.
  • Code reading:
    • core/libs/prx/libSceNpEulaDialog/Export.cpp: sceNpEulaDialogOpen probes param with GuestCopyIn_nid_no_patch(&probe, param, sizeof(probe)) while preserving caller errno on both success and failure paths
    • core/libs/prx/libSceNpEulaDialog/Export.cpp: status checks (COMMON_DIALOG_STATUS_NONE -> COMMON_DIALOG_ERROR_NOT_INITIALIZED, COMMON_DIALOG_STATUS_RUNNING -> COMMON_DIALOG_ERROR_BUSY) remain correctly ordered before pointer checks
    • core/libs/prx/libSceNpEulaDialog/Export.cpp: returns COMMON_DIALOG_ERROR_ARG_NULL (0x80B8000Du) when param is nullptr or unreadable guest memory
    • core/libs/prx/libSceNpEulaDialog/Export.cpp: atomic CAS loop g_status.compare_exchange_weak(status, COMMON_DIALOG_STATUS_FINISHED) remains thread-safe
    • core/libs/tests/GuestNpEulaDialog.cpp: verified unit test exercises unreadable address 0x10 and verifies caller errno preservation

Looks Good To Me

@github-actions github-actions Bot added the prx label Nov 17, 2026
@maskym

maskym commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Windows result for head 062a017e46, merged alone into main 56c87adbdc (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. Microsoft Defender on this machine quarantines 34 AGC test executables as Trojan:Win64/ShellCode.MKA!MTB when they are linked (the case docs/dev/BUILD.md describes), so their objcopy step fails on both trees and those tests do not run here. This PR adds no other build failure.

guest_np_eula_dialog, 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.

@kiwe147

kiwe147 commented Nov 21, 2026

Copy link
Copy Markdown

Tested head 062a017e46, applied with git apply (with -C1, context shifted) on main fd4aeed483 together with the other 29 PRs of one batch (#16191, #16207, #17573, #18945, #20978, #21054, #22003, #22042, #22078, #22822, #24354, #24484, #12860, #18915, #19999, #22160, #22890, #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
guest_np_eula_dialog (1 test, matched by name to the test file this PR changes) all pass outside the iGPU subset

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)

This was referenced Nov 21, 2026

@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

Nothing blocks this change; the unreadable-pointer check preserves errno and returns the argument error before changing dialog state.

What I ran

Reviewed head 062a017e46d0e2b176977b7ec09e06e9a081dd32 and the prepared diff. I did not run tests or commands. The PR description reports unit tests and a conventions check; those were not run by me.

Results

Check Result Note
Diff and changed source review passed Both changed files read
Tests and conventions check not run Reported by the author only

Findings

Blocking

None.

Non-blocking

None.

Not verified

No files were excluded from the prepared diff. The two changed files listed in the manifest were read in full. Tests, conventions check, and runtime behavior were not independently verified.

To get this to a good state

Nothing is required.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@Kikoarl, I am closing this one. On main this Open function never reads param, it only checks it for null, so an unreadable pointer cannot crash the host here, and the ARG_NULL answer for it is not measured on a console. That leaves a guessed error code for a case no title is known to hit. If you have a title that passes such a pointer, together with what a retail PS5 returns, please reopen with that and it goes to review.

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