feat(libkernel_sys): implement is_in_sandbox #10421

Merged
amazedturnip merged 1 commit from upstream-pr/10421 into main 2026-11-02 16:12:43 +00:00
amazedturnip commented 2026-10-23 23:49:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by amazedturnip on 2026-10-23T23:49:20Z.


What

Implement is_in_sandbox_nid_postfix returning 1 in libkernel_sys and document the behavior in technical debt.

On PS5 and FreeBSD 11 runtime environments, user-space guest application processes execute inside a sandboxed container jail. Titles query is_in_sandbox() to confirm isolation, expecting 1.

Tested

  • Linux (Ubuntu 24.04 on WSL2 / x86-64 AMD Ryzen 7 9800X3D).
  • Built and executed guest_kernel_sys_ktimer_tests cleanly with Require(is_in_sandbox_nid_postfix() == 1).
  • Verified 17/17 checks with python3 tools/check_conventions.py --base upstream/main (passed).
  • Verified python3 tools/pr_overlap.py --branch feat/libkernel_sys-is-in-sandbox (0 conflicting files, 0 overlap).

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
  • 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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4990689833 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10421). Originally posted by [amazedturnip](https://github.com/amazedturnip) on 2026-10-23T23:49:20Z. --- ### What Implement `is_in_sandbox_nid_postfix` returning 1 in `libkernel_sys` and document the behavior in technical debt. On PS5 and FreeBSD 11 runtime environments, user-space guest application processes execute inside a sandboxed container jail. Titles query `is_in_sandbox()` to confirm isolation, expecting 1. ### Tested - Linux (Ubuntu 24.04 on WSL2 / x86-64 AMD Ryzen 7 9800X3D). - Built and executed `guest_kernel_sys_ktimer_tests` cleanly with `Require(is_in_sandbox_nid_postfix() == 1)`. - Verified 17/17 checks with `python3 tools/check_conventions.py --base upstream/main` (passed). - Verified `python3 tools/pr_overlap.py --branch feat/libkernel_sys-is-in-sandbox` (0 conflicting files, 0 overlap). ### Checklist - [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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
harisibrar1 commented 2026-10-24 01:04:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-24T01:04:28Z.

Review: COMMENTED


Checked against main 11d6efa06c, shadPS4 bab374ba8e (src/core/libraries/kernel/process.cpp) and ps5-payload-dev/sdk a7685ce8e9 (sce_stubs/libkernel_sys.c):

  • This still merges cleanly. return 1 matches shadPS4, whose sceKernelIsInSandbox returns 1 for a title process (process.cpp:15-17). The sdk only has a label stub for is_in_sandbox, so int(void) looks right.
  • sceKernelIsInSandbox in the same library is still NotImplemented_nid_no_patch on main (Export.Discovery.cpp:1494). After this PR, a title that asks through the raw call gets 1, while the sce wrapper throws. Could it return the same value in this PR, or call is_in_sandbox_nid_postfix?
  • Could the debt entry cite where the value comes from, such as the shadPS4 line above? At the moment it only says AnyPS5 runs titles sandboxed.

Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5635987347 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10421#pullrequestreview-5635987347). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-24T01:04:28Z. **Review:** COMMENTED --- Checked against main 11d6efa06c, shadPS4 bab374ba8e (`src/core/libraries/kernel/process.cpp`) and ps5-payload-dev/sdk a7685ce8e9 (`sce_stubs/libkernel_sys.c`): - This still merges cleanly. `return 1` matches shadPS4, whose `sceKernelIsInSandbox` returns 1 for a title process (process.cpp:15-17). The sdk only has a label stub for `is_in_sandbox`, so `int(void)` looks right. - `sceKernelIsInSandbox` in the same library is still `NotImplemented_nid_no_patch` on main (`Export.Discovery.cpp:1494`). After this PR, a title that asks through the raw call gets 1, while the `sce` wrapper throws. Could it return the same value in this PR, or call `is_in_sandbox_nid_postfix`? - Could the debt entry cite where the value comes from, such as the shadPS4 line above? At the moment it only says AnyPS5 runs titles sandboxed. Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
MarcZX10 commented 2026-10-24 22:03:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T22:03:13Z.

Review: APPROVED


Re-reviewed exact head aae9b2456a8232ed57b98a6ab15d4aa69cfa654c.

The follow-up addressed the consistency point: both is_in_sandbox_nid_postfix() and sceKernelIsInSandbox() now return the same value through one implementation, the stale throwing definitions are removed, the focused guest test asserts both exports, and the debt entry cites its behavioral reference. The current-main merge-tree is clean; current-main conventions and diff-check pass. The author reports the focused guest kernel test passing; hosted product builds are not run for this PR, and I did not run the test binary locally.

No blocking findings on this head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5640209504 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10421#pullrequestreview-5640209504). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T22:03:13Z. **Review:** APPROVED --- Re-reviewed exact head `aae9b2456a8232ed57b98a6ab15d4aa69cfa654c`. The follow-up addressed the consistency point: both `is_in_sandbox_nid_postfix()` and `sceKernelIsInSandbox()` now return the same value through one implementation, the stale throwing definitions are removed, the focused guest test asserts both exports, and the debt entry cites its behavioral reference. The current-main merge-tree is clean; current-main conventions and diff-check pass. The author reports the focused guest kernel test passing; hosted product builds are not run for this PR, and I did not run the test binary locally. No blocking findings on this head.
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!10421
No description provided.