Repository navigation
docs(libSceSystemService): record the valid-buffer and unmapped-pointer results of sceSystemServiceGetDisplaySafeAreaInfo on firmware 11.60 - #27880
Conversation
…er results of GetDisplaySafeAreaInfo Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Probe source ( Run: probe.c (build 19306b2522f2)#include <errno.h>
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <ps5/kernel.h> /* only for kernel_get_fw_version() */
#ifndef PROBE_NAME
#define PROBE_NAME "unnamed"
#endif
#ifndef PROBE_BUILD
#define PROBE_BUILD "unbuilt"
#endif
/* Self limit: on timeout the runner can only close the connection, not end the process on the console.
The probe ends itself after at most PROBE_MAX_S seconds (the build script sets timeout - 10 s). */
#ifndef PROBE_MAX_S
#define PROBE_MAX_S 50
#endif
static void probe_alarm(int sig) {
static const char msg[] = "TIMEOUT\tprobe self limit\n";
(void)sig;
(void)!write(1, msg, sizeof msg - 1);
_exit(124);
}
static int cases = 0;
static void probe_header(void) {
char utc[32];
time_t now = time(0);
struct tm tmv;
gmtime_r(&now, &tmv);
strftime(utc, sizeof utc, "%Y-%m-%dT%H:%M:%SZ", &tmv);
printf("PROBE\t%s\tfw=0x%08x\tbuild=%s\tpid=%d\tutc=%s\n", PROBE_NAME, kernel_get_fw_version(), PROBE_BUILD,
getpid(), utc);
fflush(stdout);
}
/* CASE: id, description of the call, return value as long, errno (0 if not set), extra (hex/bytes). */
static void probe_case(const char* id, const char* call, long ret, int err, const char* extra) {
printf("CASE\t%s\t%s\t%ld\t%d\t%s\n", id, call, ret, err, extra ? extra : "-");
fflush(stdout);
cases++;
}
static void probe_end(void) {
printf("END\t%d\n", cases);
fflush(stdout);
}
#include <dlfcn.h>
#include <setjmp.h>
#include <stdlib.h>
#include <pthread.h>
#include <sys/mman.h>
#include <sys/types.h>
static sigjmp_buf guard_env;
static volatile int guard_sig = 0;
static volatile int guard_active = 0;
static volatile int guard_hits = 0;
static void guard_handler(int s) {
static const char msg[] = "FAULT\tprobe guard: fault outside a guarded call or too many faults\n";
if(!guard_active || ++guard_hits > 8) {
(void)!write(1, msg, sizeof msg - 1);
_exit(125);
}
guard_sig = s;
guard_active = 0;
siglongjmp(guard_env, 1);
}
static void guard_arm(void) {
struct sigaction sa;
memset(&sa, 0, sizeof sa);
sa.sa_handler = guard_handler;
sigaction(SIGSEGV, &sa, 0);
sigaction(SIGBUS, &sa, 0);
sigaction(SIGABRT, &sa, 0);
}
#define CALL(rvar, evar, expr) do { errno = 0; guard_sig = 0; rvar = -1; if(sigsetjmp(guard_env, 1) == 0) { guard_active = 1; rvar = (expr); } guard_active = 0; evar = errno; } while(0)
#include <time.h>
/* sceSystemServiceGetDisplaySafeAreaInfo in libSceSystemService.sprx on firmware 11.60 (payload process; a title process may differ), output buffer cases for debt entry libSceSystemService.md:173 (an unwritable output pointer: does the console fault or return an argument error; the valid output is not recorded anywhere either). dlopen first (result printed at once), controls, names. The prototype (info*) and the layout (a float ratio and 128 reserved bytes, 132 bytes) are ASSUMPTIONS from core/libs/SceTypes.hpp (SystemServiceDisplaySafeAreaInfo) and core/libs/prx/libSceSystemService/Export.cpp of AnyPS5 (upstream/main 37749b6cd567); the valid buffer is filled with 0xAA so that the written bytes show. Pointer cases (0x10, a read-only literal, NULL) are single calls and come last; a fault ends the calls. A watchdog thread ends the probe after PROBE_MAX_S. No state is set, read only. */
typedef long (*f4_t)(long, long, long, long);
static void* L;
static int stopped = 0;
static void note(const char* t) { printf("NOTE\t%s\n", t); fflush(stdout); }
static void report(const char* id, const char* what, const char* ex) { probe_case(id, what, 0, 0, ex); }
static void* wd_thread(void* arg) {
static const char msg[] = "TIMEOUT\twatchdog thread\n";
unsigned left = PROBE_MAX_S;
(void)arg;
while(left) left = sleep(left);
(void)!write(1, msg, sizeof msg - 1);
_exit(124);
return 0;
}
static void wd_start(void) { pthread_t t; if(pthread_create(&t, 0, wd_thread, 0) == 0) pthread_detach(t); }
static int canary_ok(const unsigned char* p, int n) { for(int i = 0; i < n; i++) if(p[i] != 0xAA) return 0; return 1; }
static struct { unsigned char b[132]; unsigned char can[64]; } B;
static const char RO[32] = "read-only probe literal";
static f4_t fn;
static void run(const char* id, const char* what, long ptr, int own, int words) {
if(stopped) return;
if(own) { memset(B.b, 0xAA, sizeof B.b); memset(B.can, 0xAA, sizeof B.can); }
long r = -1; int e = 0;
CALL(r, e, fn(ptr, 0, 0, 0));
char ex[520];
if(own) {
int ch = 0, last = -1;
for(int i = 0; i < (int)sizeof B.b; i++) if(B.b[i] != 0xAA) { ch++; last = i; }
unsigned w[4] = {0, 0, 0, 0};
memcpy(w, B.b, 16);
float f0; memcpy(&f0, B.b, 4);
snprintf(ex, sizeof ex, "rc=0x%08x errno=%d changed=%d last_changed=%d word0=0x%08x word1=0x%08x word2=0x%08x word3=0x%08x float0=%g canaries_intact=%d signal=%d", (unsigned)r, e, ch, last, w[0], w[1], w[2], w[3], (double)f0, canary_ok(B.can, 64), (int)guard_sig);
} else {
snprintf(ex, sizeof ex, "rc=0x%08x errno=%d signal=%d", (unsigned)r, e, (int)guard_sig);
}
(void)words;
probe_case(id, what, guard_sig ? -1 : (int)r, e, ex);
if(guard_sig) stopped = 1;
}
int main(void) {
signal(SIGALRM, probe_alarm);
alarm(PROBE_MAX_S);
probe_header();
guard_arm();
wd_start();
note("0.pre: dlopen of libSceSystemService.sprx next");
L = dlopen("libSceSystemService.sprx", RTLD_LAZY);
{ char ex[16]; snprintf(ex, sizeof ex, "%d", L != 0); report("0", "dlopen of the module (1 yes, 0 no)", ex); }
if(!L) { probe_end(); return 0; }
{ void* k = dlopen("libkernel.sprx", RTLD_LAZY); char ex[80]; snprintf(ex, sizeof ex, "libkernel_opened=%d control_found=%d", k != 0, k ? dlsym(k, "sceKernelGetProcessTime") != 0 : 0); report("1", "control in libkernel.sprx: sceKernelGetProcessTime (dlsym, name only)", ex); }
{ char ex[40]; snprintf(ex, sizeof ex, "found=%d", dlsym(L, "sceSystemServiceParamGetInt") != 0); report("1b", "control in the same module: sceSystemServiceParamGetInt (dlsym, name only; resolved in earlier runs)", ex); }
{ char ex[40]; snprintf(ex, sizeof ex, "found=%d", dlsym(L, "probe_e_no_such_function_in_module") != 0); report("2", "negative control, a name that does not exist (expected found=0)", ex); }
{ char ex[40]; snprintf(ex, sizeof ex, "found=%d", dlsym(L, "sceSystemServiceGetDisplaySafeAreaInfo") != 0); report("3", "the function under test (dlsym, name only)", ex); }
fn = (f4_t)dlsym(L, "sceSystemServiceGetDisplaySafeAreaInfo");
if(!fn) { probe_end(); return 0; }
note("next: GetDisplaySafeAreaInfo with an own 132 byte output buffer filled with 0xAA (assumed layout: a float ratio and 128 reserved bytes, from the AnyPS5 type), twice; assumed prototype (info*)");
run("a.1", "GetDisplaySafeAreaInfo(own 132 byte buffer, 0xAA fill): rc, bytes changed, first words", (long)(void*)B.b, 1, 4);
run("a.2", "the same call again (stable?)", (long)(void*)B.b, 1, 4);
note("next: pointer cases, one call each, last, in this order; a fault ends the calls (hello2 after)");
run("z.1", "GetDisplaySafeAreaInfo(output pointer 0x10, unmapped)", 0x10, 0, 0);
run("z.2", "GetDisplaySafeAreaInfo(output pointer to a read-only literal: mapped but not writable)", (long)(void*)RO, 0, 0);
run("z.3", "GetDisplaySafeAreaInfo(NULL output pointer)", 0, 0, 0);
if(stopped) note("a fault ended the calls");
probe_end();
return 0;
}Run: raw output (15 lines)AI-assisted (Claude Code). |
|
No actionable comments were generated in the recent review. Walkthrough
Change: Other Merge Risk:
|
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
The documentation change accurately records the single-run firmware 11.60 observations and clearly states the limits of the probe; I found no blocking issue in the changed fragment.
What I ran
Reviewed head b4b2ee4482f4552c5540a65cd3372d723184dd2f. No commands or tests were run; the review bundle reports that no test was added or run. I read description.md, commits.md, manifest.json, diff.patch, the complete changed fragment, and the existing debt entry it replaces. The changed file is the only file listed in the manifest as reviewed; no exclusions were provided in the bundle.
Results
| Check | Result | Note |
|---|---|---|
| Changed fragment | passed | Matches the stated observations and limitations |
| Repository checks | not run | Description reports author-run checks |
| Probe | not run | Hardware observation supplied by author |
Findings
Blocking
None.
Non-blocking
None.
Not verified
The PS5 probe and reported firmware behavior were not independently verified. No tests or repository checks were run during this review. files.json was unavailable, so exclusions beyond the manifest could not be confirmed.
To get this to a good state
Nothing is required.
ligmaSec
left a comment
There was a problem hiding this comment.
The fragment folded into the intended safe-area output entry, and the linked host wrapper checks the output through the guest copy routine. The firmware 11.60 results, including the four bytes changed in the valid buffer and the fault in the unmapped case, are the author’s console measurements.
AI-assisted: yes.
What
The debt entry for
sceSystemServiceGetDisplaySafeAreaInfo(docs/dev/debt/libSceSystemService.md:173onmain13bf980d9659) says that whether the console faults or returns an argument error on unmapped memory is unmeasured. A probe on a PS5 (firmware 11.60, payload process; a title process may differ) called the function with an own 132-byte buffer filled with 0xAA: it returned 0 and changed only the first 4 bytes, to0x3f800000, the float 1.0 (case a.1, line 10 of the raw output in the first comment), and the same again in a second call (case a.2, line 11). The call with the unmapped output pointer 0x10 did not return: the probe's handler (installed for SIGSEGV, SIGBUS and SIGABRT,probe.c:79to:81) caught a signal and theCASEline showssignal=11with the return value -1 (case z.1, line 13;probe.c:126). It ran once; line 14 says that the fault ended the calls, so a read-only buffer and NULL were not measured. The size of 132 bytes (a float and 128 reserved bytes) and the prototype (a pointer to it) are assumed from AnyPS5's own typeSystemServiceDisplaySafeAreaInfo(core/libs/SceTypes.hpp:2209to:2212); the probe did not measure how many bytes the console may write. Line 3 is a[SceLncUtil] ... getAppStatus: LNC_ISOK::0x80940004message that the console printed during the run.On
mainthe function returnsSYSTEM_SERVICE_ERROR_PARAMETER(-2136932349,core/libs/prx/libSceSystemService/SystemService.hpp:17) for a NULL pointer and for an output that cannot be written, and otherwise writes the whole 132-byte structure, the ratio 1.0 followed by zero bytes, and returns 0 (core/libs/prx/libSceSystemService/Export.cpp:419to:430); the console changed only the first 4 bytes of the 0xAA-filled buffer. The entry states the measured answers; it does not change any code.This pull request replaces the entry in a new fragment (
docs/dev/debt/changes/docs-libscesystemservice-displaysafearea-unmapped.md,## change [sceSystemServiceGetDisplaySafeAreaInfo guest output]); the entry grows from 325 to 586 characters with its list marker. It keeps that the PARAMETER answer is a host-safety fallback, states the valid-buffer answer 0 with only the first 4 bytes changed to the float 1.0 (the same in a second call) and the fault for an unmapped pointer (one run), and says that the prototype and the buffer layout are assumed. No code changes.Not measured: a NULL output pointer, a read-only output buffer, the number of bytes the console may write beyond the 132 assumed, the values for a title process, other firmware.
Tested
Measured on a PS5 with firmware 11.60 from a homebrew payload process, one run at about 07:19 UTC on 2026-11-27 (probe build 19306b2522f2,
END 8). This is a documentation change; no test was added or run.On the head merged into
mainat 13bf980 (2026-11-27 17:30 UTC) I rantools/check_conventions.py --base upstream/mainwith this title and description (All conventions checks passed, exit code 0) andtools/debt_fold.py --check(exit code 0, no message). The commit has one author,xXPBSXxwith the noreply address, and adds one new file with the mode 100644.Overlap: counted on 2026-11-27 from the 2168 open pull requests (file lists from the GitHub API, the 13 with 100 or more files read in full through the files API and, for those and for the pull requests with an old base, the real diff against the merge base; the patches of the 1299 pull requests that change a file under
docs/dev/debt/or a libSceSystemService file, or have SystemService, HdrToneMap, NoticeSkip, ParamGetInt or DisplaySafeArea in the title or branch name, were searched forsceSystemServiceGetHdrToneMapLuminance,sceSystemServiceGetNoticeScreenSkipFlag,sceSystemServiceParamGetInt,sceSystemServiceGetDisplaySafeAreaInfo, the short namesHdrToneMap,NoticeScreenSkipandDisplaySafeAreaand the four fragment names, from 15:15 to 15:35 UTC). No open pull request changes the fragmentdocs/dev/debt/changes/docs-libscesystemservice-displaysafearea-unmapped.mdor the entry forsceSystemServiceGetDisplaySafeAreaInfoatdocs/dev/debt/libSceSystemService.md:173. The base of this branch is2b6c1b044528. The only pull requests whose patch names one of the four functions or short names are #20235 (fix(libSceVideoOut): clear the HDR report when the Windows window query fails, which rewrites theHDR outputentry indocs/dev/debt/libSceVideoOut.mdand namessceSystemServiceGetHdrToneMapLuminancethere, a different entry in a different file), #24736 (feat(libSceWkFontConfig): look fonts up in the firmware font table, which callssceSystemServiceParamGetInt(1, ...)and names it in its own fragment) and #12315 (feat(libSceLibreSsl3): implement numeric object identifier text parsing, an old base, whose patch addsSystemServiceParamGetIntas an export of the modulelibReactNative.Modules.Vsh.WebAppLauncher, a different function, and has other names that only end inParamGetInt); none of them changes one of the four entries. The other open pull requests that change a libSceSystemService file (#27751, #27629, #27626, #27531, #25260, #25101, #20896, #17144, #17090, #15973, #15947, #14202; #25704 lists SystemService files only because of its old base, its own diff of 7 files has none) were searched in the real diff against the merge base for the same names and fragment names and do not contain them; #27531 is the fragment ofsceSystemServiceGetStatusby the same author, a different entry (:178). The merges of this head with each of these pull requests and with the pull requests with 100 or more files or an old base (#25940, #22647, #20315, #14443, #14340, #13929, #13928, #12315, #10193, #9508, #7642, #6743) were made withgit merge-treefrom 15:15 to 15:39 UTC againstmainatb464859c1f83: #27751, #27629, #27626, #27531, #25260, #25101, #20896, #17144, #17090, #15947, #25940, #25704 and #6743 are clean; #15973 (6 files), #14202 (1 file), #22647, #20315, #14443, #14340, #13929, #13928, #12315, #10193, #9508 and #7642 already conflict withmainalone, in at least as many files as with this head, so none of them conflicts because of this change. The count was repeated for the pull requests that were opened or updated since 15:15 UTC (147 of the 2111 open pull requests, listed from 17:22 to 17:28 UTC; the 91 of them with a debt file, a SystemService path or one of the names in the title or branch were patch-scanned for the same names and fragment names): no further pull request names one of the four functions or changes one of the four entries or fragments; the two that change a SystemService file, #27751 and #27626, merge cleanly with each of the four heads (git merge-treeof the head with the pull request head, compared withmainat 13bf980). No commit onmainsince2b6c1b044528(268 commits) changed the four entries,core/libs/prx/libSceSystemService/Export.cppor a SystemService fragment. A merge of this head intomainat 13bf980 was checked the same way at 17:30 UTC and is clean, and the four heads of this series (hdrtonemap, noticeskip, paramgetint, displaysafearea, each a new file of its own) merge with each other without a conflict. This pull request does not depend on any of them (Depends on: none).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Summary by CodeRabbit