Skip to content

fix(libkernel): return ENOENT for thirteen sysctl names, as measured on a PS5 - #7541

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
ionut27001:fix/libkernel-sysctl-absent-names
Oct 20, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
ionut27001:fix/libkernel-sysctl-absent-names

Conversation

@ionut27001

@ionut27001 ionut27001 commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

What

sysctlbyname now answers thirteen names the way the console answers a payload process on a PS5 (firmware 12.70), where it threw unsupported name. sysctl does the same for seven of their MIBs, and sysctlnametomib for nine of the names; the other four names still throw in sysctlnametomib.

Call Payload process, firmware 12.70 main before this PR
sysctlbyname for hw.byteorder, hw.cacheline_size, hw.machine_arch, hw.usermem, kern.clockrate, kern.maxfiles, kern.maxfilesperproc, kern.maxproc, kern.ps_strings, kern.sched.name, kern.smp.maxcpus, kern.stackprot, kern.timecounter.hardware -1 with ENOENT, buffer and length untouched. Same for a read, a size query, a null length, and a null buffer with a null length throws
sysctl for {1, 6}, {1, 7}, {1, 12}, {1, 27}, {1, 32}, {6, 4}, {6, 11} the same throws
sysctlnametomib for the seven names with those MIBs returns the MIB (all seven); errno is kept (measured for kern.maxproc, kern.ps_strings, hw.byteorder); a short count copies part of the MIB and returns ENOMEM (measured for kern.maxproc, hw.byteorder) throws
sysctlnametomib for hw.cacheline_size, hw.usermem -1 with ENOENT, count and the first three MIB words untouched throws
machdep.cacheline_size -1 with ENOENT same (unchanged, now tested with the others)

Writes: a write to the new names and MIBs throws. The probes never write a sysctl, so the console's answer to a write is not known. machdep.cacheline_size keeps returning ENOENT for a write, as on main.

Changes in docs/dev/debt/libkernel.md:

  • The machdep.cacheline_size entry now covers all fourteen names. It lists what is still not modelled: four of the names, whose MIBs the console numbers just below 2^31 (2147482814 to 2147483182), and all other names, which still throw.
  • The hw.realmem and vm.overcommit entries said the console's values were not known. They now say that a payload process on a PS5 (firmware 12.70) gets ENOENT for hw.physmem, hw.realmem and vm.overcommit, and for {6, 5} and {6, 12}.
  • Their code is unchanged: titles read them (RetroArch PPSA99169 through its dolphin_libretro core, PS5MC PPSA99420 through mimalloc), so changing them is left for a separate PR.

How the console was measured

  • Setup:
    • The console runs firmware 12.70 and is jailbroken.
    • The probes are ELF payloads built with ps5-payload-dev/sdk v0.44 and clang 18.1.8.
    • They were started through a payload manager, so they ran in a payload process, not in a title. A title process was not measured.
  • Provenance: p16's resolve lines show that its sysctlbyname, sysctl and sysctlnametomib are the ones libkernel_sys.sprx exports; p10 and p13 resolve some of them the same way, and p24 prints no resolve lines. All probes link these functions the same way.
  • Method:
    • Buffers were prefilled with 0xAA (p16, p24). Lengths were preset to 64 for a read and 77 for a size query (p16); p24 passes null lengths. MIB arrays were prefilled with 0xAA bytes (p13, p16, p24).
    • last_changed is one past the last byte that changed.
    • No sysctl was written.
  • Files: sources and the full logs are in the attached sysctl-probes.zip.
Console output (excerpt, lines copied unchanged)
p10: meta fw=0x12700001 pid=121 sdk=v0.44 compiler=Clang 18.1.8 built=Oct 18 2026 01:17:42
p13: meta fw=0x12700001 pid=125 sdk=v0.44 compiler=Clang 18.1.8 built=Oct 18 2026 01:52:02
p16: meta fw=0x12700001 pid=128 sdk=v0.44 compiler=Clang 18.1.8 built=Oct 18 2026 02:01:38
p24: meta fw=0x12700001 pid=136 sdk=v0.44 compiler=Clang 18.1.8 built=Oct 18 2026 02:48:52

p16: resolve sym=sysctlbyname module=libkernel_sys.sprx same_as_called=yes
p16: resolve sym=sysctl module=libkernel_sys.sprx same_as_called=yes
p16: resolve sym=sysctlnametomib module=libkernel_sys.sprx same_as_called=yes

p16: case absent_read name=kern.maxproc ret=-1 errno=2 len=64 last_changed=0
p16: case absent_size name=kern.maxproc ret=-1 errno=2 len=77
p16: case absent_null_oldlenp name=kern.maxproc ret=-1 errno=2 last_changed=0
p16: case absent_mib name=kern.maxproc mib=1.6 read_ret=-1 read_errno=2 len=64 last_changed=0 size_ret=-1 size_errno=2 size=77
p24: case unanswered_mib_null_oldlenp mib=1.6 ret=-1 errno=2 last_changed=0
p24: case unanswered_mib_null_both mib=1.6 ret=-1 errno=2
p24: case unanswered_name_null_both name=kern.maxproc ret=-1 errno=2
p16: case absent_mib name=hw.byteorder mib=6.4 read_ret=-1 read_errno=2 len=64 last_changed=0 size_ret=-1 size_errno=2 size=77
p16: case absent_mib name=hw.machine_arch mib=6.11 read_ret=-1 read_errno=2 len=64 last_changed=0 size_ret=-1 size_errno=2 size=77
p16: case absent_mib name=kern.ps_strings mib=1.32 read_ret=-1 read_errno=2 len=64 last_changed=0 size_ret=-1 size_errno=2 size=77
p16: case absent_mib name=kern.smp.maxcpus mib=1.2147482816.2147482814 read_ret=-1 read_errno=2 len=64 last_changed=0 size_ret=-1 size_errno=2 size=77
p16: case absent_mib name=hw.usermem nametomib_ret=-1 nametomib_errno=2
p16: case absent_read name=hw.physmem ret=-1 errno=2 len=64 last_changed=0
p16: case absent_mib name=hw.realmem mib=6.12 read_ret=-1 read_errno=2 len=64 last_changed=0 size_ret=-1 size_errno=2 size=77
p16: case absent_read name=vm.overcommit ret=-1 errno=2 len=64 last_changed=0
p16: case absent_mib name=kern.anyps5_no_such_name nametomib_ret=-1 nametomib_errno=2

p24: case nametomib2 name=hw.cacheline_size ret=-1 errno=2 count=8 m0=-1431655766 m1=-1431655766 m2=-1431655766
p24: case nametomib2 name=hw.usermem ret=-1 errno=2 count=8 m0=-1431655766 m1=-1431655766 m2=-1431655766
p24: case nametomib2 name=kern.maxproc ret=0 errno=77 count=2 m0=1 m1=6 m2=-1431655766
p24: case nametomib_null_mib name=kern.maxproc ret=0 errno=77 count=2
p24: case nametomib_short name=kern.maxproc given=1 ret=-1 errno=12 count=1 m0=1 m1=-1431655766
p13: case nametomib name=kern.maxfiles ret=0 errno=0 count=2 mib=1.7.-1431655766
p13: case nametomib name=kern.maxfilesperproc ret=0 errno=0 count=2 mib=1.27.-1431655766
p13: case nametomib name=hw.machine_arch ret=0 errno=0 count=2 mib=6.11.-1431655766
p13: case nametomib name=kern.clockrate ret=0 errno=0 count=2 mib=1.12.-1431655766
p13: case nametomib name=hw.byteorder ret=0 errno=0 count=2 mib=6.4.-1431655766

The pNN: prefix names the probe; the rest of each line is copied unchanged.

The other names and MIBs give the same lines. All of them are in the logs.

Overlaps:

Tested

Build: Windows 11 x86-64, full build with WinLibs MinGW-w64 GCC 15.2.0 (posix-seh, ucrt, r7) and -DBUILD_TESTING=ON.

Rebase (not re-tested): after #6833 landed, this branch was rebased onto main bbb4546. The only conflict was in docs/dev/debt/libkernel.md, where #6833 changed the sysconf line next to this PR's hw.realmem and vm.overcommit lines; the resolution keeps #6833's sysconf line and this PR's two lines. The code and test changes are the same as before the rebase, and the tests above were not run again on the new base.

Tests: with this branch on top of main 9f25d0b, guest_system_configuration and the other guest_* tests pass: 464 of 465 pass and guest_video_out_wqhd_detection_no_vulkan is skipped on this machine. In the parallel run (ctest -j 6), guest_video_out_wqhd_detection, guest_pthread_rwlock and guest_pthread_second_join timed out once and passed when rerun. The branch was then rebased onto main 5bf2e13 without conflicts, since upstream changed none of its code or test files, and guest_system_configuration passes there too.

Old code, new test: with SystemConfiguration.cpp reverted to main and the new test kept, guest_system_configuration aborts.

Rebase onto main 6e27fc8: after #6220 landed, the branch was rebased onto main 6e27fc8, resolving the SystemConfiguration.cpp conflict with #6220 described under Overlaps; the other files merged without conflicts. With this branch and #7543's branch built in one tree on that main, the guest_* tests pass: 473 of 474, and guest_video_out_wqhd_detection_no_vulkan is skipped on this machine. That is the second of two full runs; the first, right after the build, timed out in four tests this PR does not touch (guest_message_destructor_unshared-decoy, guest_video_out_cursor, guest_app_info, guest_pthread_rwlock). guest_system_configuration also passed 3 runs in a row. With SystemConfiguration.cpp reverted to that main and the new test kept, guest_system_configuration aborts with sysctlbyname_nid_postfix: unsupported name hw.byteorder. The branch merges cleanly with main 3259e4c.

Console: behaviour measured on a PS5 (firmware 12.70), as described above.

Not tested here: Linux (a reviewer reported a Linux run in the comments), and no 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

  • 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
    Rebase: rebased onto main 1e774a3. feat(libkernel): report the guest address-space map through kern.proc.vmmap #7070 has landed since the last rebase (kern.proc.vmmap), so the rebase conflicted in SystemConfiguration.cpp, where its GuestVmEntries block and this PR's IsUnansweredMib and IsUnansweredName blocks sit at the same place; the resolution keeps both, feat(libkernel): report the guest address-space map through kern.proc.vmmap #7070's first. It also conflicted in docs/dev/debt/libkernel.md, where feat(libkernel): report the guest address-space map through kern.proc.vmmap #7070's kern.proc.vmmap entry and this PR's sysctl names a PS5 payload process gets ENOENT for entry sit together; both are kept, and machdep.cacheline_size stays folded into this PR's entry as before the rebase. The code and test changes are otherwise the same as before the rebase. Re-tested on the new base: full build with WinLibs GCC 15.2.0 (Windows 11), exit 0; guest_system_configuration passed twice (1.29 s, 0.06 s); with SystemConfiguration.cpp restored from main the test aborts with sysctlbyname_nid_postfix: unsupported name hw.byteorder.

  • Depends on: none

  • Fixes: none

  • Unblocks: none

  • GPUs tested: n/a

  • AI-assisted: yes

🤖 Generated with Claude Code

@MarcZX10

Copy link
Copy Markdown
Contributor

I'm preparing a separate PR for measured kern.rng_pseudo MIB {1,50} support and its sysctlnametomib mapping. The overlap checker flags nearby insertion points in SystemConfiguration.cpp and GuestSystemConfiguration.cpp; the behavior is separate, but rebasing may need small conflict resolutions. Which PR should land first, or are you comfortable with this one landing first?

@github-actions

github-actions Bot commented Oct 18, 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 4630 docs/dev/debt/libkernel.md
PR 5021 docs/dev/debt/libkernel.md
PR 6044 core/libs/tests/GuestSystemConfiguration.cpp
PR 6149 docs/dev/debt/libkernel.md
PR 6469 docs/dev/debt/libkernel.md
PR 6519 docs/dev/debt/libkernel.md
PR 6658 docs/dev/debt/libkernel.md
PR 6740 docs/dev/debt/libkernel.md
PR 6893 docs/dev/debt/libkernel.md
PR 6936 docs/dev/debt/libkernel.md
PR 6977 docs/dev/debt/libkernel.md
PR 7049 docs/dev/debt/libkernel.md
PR 7088 docs/dev/debt/libkernel.md
PR 7105 docs/dev/debt/libkernel.md
PR 7121 docs/dev/debt/libkernel.md
PR 7149 docs/dev/debt/libkernel.md
PR 7464 docs/dev/debt/libkernel.md
PR 7509 docs/dev/debt/libkernel.md
PR 7530 docs/dev/debt/libkernel.md
PR 7937 docs/dev/debt/libkernel.md
PR 8437 docs/dev/debt/libkernel.md

@MarcZX10

Copy link
Copy Markdown
Contributor

I opened #7556 for the four additional numeric MIBs in your probe logs: it returns ENOENT on the measured sysctl read and size-query paths, while leaving writes unmodeled. It is separate from your name-to-MIB work; pr_overlap.py reports no overlapping hunks. The PR body links back to your measurement as its evidence.

@MarcZX10

Copy link
Copy Markdown
Contributor

Update: the separate kern.rng_pseudo PR is now open as #7554. It is behaviorally independent of the name-to-MIB cases in this PR; only adjacent insertion points may need conflict resolution during rebase. Either PR can land first, and I will keep the changes separate.

@ionut27001

Copy link
Copy Markdown
Contributor Author

Thanks for picking these up. Either order is fine with me; whichever lands second resolves the conflict in SystemConfiguration.cpp (both blocks stay). One text dependency: the sysctl names a PS5 payload process gets ENOENT for debt entry here ends with "here sysctlnametomib and sysctl throw for them" for those four MIBs. After #7556 only sysctlnametomib throws, so that clause should become "here sysctlnametomib throws for them". If this PR lands first, could you adjust it in #7556? If #7556 lands first, I'll update it here. I checked the four MIBs in #7556 against the p16 log and they match.

@LeandroLP23

Copy link
Copy Markdown
Contributor

Windows run. Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), Windows 11 26300, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. Build: main c3591adf9 with #7623, #7612, #7611, #7603, #7579, #7563 and #7541 merged together (each merge clean, built once).

guest_system_configuration, guest_pthread_rwlock, guest_pthread_second_join and guest_video_out_wqhd_detection pass 3 runs of 3. guest_video_out_wqhd_detection_no_vulkan skips itself on this host. No title was run.

AI-assisted

@LeandroLP23 LeandroLP23 mentioned this pull request Oct 18, 2026
10 tasks done
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 18, 2026
@ionut27001
ionut27001 force-pushed the fix/libkernel-sysctl-absent-names branch from 827b578 to 3fac97b Compare October 18, 2026 21:23
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 18, 2026

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

Linux run, since the description and the existing run are Windows only.

Machine: Linux x86_64, i7-8700, Ubuntu 26.04, GCC 15.2, Release, BUILD_TESTING=ON, full build.
Head 3fac97bf6 merged onto main 84c1a4d9a (clean merge).

  • guest_system_configuration passes.
  • GuestSystemConfiguration.cpp only, on main: aborts with sysctlbyname_nid_postfix: unsupported name hw.byteorder, so the test covers the new names.
  • Non-GPU suite (ctest -E "^agc|gpu|vulkan|video_out"): 739/739, same as main.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 19, 2026
@ionut27001
ionut27001 force-pushed the fix/libkernel-sysctl-absent-names branch from 3fac97b to ff8e19c Compare October 19, 2026 12:00
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 19, 2026
@adriadam10 adriadam10 self-assigned this Oct 19, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 19, 2026
@ionut27001
ionut27001 force-pushed the fix/libkernel-sysctl-absent-names branch from ff8e19c to 5e65f31 Compare October 19, 2026 20:42
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Oct 19, 2026
…on a PS5

In a payload process on a PS5 (firmware 12.70), sysctlbyname returns -1
with ENOENT for thirteen names that threw here, and leaves the buffer and
the length alone, for a read, a size query, a null length and a null
buffer with a null length. sysctl does the same for the fixed MIBs of
seven of them. sysctlnametomib gives those seven MIBs and returns ENOENT
for hw.cacheline_size and hw.usermem, which threw too.

machdep.cacheline_size already returned ENOENT and is now tested with
the others. A write to the new names and MIBs throws, as the console's
answer to a write was not tried. The hw.realmem and vm.overcommit debt
entries now say that a payload process gets ENOENT for them as well.

AI-assisted: yes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@adriadam10
adriadam10 force-pushed the fix/libkernel-sysctl-absent-names branch from 5e65f31 to dfa96f1 Compare October 20, 2026 11:57
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 20, 2026
@adriadam10
adriadam10 merged commit 10e2cbf into boykopovar:main Oct 20, 2026
10 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Rebased onto current main (conflicts in SystemConfiguration.cpp with #7556 and #7554: kept both blocks, kern.rng_pseudo stays in the sysctlnametomib table). Updated the debt entry as you proposed, since #7556 now answers sysctl for the four MIBs: "here sysctlnametomib throws for them". Rest of the review unchanged (probe logs, check order, new test aborts on main); merged.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants