Skip to content

fix(libSceNpSnsFacebookDialog): return ARG_NULL when open param is unreadable - #21995

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

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

Conversation

@Kikoarl

@Kikoarl Kikoarl commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

What

This pull request updates sceNpSnsFacebookDialogOpen to validate unreadable non-null param pointers safely:

  • Reads 1 byte from param via GuestCopyIn_nid_no_patch while preserving caller errno and returning COMMON_DIALOG_ERROR_ARG_NULL (0x80B8000D) on failure.
  • Adds unreadable param and errno preservation checks in core/libs/tests/GuestNpSnsFacebookDialog.cpp.
  • Documents the unmeasured 0x80B8000D fallback in docs/dev/debt/changes/fix-libSceNpSnsFacebookDialog-open-param-unreadable.md (folded into the libSceNpSnsFacebookDialog debt entry).

Tested

  • Built and ran guest_np_sns_facebook_dialog_tests (ctest --test-dir /tmp/anyps5_build_pad --output-on-failure -R "^guest_np_sns_facebook_dialog$"): 1/1 passed.
  • Verified conventions with python3 tools/check_conventions.py --base origin/main.

Checklist

  • Commits correspond to isolated fixes or features
  • Code conforms to project conventions
  • Explanation of the problem and proposed solution included above
  • Dependent changes have been merged
  • Verification steps included above
  • Dependabot/renovate PRs are not touched
  • Zero code comments in implementation diffs
  • All unmeasured hardware behavior documented in debt fragment
  • Depends on: none
  • AI-assisted: yes
    Fixes: none
    Unblocks: none
    GPUs tested: none

@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 bf7f8a3aca:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_np_sns_facebook_dialog_tests built cleanly.
  • CTest (guest_np_sns_facebook_dialog):
    1/1 Test #4608: guest_np_sns_facebook_dialog .....   Passed    0.36 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNpSnsFacebookDialog/Export.cpp reverted to main and the new tests kept, the suite fails:
    1/1 Test #4608: guest_np_sns_facebook_dialog .....Subprocess aborted***Exception:   0.12 sec
    0% tests passed, 1 tests failed out of 1
    
    Restoring the change makes it pass again.
  • Code reading:
    • Verified GuestCopyIn_nid_no_patch safely probes param readability before state transition and returns COMMON_DIALOG_ERROR_ARG_NULL (0x80B8000D) on unreadable pointer in core/libs/prx/libSceNpSnsFacebookDialog/Export.cpp
    • Verified errno preservation across GuestCopyIn_nid_no_patch probing via savedErrno restoration on both failure and success paths
    • Verified loop and atomic state progression in sceNpSnsFacebookDialogOpen ensuring no state corruption or race condition occurs prior to successful probe
    • Verified test coverage in core/libs/tests/GuestNpSnsFacebookDialog.cpp verifying rejection of unreadable guest pointer (0x10) and errno preservation
    • Verified compliance with AGENTS.md conventions (no disallowed comments, no forbidden files, no hardcoded title workarounds)

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 bf7f8a3aca, 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_sns_facebook_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 bf7f8a3aca, applied with git apply (with -C1, context shifted) on main fd4aeed483 together with the other 29 PRs of one batch (#24470, #24601, #17439, #17546, #21117, #21261, #21741, #22067, #22398, #23111, #23346, #23864, #24377, #24475, #24556, #14106, #14109, #19966, #20050, #20161, #20622, #21237, #22215, #22764, #22884, #22938, #23745, #24399, #24460). 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_sns_facebook_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 (6525 tests) on the RTX 3080 has 5 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. Traced to other PRs of the batch, each by reverting it and testing again: #21117 (guest_pad); none is in this PR's area. The 2125 agc_/video tests on the iGPU have 1 failing: agc_driver_stencil_plane_memory (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 implementation probes the guest pointer and restores errno on both probe outcomes before changing dialog state.

What I ran

Reviewed head bf7f8a3acad9e4c7b80d9e43816e31937cc954de using repo_read.py-provided review bundle and pinned source reads. No commands or tests were run.

Results

Check Result Note
Patch and source review passed Both changed files read
Unit tests not run No test execution available
Convention check not run Author-reported only

Findings

Blocking

None.

Non-blocking

None.

Not verified

Test execution and the author-reported convention check were not verified. Read: core/libs/prx/libSceNpSnsFacebookDialog/Export.cpp, core/libs/tests/GuestNpSnsFacebookDialog.cpp, and core/libs/prx/libc/include/General.hpp. Both files listed in the manifest as reviewed were read; no excluded changed files were listed.

To get this to a good state

Nothing is required.

@Helldiverr

Copy link
Copy Markdown
Contributor

Windows run of head bf7f8a3. In this comment, "the source" means core/libs/prx/libSceNpSnsFacebookDialog/Export.cpp and "the test" means core/libs/tests/GuestNpSnsFacebookDialog.cpp, both at the PR head. "The debt file" means docs/dev/debt/libSceNpSnsFacebookDialog.md at main 403fbe6.

Host: Ryzen 9 9950X3D, Windows 11 Pro 26300, WinLibs GCC 15.2, Ninja, Release. Test: guest_np_sns_facebook_dialog. I merged the head alone into main 403fbe6 (merge 8aa570672a). It merges cleanly: 2 files, +13.

Existing runs

  • maskym ran Windows at bf7f8a3 (guest_np_sns_facebook_dialog, pass).
  • PrivacyOnion ran Linux with a negative control.
  • MarcZX10 read the code.
  • kiwe147 ran this head in a batch of 30 PRs.

This run adds a Windows negative control and mutations of the probe.

Results

Run Result
main, 1 run 1/1 pass
merge, 3 runs 1/1 each time
negative control: source at main, test kept aborts
raw read of param instead of GuestCopyIn_nid_no_patch segfault
probe size 0 aborts
both errno = savedErrno; lines dropped passes
check_conventions.py --base upstream/main passes
debt_fold.py --check passes

Findings

  1. Returning 0x80B8000D for an unreadable param (source lines 36-38) is not measured. Nothing records it. The debt file (line 6) already lists the same fallback for an unwritable result pointer as "a host-safety fallback with console behavior unmeasured". Sibling dialogs list the param case the same way, for example docs/dev/debt/libSceCdlgG2P.md line 5. A fragment under docs/dev/debt/changes/ for sceNpSnsFacebookDialogOpen would record this one.
  2. Minor: the errno save and the two restores (source lines 35, 37 and 40) do nothing. GuestCopyIn_nid_no_patch ends in CopyGuestBytes, which already holds a RestoreErrno (core/libs/prx/libc/src/General.cpp line 97 at main). That is why the mutation that drops both restores still passes the errno == 71 checks at test lines 67 and 101. The same pattern is in sceNpSnsYouTubeDialogOpen on main, so keeping it for consistency is a fair choice.

I did not run Linux or macOS.

AI-assisted: yes

@Kikoarl
Kikoarl force-pushed the fix/libSceNpSnsFacebookDialog-open-param-unreadable branch from bf7f8a3 to fae9d7d Compare November 24, 2026 18:23
@Kikoarl

Kikoarl commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@Helldiverr Rebased onto origin/main and pushed fae9d7db92 adding docs/dev/debt/changes/fix-libSceNpSnsFacebookDialog-open-param-unreadable.md (## change [libSceNpSnsFacebookDialog]) to document the unmeasured 0x80B8000D fallback for an unreadable open param pointer (Closes when: measured on hardware. Labels: console, tested.), and re-verified check_conventions.py and guest_np_sns_facebook_dialog (1/1 passed).

@Helldiverr

Copy link
Copy Markdown
Contributor

Re-checked at fae9d7db92. The new fragment records the 0x80B8000D fallback for an unreadable param, which addresses the earlier finding 1, with one minor point left: the errno save is still redundant. guest_np_sns_facebook_dialog passes 3 of 3 times on the merge, and the fragment folds cleanly.

What changed. The head is rebased onto main 17220db6a3 and adds docs/dev/debt/changes/fix-libSceNpSnsFacebookDialog-open-param-unreadable.md. Compared with bf7f8a3aca, the code and test hunks are the same. Only the context line next to them differs (COMMON_DIALOG_ERROR_INVALID_STATE, which comes from main).

Checked on the merge (head merged onto main aae1ec1424 as abb007ca34, built in an existing build directory):

Check Result
guest_np_sns_facebook_dialog, run 1 / 2 / 3 Passed 0.60 / 1.27 / 0.16
check_conventions.py --base aae1ec1424 All conventions checks passed
debt_fold.py --check passes
debt_fold.py --show libSceNpSnsFacebookDialog the ## change [libSceNpSnsFacebookDialog] operation replaces the second Silent stubs entry, which is now 749 characters; the sceNpSnsFacebookDialogOpen entry is unchanged
both errno = savedErrno; lines removed (src 35 and 38) passes

Times are in seconds.

What still stands.

  1. Earlier finding 1 is addressed. The folded entry now covers both host-safety fallbacks, the unwritable result pointer and the unreadable open param, and ends with Closes when: measured on hardware.
  2. Earlier finding 2 is unchanged and minor. The save at src 33 and the restores at src 35 and 38 do nothing, because GuestCopyIn_nid_no_patch reaches CopyGuestBytes, which holds a RestoreErrno (General.cpp 97). With both restores removed, the errno == 71 checks (tests 67 and 101) still pass. Keeping the save to match sceNpSnsYouTubeDialogOpen is still a fair choice.

"src" is core/libs/prx/libSceNpSnsFacebookDialog/Export.cpp and "tests" is core/libs/tests/GuestNpSnsFacebookDialog.cpp, both at fae9d7db92.

The head is 44 commits behind aae1ec1424. main has since moved 68 commits to 685b72623b. Those commits touch none of the files above, and the head merges cleanly onto them too.

CPU: Ryzen 9 9950X3D
OS: Windows 11 Pro 26300
Toolchain: WinLibs GCC 15.2, Release
Commits: head fae9d7db92, merged onto main aae1ec1424 as abb007ca34

AI-assisted: yes

@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 code safely rejects an unreadable non-null param, preserves errno, and includes focused regression checks; the remaining hardware behavior is documented as unmeasured.

What I ran

Reviewed head fae9d7db92fc825a433860258d1dc066e4be4767. Read the prepared description, commits, manifest, diff, and all three changed files through repo_read.py; no commands or tests were run.

Results

Check Result Note
Change and source review passed All changed files reviewed
Build and tests not run Author reports the dialog test passed
Conventions check not run Author reports it passed
Console behavior not run Documented as unmeasured

Findings

Blocking

None.

Non-blocking

None.

Not verified

No independent build, test, or conventions check was run. Console behavior was not measured. files.json was unavailable in the prepared review folder, so excluded files could not be independently confirmed; the manifest lists all three changed files as included, and each was read.

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.

7 participants