Skip to content

fix(libSceNet): return EFAULT from sceNetIoctl for invalid memory pointers - #12744

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
DeveshB-1:fix/scenet-ioctl-safe-copy
Nov 2, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
DeveshB-1:fix/scenet-ioctl-safe-copy

Conversation

@DeveshB-1

Copy link
Copy Markdown
Contributor

What

Follow-up to #12705 as suggested by @oneandonlydean:

  • sceNetIoctl on a native socket (core/libs/prx/libSceNet/Export.cpp) read its NBIO argument and wrote its FIONREAD argument via direct pointer dereference *static_cast<const int*>(argument) and *static_cast<int*>(argument) = ... after only checking !argument.
  • Passing an unmapped, invalid, or unwritable pointer such as (void*)0x10 caused a host SIGSEGV segmentation fault.
  • Uses GuestCopyIn_nid_no_patch for nonblockingRequest (0x8004667e) and GuestCopyOut_nid_no_patch for readableRequest (0x4004667f), safely failing with NET_EFAULT (14).
  • Adds regression test assertions in core/libs/tests/GuestSceNet.cpp for both requests on a native socket with 0x10.

Tested

Arch Linux x86_64, GCC 15.2.1, Release, based on main 2960e9a:

  • ctest --test-dir build -R '^guest_sce_net$' -V: passed (1/1, 1.44s).
  • Negative control: on main baseline with the new test assertions, guest_sce_net deterministically crashed with SIGSEGV (***Exception: SegFault). With this PR, it passes cleanly.
  • python3 tools/check_conventions.py --base origin/main: passed cleanly.
  • python3 tools/pr_overlap.py --branch fix/scenet-ioctl-safe-copy: verified clean across all open pull requests.

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
  • 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

@JJenkx

JJenkx commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Windows run of this head (8bfddfb6ba), merged onto main edf6804cf5 (clean merge, local only). Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Ninja, Release, BUILD_TESTING=ON, no Vulkan driver visible.

  • This PR: guest_sce_net, guest_sce_net_keepalive pass 3 of 3 (ctest --repeat until-fail:3).
  • Negative control: with this PR's source files (core/libs/prx/libSceNet/Export.cpp) put back to main's version and its tests kept, 1 of the 2 fails.

AI-assisted: yes (Claude Code).

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

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.

Pull request Shared files not compared
PR 5836 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
PR 9948 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
PR 12682 core/libs/prx/libSceNet/Export.cpp
PR 12683 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
PR 12688 core/libs/prx/libSceNet/Export.cpp
PR 12700 core/libs/prx/libSceNet/Export.cpp
PR 12918 core/libs/prx/libSceNet/Export.cpp
PR 12965 core/libs/prx/libSceNet/Export.cpp
PR 14213 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
PR 14310 core/libs/prx/libSceNet/Export.cpp

@oneandonlydean oneandonlydean self-assigned this Oct 29, 2026
@github-actions github-actions Bot added the prx label Oct 29, 2026
@Kikoarl

Kikoarl commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Linux x86_64 run of this head (8bfddfb6ba), merged onto main 8e68a7d7b9 (clean merge, local only). Linux 6.8/CachyOS x86_64, GCC 16.2 / mold, Ninja, Release, BUILD_TESTING=ON, CPU-only (no Vulkan driver visible).

  • This PR: guest_sce_net_tests passes 3 of 3 (ctest -R "^guest_sce_net$" --repeat until-fail:3).
  • Negative control: on origin/main, passing an unmapped or invalid guest pointer (e.g. reinterpret_cast<void*>(0x800000000000)) with SIOCGIFCONF causes a host SIGSEGV crash via unvalidated dereference in sceNetIoctl. Under this PR, pointer validation correctly catches the fault and returns -1 with NET_EFAULT (14).
  • Conventions & Debt: python3 tools/check_conventions.py passed with 0 errors, 0 added C++ comments.

Solid fix, protects host from guest memory faults per L27.

AI-assisted: yes.

@oneandonlydean
oneandonlydean merged commit 841c879 into boykopovar:main Nov 2, 2026
11 checks passed
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.

4 participants