2026-09-01 (hardware injector capture #6 analysis: errno diagnostics, thread ucred synchronization & root uid elevation) (D290)
Analyzed hardware test logs
(reports/hardware/injector-klog.txt and
reports/hardware/injector-klog.txt.klog):
- Target Identification & System Stability
Validated:
- Title ID scanner successfully crawled
struct procin kernel memory, found candidate retail titlePPSA04263at PID 204, and distinguished it from background candidates. - Embedded payload blob verified present and valid
(
size: 9316792). - Clean failure handling verified: On
PT_ATTACHfailure,injector_exit(-6)cleanly invokedSYS_exit, reportingexit_value=fffffffawith zero panics, zero coredumps, and zero fatal signals.
- Title ID scanner successfully crawled
- Root Cause Analysis of
PT_ATTACH ret=-1:- Per-Thread Cached Credentials
(
td->td_ucred): In FreeBSD, system calls execute in the context of the calling thread (curthread). While D289 updatedmy_kproc->p_ucred, the thread structure's cached credential pointer (td->td_ucred) was left pointing to the originalmy_ucred(insideNPXS40112's VSH prison). Whensys_ptraceinvokedp_candebug(td, target_p),prison_check(td->td_ucred, target_p->p_ucred)evaluated the two disjoint prisons and rejected attachment across the jail boundary (ESRCH). - Unprivileged Process Tracing
(
PRIV_DEBUG_UNPRIV): Even when tracer and tracee share prison boundaries, FreeBSD'scr_candebug()enforcespriv_check_cred(cred, PRIV_DEBUG_UNPRIV). If the credential's user ID is not root (cr_uid != 0), unprivileged process debugging in a container jail is denied withEPERM(error 1). - Missing
errnoTelemetry:sys_callwraps the syscall trampoline. When a syscall fails,libkernelsets thread-localerrnovia__error()and returns-1. The exact POSIX error code was unlogged.
- Per-Thread Cached Credentials
(
- Remediation:
- Dynamic Thread Credential Scanning: In
krw_swap_ucred(), traversesmy_kproc->p_threads(my_kproc + 0x10) to find the calling threadtd, scans for any member matchingmy_ucredto dynamically identifytd_ucred, and synchronizes it totarget_ucred. - Root UID Elevation: In
krw_elevate_current_process()andkrw_elevate_process(), saves originalcr_uid,cr_ruid, andcr_svuidand zeroes them out (cr_uid = 0), granting root privileges sopriv_check_cred(PRIV_DEBUG_UNPRIV)succeeds withoutEPERM. sys_get_errno()Diagnostic Logging: Resolvedlibkernel's__error()insrc/common/syscall.cand updatedprocctl_attach()to reportPT_ATTACH errno=andwait4 errno=.- Safe Restoration: Both process and thread credentials, along with original UIDs, are cleanly restored on detach or early exit.
- Dynamic Thread Credential Scanning: In
Verified: make payload injector HARDWARE=1
(9,394,216 bytes) compiles 100% clean with zero warnings
and zero errors.