fix(libkernel): return EFAULT from sendfile for invalid memory pointers #13537
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13537"
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 pushkarreddyy on 2026-10-30T17:47:32Z.
What
In
sendfile_nid_postfix(core/libs/prx/libkernel/Socket/src/Udp.cpp), passing an unreadable guest pointer forheadersor its internalheaders/trailersKernelIovecarrays, or an unwritable pointer forsbytes, caused direct host pointer dereferences resulting in host segmentation faults (SIGSEGV).This change copies guest data safely via
GuestCopyIn_nid_no_patchandGuestCopyOut_nid_no_patch, returningEFAULT(14) per FreeBSD 11.4sys_sendfile/kern_sendfilesemantics when memory is inaccessible. Also adds regression test coverage incore/libs/tests/GuestSendfile.cppand updates technical debt documentation indocs/dev/debt/libkernel.md.Fixes #13525.
Tested
Windows 11, unit test suite (
core/libs/tests/GuestSendfile.cpp) verifying rejection of invalid memory pointers (0x10) forheaders,headers->headers,headers->trailers, andsbytesreturning14(EFAULT).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-30T17:54:39Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The invalid guest-pointer paths are routed through safe copy helpers, but the new iovec-vector allocations can throw instead of returning the existing ENOMEM error.
What I ran
Reviewed head 299c2fe0cbd4246d62bdee1f49d04597164e4037 against base
223b19ba0a; the exact-head merge preview was clean. Environment: Linux x86_64, Python 3.11.2, GCC 12.2.0. I did not build or compile.Conventions, diff check, ABI audit, and base merge preview passed. The test-quality heuristic flagged test registration, but CMake directly registers this test; that heuristic finding is a false positive. The precheck could not invoke two private helper scripts because they are not present in the PR snapshot. Hosted checks were queued at last refresh.
Results
Unedited command output
The heuristic's registration warning was:
The precheck's private helper paths were unavailable in the PR snapshot; for example:
Findings
Blocking
Non-blocking
Sources
Not verified
To get this to a good state
Catch allocation failure for both vector resizes and return ENOMEM, then rerun guest_sendfile on the updated head. I will repeat the same checks there.