libkernel: sendmsg on guest memory it cannot read crashes the host instead of failing with EFAULT #8462
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 xXPBSXx on 2026-10-20T13:03:40Z.
Repro
Windows host.
sendmsg(s, (const msghdr*)0x1000, 0), or a valid header whoseiov, an iovecbaseornamepoints to unmapped orPROT_NONEmemory.Expected (FreeBSD 11.4): EFAULT (14):
sys_sendmsgcopies the header,copyiniovthe iovec array,getsockaddrthe name anduiomovethe buffers withcopyin.Actual: the host takes an access violation (0xc0000005) in
sendmsg_nid_postfix, which reads all four from guest memory directly.recvmsgalready fails with EFAULT (#7675).Test:
guest_sendmsg_memory(modesendmsg-memoryofguest_socket_pair_tests, new); crashes before the fix.Fix branch: https://github.com/xXPBSXx/AnyPS5/tree/fix/sendmsg-guest-memory-efault
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by Filip722 on 2026-10-21T09:45:56Z.
Confirmed on Linux: unreadable guest inputs to
sendmsgterminate the process withSIGSEGV, rather than returningEFAULT.Tested unchanged upstream
mainb5d763770a8e932b35db9bea1c415e7e0ac50a22in a separate validation checkout. Environment: Debian GNU/Linux 13.7 (trixie), x86-64, kernel7.2.9-x64v3-xanmod1, AMD Ryzen 5 7640HS, GCC/G++ 15.2.0, CMake 3.31.6/Ninja. Full project configuration:Release,BUILD_TESTING=ON,ANYPS5_RELINKER_ONLY=OFF,ANYPS5_USE_SYSTEM_DEPS=OFF; rebuiltlibc,libkernelandlibkernel_sys. Temporary probes linked directly to these freshly built, unpatched runtime libraries, as the repository runtime tests do. No production source changes.Reproduction: a temporary probe reused the layouts and guest-memory setup from
GuestSocketPair.cpp:socketpair_nid_postfix(1, 2, 0, pair)and a 48-byte guestmsghdr. For each input below I launched a separate process and calledsendmsg_nid_postfix(pair[0], message, 0). The inaccessible page was allocated withsceKernelMapFlexibleMemoryand protected withsceKernelMprotect(..., 0); the other bad address was0x1000. Core dumps were disabled.0x1000All eight children reached the marker immediately before the call and exited from signal 11 (Python subprocess return code
-11), without returning a guest errno. A debugger run of the header case confirms the affected path:Positive controls: a valid message sent/received
ok(2 bytes); a payload on a guest page protected read-only sent/receivedro(2 bytes). Existingguest_socket_pairandguest_recvmsg_memorypass, so the receive-side protection test passing does not establish send-side safety.Scope: unchanged-main reproduction only; #8463's checked-read implementation was not applied/tested. No second-iovec, racing unmap, ancillary-data, console, Windows, GPU or title testing claimed.
AI-assisted: yes (Codex); I am responsible for the reported investigation and results.