feat(libkernel): implement seteuid and setegid #1748

Merged
danielradosa merged 1 commit from upstream-pr/1748 into main 2026-10-09 21:23:34 +00:00
danielradosa commented 2026-10-08 18:24:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by danielradosa on 2026-10-08T18:24:22Z.


What

Part of #1578. Implements seteuid (HTxb6gmexa0) and setegid (4oKwKmeOKjM) in libkernel. In the #1578 audit, seteuid is an absent import of 11 of the relinking homebrew titles (ProsperoRadio, ProsperoLight, ProsperoTV, PS5MC, Prospero Win and others) and setegid of 4. No open PR implements them or any other set*id function.

The guest process is assumed to run as root, with real, effective and saved ids 0; #1650 reports the same identity through getuid/geteuid/getgid/getegid. In FreeBSD 11.0 sys_seteuid and sys_setegid (sys/kern/kern_prot.c), an id equal to the real or saved id passes without a privilege check, and the credential changes (and P_SUGID is set) only when the id differs from the current effective one. So:

  • seteuid(0) and setegid(0) return 0, change nothing and leave errno untouched.
  • Any other id would change the effective credential, which nothing models, so it throws. EPERM would be wrong, since root is allowed.

The known callers are the sandbox-elevation clients these homebrew share (the ps5-native-app-boilerplate example vendored in ProsperoLight, ProsperoTV and ProsperoStore; Porpoise; prospero-win; PSXS5). They call seteuid(geteuid()), and setegid(getgid()) only when getegid() != getgid(). With a root identity, both pass id 0. The assumed identity is recorded in TechnicalDebt.md.

There is no build dependency on #1650: the two change different lines and merge in either order. If #1650's identity changes, the accepted id here follows it. Whichever lands second can fold the two TechnicalDebt.md entries into one and move these exports next to the getters.

Title

Callers do seteuid(geteuid()) and imports resolve in name order, so on main these titles stop at geteuid first; with #1650 they stop here. Runs posted by others:

  • CouchRiv on #1650, Linux main f1451396 + #1650: PPSA99003 ProsperoTV 01.000.030 stops at undefined symbol: HTxb6gmexa0 (seteuid), PPSA99002 ProsperoLight 01.000.090 at 4oKwKmeOKjM (setegid).
  • LeandroLP23 on #1578, Windows main f1451396 with each stop's PR merged in turn: PPSA99808 PICO-8 v0.1.2 resolves seteuid with this PR and stops next at sigaction.
  • Own Windows runs, main 0fdda7be + #1650: PPSA99003 ProsperoTV stops at HTxb6gmexa0 and PPSA99002 ProsperoLight at 4oKwKmeOKjM; with this PR they stop next at JGfTMBOdUJo (sceKernelGetFsSandboxRandomWord) and +F7C-hdk7+E (sigemptyset). Details in the comments.

Tested

Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, Ninja, full build with BUILD_TESTING=ON, on main 0fdda7be (rebased today).

  • New guest_credentials test: seteuid(0) and setegid(0) return 0 and leave errno untouched; ids 1000 and 0xFFFFFFFF throw. On main the test does not link, because the exports are missing.
  • Negative check: accepting every id makes the test abort.
  • The patched libkernel.prx exports both NIDs.
  • ctest -R "^guest_": 161 pass, 0 fail, 1 skipped by design (guest_video_out_wqhd_detection_no_vulkan).
  • tools/check_test_registration.py and tools/check_conventions.py --base origin/main pass.
  • The test registration sits before guest_address_tests, clear of #1859, which registers its test where this one first did. The branch merges cleanly with #1650 and #1859.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4791097241 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1748). Originally posted by [danielradosa](https://github.com/danielradosa) on 2026-10-08T18:24:22Z. --- ### What Part of #1578. Implements `seteuid` (`HTxb6gmexa0`) and `setegid` (`4oKwKmeOKjM`) in libkernel. In the #1578 audit, `seteuid` is an absent import of 11 of the relinking homebrew titles (ProsperoRadio, ProsperoLight, ProsperoTV, PS5MC, Prospero Win and others) and `setegid` of 4. No open PR implements them or any other `set*id` function. The guest process is assumed to run as root, with real, effective and saved ids 0; #1650 reports the same identity through `getuid`/`geteuid`/`getgid`/`getegid`. In FreeBSD 11.0 `sys_seteuid` and `sys_setegid` (`sys/kern/kern_prot.c`), an id equal to the real or saved id passes without a privilege check, and the credential changes (and `P_SUGID` is set) only when the id differs from the current effective one. So: - `seteuid(0)` and `setegid(0)` return 0, change nothing and leave errno untouched. - Any other id would change the effective credential, which nothing models, so it throws. EPERM would be wrong, since root is allowed. The known callers are the sandbox-elevation clients these homebrew share (the ps5-native-app-boilerplate example vendored in ProsperoLight, ProsperoTV and ProsperoStore; Porpoise; prospero-win; PSXS5). They call `seteuid(geteuid())`, and `setegid(getgid())` only when `getegid() != getgid()`. With a root identity, both pass id 0. The assumed identity is recorded in `TechnicalDebt.md`. There is no build dependency on #1650: the two change different lines and merge in either order. If #1650's identity changes, the accepted id here follows it. Whichever lands second can fold the two `TechnicalDebt.md` entries into one and move these exports next to the getters. ### Title Callers do `seteuid(geteuid())` and imports resolve in name order, so on `main` these titles stop at `geteuid` first; with #1650 they stop here. Runs posted by others: - CouchRiv on #1650, Linux `main` f1451396 + #1650: PPSA99003 ProsperoTV 01.000.030 stops at `undefined symbol: HTxb6gmexa0` (`seteuid`), PPSA99002 ProsperoLight 01.000.090 at `4oKwKmeOKjM` (`setegid`). - LeandroLP23 on #1578, Windows `main` f1451396 with each stop's PR merged in turn: PPSA99808 PICO-8 v0.1.2 resolves `seteuid` with this PR and stops next at `sigaction`. - Own Windows runs, `main` 0fdda7be + #1650: PPSA99003 ProsperoTV stops at `HTxb6gmexa0` and PPSA99002 ProsperoLight at `4oKwKmeOKjM`; with this PR they stop next at `JGfTMBOdUJo` (`sceKernelGetFsSandboxRandomWord`) and `+F7C-hdk7+E` (`sigemptyset`). Details in the comments. ### Tested Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, Ninja, full build with `BUILD_TESTING=ON`, on `main` 0fdda7be (rebased today). - New `guest_credentials` test: `seteuid(0)` and `setegid(0)` return 0 and leave errno untouched; ids 1000 and 0xFFFFFFFF throw. On `main` the test does not link, because the exports are missing. - Negative check: accepting every id makes the test abort. - The patched `libkernel.prx` exports both NIDs. - `ctest -R "^guest_"`: 161 pass, 0 fail, 1 skipped by design (`guest_video_out_wqhd_detection_no_vulkan`). - `tools/check_test_registration.py` and `tools/check_conventions.py --base origin/main` pass. - The test registration sits before `guest_address_tests`, clear of #1859, which registers its test where this one first did. The branch merges cleanly with #1650 and #1859. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-08 22:20:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-08T22:20:16Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#1859 core/libs/prx/libkernel/CMakeLists.txt L380
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6070189408 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1748#issuecomment-6070189408). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-08T22:20:16Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #1859 | `core/libs/prx/libkernel/CMakeLists.txt` [L380](https://github.com/boykopovar/AnyPS5/blob/745b775e2d883c68560b2d87f4ab96a01e221ccf/core/libs/prx/libkernel/CMakeLists.txt#L380) | | |
danielradosa commented 2026-10-09 17:25:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by danielradosa on 2026-10-09T17:25:55Z.


Rebased onto main 0fdda7be and moved the guest_credentials registration before guest_address_tests, so it no longer collides with #1859. The description now lists the title runs posted on #1650 and #1578. Could a collaborator dispatch Actions > Build for this PR? Its pull_request runs are action_required.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6085870741 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1748#issuecomment-6085870741). Originally posted by [danielradosa](https://github.com/danielradosa) on 2026-10-09T17:25:55Z. --- Rebased onto `main` 0fdda7be and moved the `guest_credentials` registration before `guest_address_tests`, so it no longer collides with #1859. The description now lists the title runs posted on #1650 and #1578. Could a collaborator dispatch Actions > Build for this PR? Its `pull_request` runs are `action_required`.
danielradosa commented 2026-10-09 18:28:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by danielradosa on 2026-10-09T18:28:54Z.


Windows runs of the two catalog titles, each relinked with relinker --windows from the release ZIP (sha256 as in the catalog record, eboot.bin and sce_module/libc.prx unwrapped from their SELF containers). Windows 11 Pro 10.0.26300, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release.

Title main 0fdda7be + #1650 main 0fdda7be + #1650 + this PR
PPSA99003 ProsperoTV 01.000.030 FAIL: unresolved ELF import HTxb6gmexa0 from libkernel.prx (seteuid) FAIL: unresolved ELF import JGfTMBOdUJo from libkernel.prx (sceKernelGetFsSandboxRandomWord)
PPSA99002 ProsperoLight 01.000.090 FAIL: unresolved ELF import 4oKwKmeOKjM from libkernel.prx (setegid) FAIL: unresolved ELF import +F7C-hdk7+E from libkernel.prx (sigemptyset)

Both titles get past seteuid/setegid with this PR and stop at the next absent import.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6086876872 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1748#issuecomment-6086876872). Originally posted by [danielradosa](https://github.com/danielradosa) on 2026-10-09T18:28:54Z. --- Windows runs of the two catalog titles, each relinked with `relinker --windows` from the release ZIP (sha256 as in the catalog record, `eboot.bin` and `sce_module/libc.prx` unwrapped from their SELF containers). Windows 11 Pro 10.0.26300, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. | Title | `main` 0fdda7be + #1650 | `main` 0fdda7be + #1650 + this PR | |---|---|---| | PPSA99003 ProsperoTV 01.000.030 | `FAIL: unresolved ELF import HTxb6gmexa0 from libkernel.prx` (`seteuid`) | `FAIL: unresolved ELF import JGfTMBOdUJo from libkernel.prx` (`sceKernelGetFsSandboxRandomWord`) | | PPSA99002 ProsperoLight 01.000.090 | `FAIL: unresolved ELF import 4oKwKmeOKjM from libkernel.prx` (`setegid`) | `FAIL: unresolved ELF import +F7C-hdk7+E from libkernel.prx` (`sigemptyset`) | Both titles get past `seteuid`/`setegid` with this PR and stop at the next absent import. AI-assisted: yes (Claude Code).
adriadam10 commented 2026-10-09 21:23:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T21:23:31Z.


Checked on top of current main: build + full ctest, guest_credentials passes and does not link without the change; libkernel.prx exports HTxb6gmexa0 and 4oKwKmeOKjM. Behaviour matches FreeBSD 11.0 sys_seteuid/sys_setegid (id equal to the real/saved id needs no privilege check) for the assumed root identity, and the assumption is in TechnicalDebt. Title runs by @LeandroLP23 and @CouchRiv on #1578/#1650 confirm the imports now resolve. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6089492542 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1748#issuecomment-6089492542). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-09T21:23:31Z. --- Checked on top of current main: build + full ctest, `guest_credentials` passes and does not link without the change; `libkernel.prx` exports `HTxb6gmexa0` and `4oKwKmeOKjM`. Behaviour matches FreeBSD 11.0 `sys_seteuid`/`sys_setegid` (id equal to the real/saved id needs no privilege check) for the assumed root identity, and the assumption is in TechnicalDebt. Title runs by @LeandroLP23 and @CouchRiv on #1578/#1650 confirm the imports now resolve. Merging.
github-actions[bot] commented 2026-10-09 21:31:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T21:31:59Z.


Progress report (f8c2f07 → 1414b27)

📈 System libraries: 84.7% (+0.01%, +2 implemented functions)

✅ 2 implemented
Library Name
libkernel setegid_nid_postfix
libkernel seteuid_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6089602812 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1748#issuecomment-6089602812). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T21:31:59Z. --- <!-- progress-report --> ### Progress report (f8c2f07 → 1414b27) 📈 **System libraries**: 84.7% (+0.01%, +2 implemented functions) <details> <summary>✅ 2 implemented</summary> | Library | Name | | - | - | | libkernel | `setegid_nid_postfix` | | libkernel | `seteuid_nid_postfix` | </details>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!1748
No description provided.