Skip to content

fix(libSceNet): fail sceNetSocket of an unknown type with protocol 0 with EPROTOTYPE, as libkernel's socket does - #2278

Open
Thimo188 wants to merge 1 commit into
mainfrom
upstream-pr/28543
Open

Thimo188 wants to merge 1 commit into
mainfrom
upstream-pr/28543

Conversation

@Thimo188

@Thimo188 Thimo188 commented Dec 3, 2026 •

Copy link
Copy Markdown
Owner

Imported from boykopovar/AnyPS5#28543, originally opened by Dr-Coconut.

Source commit: a305db1f7f0763603cd1919fa584777f005edca3. The import branch preserves this fetched upstream PR snapshot. The description and validation below are copied from upstream; no new code changes or test runs were made for this import. Original reviews, discussions, and attachments remain at the linked upstream PR.


What

sceNetSocket in AF_INET or AF_INET6 failed every unknown type with EPROTONOSUPPORT. FreeBSD 11.4's socreate answers EPROTOTYPE when no protocol of the domain has the type, the protocol is 0 and the type is not 0, and EPROTONOSUPPORT otherwise. libkernel's socket does the same (boykopovar#7151), which is what a payload process on a PS5 (firmware 13.60) got from socket for SOCK_RDM, SOCK_SEQPACKET and an unknown type. boykopovar#12470 added the sceNetSocket type tests with protocol 6 and left the protocol-0 case open for this reason.

The type check now returns EPROTOTYPE for a type other than stream, datagram, raw and the two P2P types when the protocol is 0 and the type is not 0. CheckSocketArgumentErrors asserts it for types 4, 5, 7, 99 and -1 with protocol 0 in both families, and EPROTONOSUPPORT for type 0 with protocol 0.

Tested

Commit a305db1 on main 4a7fd1c, Release, in a workflow on my fork: https://github.com/Dr-Coconut/AnyPS5/actions/runs/46693612002

  • Windows (GitHub-hosted windows-latest, image windows-2025-vs2026, WinLibs GCC 15.2.0 15.2.0posix-14.0.0-ucrt-r7) and Linux (GitHub-hosted ubuntu-latest, image ubuntu-26.04, GCC 15.2.0), with the change: guest_sce_net passes, and so do the eight guest_net_address_fault_* tests.
  • Both, with libSceNet's Export.cpp restored to main and the new cases kept: guest_sce_net fails at line 193, type 4 with protocol 0, with EPROTONOSUPPORT (43); the controls pass.

Not run on macOS. No title tested. tools/check_conventions.py passes. tools/pr_overlap.py --branch reported no overlap among the open pull requests it could merge; it could not compare eight that conflict with main. boykopovar#25451 and boykopovar#28442 also change sceNetSocket, at other lines (the raw protocol and the buffer sizes), and merge cleanly with this; boykopovar#5836 reworks the same type check for peer sockets but already conflicts with 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: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Socket creation now reports the appropriate error for unsupported socket types when the protocol is zero, while other unsupported combinations retain their existing error response.
    • Error handling is covered for additional socket type values across both supported address families.

…with EPROTOTYPE, as libkernel's socket does

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Dec 3, 2026

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Socket Error Handling

Layer / File(s) Summary
Socket error conditions
core/libs/prx/libSceNet/Export.cpp, core/libs/tests/GuestSceNet.cpp, docs/dev/debt/changes/fix-libscenet-socket-eprototype.md
sceNetSocket returns NET_EPROTOTYPE when the protocol is zero and the unsupported type is nonzero. Other unsupported combinations retain NET_EPROTONOSUPPORT. Tests check the reported errors for families 2 and 28. The debt note records the behavior, comparisons, and measurement caveat.

Change: Bug fix

Merge Risk: Minimal · up to a305d

This change makes sceNetSocket return a different error code for one narrow unsupported-socket-type case, and adds tests and a documentation note. No concrete merge-blocking risk was identified.

Security architecture risk: Minimal · up to a305d

For IPv4 and IPv6, libSceNet now reports EPROTOTYPE when a guest requests an unsupported nonzero socket type with protocol zero. The same requests are still rejected before a host socket is opened. Guest code that checks for the old error may take a different fallback path, but the change does not grant additional network access.

Security review details

Trust Boundaries and Controls

  • observed — Guest-controlled family, type, and protocol reach the same validation checks in both revisions. The changed branch still exits before host network initialization, the native socket call, descriptor reservation, or insertion into the socket table.

Rollout and rollback

  • inferred — Reverting the code restores EPROTONOSUPPORT for the affected requests. Neither version creates a socket or reserves a descriptor for those requests, so the change needs no socket-state migration or cleanup and does not change who can permit socket creation.
Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Usage-based review receipt

  • Mode: Continue automatically
  • Reviewed files: 3
  • Waived: $0.75 (charged $0.00)
  • View usage details

Note

This review exceeded your plan’s limits and used usage-based reviews—free during trial, billed after paid activation unless disabled. Manage usage-based reviews.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b960b327-6fb0-4e7d-8ef6-035246f11658
Commits

Reviewing files that changed from the base of the PR and between 4131f51 and a305db1.

Files selected for processing: 3

  • core/libs/prx/libSceNet/Export.cpp
  • core/libs/tests/GuestSceNet.cpp
  • docs/dev/debt/changes/fix-libscenet-socket-eprototype.md

@github-actions github-actions Bot added prx Other PRX libraries docs Documentation labels Dec 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation prx Other PRX libraries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants