Files
AnyPS5/docs/dev/debt/changes/fix-libkernel-sysctl-proc-pid-thread-id.md

2.0 KiB

libkernel

change [kern.proc.pid]

  • kern.proc.pid (libkernel) - what the console fills in a process's kinfo_proc is unverified; sysctl {CTL_KERN, KERN_PROC, KERN_PROC_PID, pid} for the calling process returns a 1,096-byte kinfo_proc, FreeBSD 11 amd64's 1,088 bytes (sys/sys/user.h) plus 8, as a firmware 11.60 payload reports it; here a 1,088-byte buffer gets ENOMEM after a 1,088-byte copy. It holds only ki_structsize, ki_pid, ki_ppid and ki_comm (eboot.bin, the base name of the kern.proc.pathname value), with every other field 0, including ki_flag, so P_TRACED (0x800) is clear. Source Port (PPSA20040) asks for its own record with a 0x440-byte buffer and tests only bit 0x800 of ki_flag at offset 0x170, to see whether a debugger is attached. Other processes' pids and -1 fail with ESRCH, a write with EPERM and a short buffer with ENOMEM.

change [kern.proc.pid_td]

  • kern.proc.pid_td (libkernel) - a PS5 payload process (firmware 11.60) answers {CTL_KERN, KERN_PROC, KERN_PROC_PID | KERN_PROC_INC_THREAD, pid} with ENOENT, so what the console fills in is unverified; here it returns one kern.proc.pid record per live guest thread, as FreeBSD 11.4's kern_proc_out does without KERN_PROC_NOTHREADS, with ki_tid (the pthread_getthreadid_np value), ki_numthreads, and the thread name split as fill_kinfo_thread splits it: up to 16 bytes in ki_tdname, the next 3 in ki_moretdname. Run time, CPU, state, priority and the other per-thread fields stay 0. As for kern.proc.pid, only the calling process is answered, by its pid or the id of one of its live threads: any other pid, -1 included, fails with ESRCH, where FreeBSD's pget also answers for other visible processes.