fix(libkernel): store setrlimit RLIMIT_CORE soft limit, ignore raised DATA/STACK hard limits #11862

Merged
ionut27001 merged 1 commit from upstream-pr/11862 into main 2026-10-29 12:47:58 +00:00
ionut27001 commented 2026-10-27 10:01:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ionut27001 on 2026-10-27T10:01:25Z.


What

setrlimit kept no state for RLIMIT_CORE, so any change threw. It now stores the RLIMIT_CORE soft limit when the hard limit is unchanged and getrlimit reports it. AnyPS5 never writes a core file, so any core size limit is honoured as is. Raising the hard limit of RLIMIT_DATA or RLIMIT_STACK with the soft limit unchanged returns 0 and leaves both limits as they were, as a payload process on a PS5 (firmware 12.70) does; a request that also changes the soft limit still throws. Other resources behave as on main, and the debt entry lists what throws.

Evidence, probe p87_libkernel (a payload process on a PS5; title processes are unverified; firmware 12.70 from meta fw=0x12700001 on line 2), result.log:

  • lines 7-15: RLIMIT_DATA reads 34359738368 for both limits; raising the hard limit to +1, x2, +2^32 and RLIM_INFINITY with the soft limit unchanged returns 0 with errno 0 each time, and getrlimit reads the old limits after each
  • lines 16-24: the same for RLIMIT_STACK (2097152)
  • lines 25-27: setting the RLIMIT_CORE soft limit to 0, then to 4096 (a raise from 0), then back to infinity returns 0 with errno 0, and getrlimit reads each value back with the hard limit infinity

Earlier probe p83_libkernel (same firmware), result.log:

  • lines 287-301: getrlimit of resources 0 to 14, RLIMIT_DATA 34359738368, RLIMIT_STACK 2097152, RLIMIT_NPROC 1604, RLIMIT_NOFILE 13952, the others infinity
  • lines 302-316: setrlimit to the values just read returns 0 for resources 0 to 14
  • lines 310 and 347-348: setrlimit(RLIMIT_NOFILE) to {13952, 13952} and then to {13952, 13953} both return 0 and getrlimit reads 12555 for both limits; the probe does not read between the two calls (unchanged here, listed in the debt entry)
  • line 362: resource 15 returns -1 with errno 22 (already handled, covered by the test)

Not claimed: the console result for a request that changes the soft limit of RLIMIT_DATA or RLIMIT_STACK together with a raised hard limit (still throws here), the limits after lowering a hard limit (p83 line 361 shows only the return value 0 for RLIMIT_CORE {2, 1}, which FreeBSD normalises to {1, 1}), and soft limit changes of the other resources, which still throw.

Tested

Windows 11, WinLibs GCC 15.2.0 (Release, Ninja), commit bfbe4043c9 on main 75f3702aed:

  • ctest -R ^guest_setrlimit$ passed twice.
  • With Process.cpp restored from main and rebuilt, the same test aborts (setrlimit: changing the limit of resource 4 is not supported).
  • The RLIMIT_DATA hard-raise check runs only when the host RLIMIT_DATA hard limit is finite; on Windows it is infinite unless the process runs in a memory-limited job, so this run most likely exercised only the RLIMIT_STACK raise.
  • Linux and macOS were not built or run.

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 (only a docs line conflict with #11236; whichever lands second rebases)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5032018786 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11862). Originally posted by [ionut27001](https://github.com/ionut27001) on 2026-10-27T10:01:25Z. --- ### What `setrlimit` kept no state for `RLIMIT_CORE`, so any change threw. It now stores the `RLIMIT_CORE` soft limit when the hard limit is unchanged and `getrlimit` reports it. AnyPS5 never writes a core file, so any core size limit is honoured as is. Raising the hard limit of `RLIMIT_DATA` or `RLIMIT_STACK` with the soft limit unchanged returns 0 and leaves both limits as they were, as a payload process on a PS5 (firmware 12.70) does; a request that also changes the soft limit still throws. Other resources behave as on `main`, and the debt entry lists what throws. Evidence, probe `p87_libkernel` (a payload process on a PS5; title processes are unverified; firmware 12.70 from `meta fw=0x12700001` on line 2), `result.log`: - lines 7-15: `RLIMIT_DATA` reads 34359738368 for both limits; raising the hard limit to +1, x2, +2^32 and `RLIM_INFINITY` with the soft limit unchanged returns 0 with errno 0 each time, and `getrlimit` reads the old limits after each - lines 16-24: the same for `RLIMIT_STACK` (2097152) - lines 25-27: setting the `RLIMIT_CORE` soft limit to 0, then to 4096 (a raise from 0), then back to infinity returns 0 with errno 0, and `getrlimit` reads each value back with the hard limit infinity Earlier probe `p83_libkernel` (same firmware), `result.log`: - lines 287-301: `getrlimit` of resources 0 to 14, `RLIMIT_DATA` 34359738368, `RLIMIT_STACK` 2097152, `RLIMIT_NPROC` 1604, `RLIMIT_NOFILE` 13952, the others infinity - lines 302-316: `setrlimit` to the values just read returns 0 for resources 0 to 14 - lines 310 and 347-348: `setrlimit(RLIMIT_NOFILE)` to {13952, 13952} and then to {13952, 13953} both return 0 and `getrlimit` reads 12555 for both limits; the probe does not read between the two calls (unchanged here, listed in the debt entry) - line 362: resource 15 returns -1 with errno 22 (already handled, covered by the test) Not claimed: the console result for a request that changes the soft limit of `RLIMIT_DATA` or `RLIMIT_STACK` together with a raised hard limit (still throws here), the limits after lowering a hard limit (p83 line 361 shows only the return value 0 for `RLIMIT_CORE` {2, 1}, which FreeBSD normalises to {1, 1}), and soft limit changes of the other resources, which still throw. ### Tested Windows 11, WinLibs GCC 15.2.0 (Release, Ninja), commit bfbe4043c9 on main 75f3702aed: - `ctest -R ^guest_setrlimit$` passed twice. - With `Process.cpp` restored from main and rebuilt, the same test aborts (`setrlimit: changing the limit of resource 4 is not supported`). - The `RLIMIT_DATA` hard-raise check runs only when the host `RLIMIT_DATA` hard limit is finite; on Windows it is infinite unless the process runs in a memory-limited job, so this run most likely exercised only the `RLIMIT_STACK` raise. - Linux and macOS were not built or run. ### 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 (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 (only a docs line conflict with #11236; whichever lands second rebases) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-27 10:30:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T10:30:23Z.

Review: DISMISSED


I reviewed the current head b6419c703092ac0b87347a541e7cd243e4e80932. Two behavior gaps block approval:

  • storesSoftLimit returns success and records new limits for RLIMIT_FSIZE, RLIMIT_CORE, RLIMIT_SBSIZE, RLIMIT_NPTS, RLIMIT_SWAP, RLIMIT_KQUEUES and RLIMIT_UMTXP, but those values are not enforced. The PR's own new debt entry confirms there is no EFBIG/SIGXFSZ at the file-size limit and no enforcement for the other resources. A caller receives success for a limit that has no effect, which is a silent stub under this repository's contribution rules. Please implement the affected behavior or keep unsupported changes on the explicit unsupported path rather than reporting them as applied.
  • The only measured hard-limit no-op for RLIMIT_DATA and RLIMIT_STACK raises the maximum by one. The condition requested.rlim_max > current.rlim_max accepts any larger value as a successful no-op. Please keep unmeasured larger raises unsupported until their behavior is established, rather than generalizing beyond the evidence.

The overlap check also lists open #11236 on docs/dev/debt/libkernel.md. CONTRIBUTING requires the authors to agree on order and declare it with Depends on; please coordinate and update the dependency field. The existing inline review comment already covers the proposed unsupported-STACK test assertions; I am not duplicating that request here.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5665613207 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11862#pullrequestreview-5665613207). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-27T10:30:23Z. **Review:** DISMISSED --- I reviewed the current head `b6419c703092ac0b87347a541e7cd243e4e80932`. Two behavior gaps block approval: - `storesSoftLimit` returns success and records new limits for `RLIMIT_FSIZE`, `RLIMIT_CORE`, `RLIMIT_SBSIZE`, `RLIMIT_NPTS`, `RLIMIT_SWAP`, `RLIMIT_KQUEUES` and `RLIMIT_UMTXP`, but those values are not enforced. The PR's own new debt entry confirms there is no `EFBIG`/`SIGXFSZ` at the file-size limit and no enforcement for the other resources. A caller receives success for a limit that has no effect, which is a silent stub under this repository's contribution rules. Please implement the affected behavior or keep unsupported changes on the explicit unsupported path rather than reporting them as applied. - The only measured hard-limit no-op for `RLIMIT_DATA` and `RLIMIT_STACK` raises the maximum by one. The condition `requested.rlim_max > current.rlim_max` accepts any larger value as a successful no-op. Please keep unmeasured larger raises unsupported until their behavior is established, rather than generalizing beyond the evidence. The overlap check also lists open #11236 on `docs/dev/debt/libkernel.md`. CONTRIBUTING requires the authors to agree on order and declare it with `Depends on`; please coordinate and update the dependency field. The existing inline review comment already covers the proposed unsupported-STACK test assertions; I am not duplicating that request here.
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!11862
No description provided.