fix(libkernel): check the SoC sensor channel before the pointer and set errno as measured on a PS5 #11182
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11182"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by orezraey on 2026-10-25T20:50:12Z.
What
sceKernelGetSocSensorTemperaturenow checks the channel before the output pointer, using the range a retail PS5 (firmware 13.60) accepts (0 to 64). It andsceKernelGetCpuTemperaturenow also seterrnoalong with theSCE_KERNEL_ERROR_*code, as the console does. Measured with homebrew probes from a payload process; the sources and console logs are in this gist (ptemp,ptemp3).On the console:
0x80020016witherrno22 and writes nothing, and so do -1,INT_MAXandINT_MIN.0x80020016witherrno22; a null output with channel 0 faults (SIGSEGV).sceKernelGetCpuTemperature(nullptr)returns0x8002000ewitherrno14.Before, AnyPS5 checked the pointer first (
EFAULTeven for an invalid channel), accepted only channels 0 to 2, and set noerrno.Channels 3 to 64 exist on the console but have no host counterpart, so a call for one with a non-null output throws instead of returning a value or an error the console does not give. A channel 0 to 2 the host has no sensor for still returns
EINVAL, as before. A null output with a valid channel keeps returningEFAULTwhere the console faults. The debt entry now starts with these differences.Before and after
sceKernelGetSocSensorTemperaturechannel 65 to 300, -1,INT_MAX0x80020016,errno220x80020016,errnonot set0x80020016,errno220x800200160x8002000e(EFAULT)0x800200160x80020016sceKernelGetCpuTemperature(nullptr)0x8002000e,errno140x8002000e,errnonot set0x8002000e,errno14EFAULTEFAULTTested
Head
57781bd219onmain5a2744c55e:guest_thermal_sensorspasses 3 times out of 3 on Windows 11 (WinLibs GCC 15.2) and 3 times out of 3 on Linux (WSL, GCC 16.2). With theThermalSensors.cppchange reverted, the updated test fails.INT_MAXandINT_MINreturnEINVALwitherrno22 and leave the output untouched, with a null output too.EFAULTwitherrno14 for a null output. The test does not call them with a non-null output, since they are valid on the console and only throw until a host sensor maps them.sceKernelGetCpuTemperatureand to channel 0 setserrno14.tools/check_conventions.pypasses.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T20:51:39Z.
Review: COMMENTED
I checked the cited firmware 13.60 probe: channels 0–64 return success (channel 64 reports -49), and 65+ return EINVAL. This change accepts the measured range but then returns EINVAL for every valid channel 3–64 (sensorId >= 3), and the new test locks that in for 3, 32 and 64. That makes EINVAL mean "no host mapping" even though the console accepts those IDs. Since CONTRIBUTING says an export must implement its behavior or throw, could these valid-but-unimplemented channels use the documented unimplemented path until a generic mapping is available, or otherwise make the intentional console mismatch explicit? The debt entry records the gap, but the return value still presents these channels as invalid. Also, the new test checks the EFAULT return for null outputs on channels 3/32/64 but does not assert errno == 14 there, unlike the other error cases.