Skip to content

fix(libkernel): pipe crashes on a descriptor array in unmapped memory instead of failing with EFAULT and closing the new descriptors #10977

Closed

Description

@xXPBSXx

pipe_nid_postfix (core/libs/prx/libkernel/File/src/Stdio.cpp) writes the two descriptors with memcpy after no real check: GuestArena::HostWrite::Open() accepts any non-arena host pointer. A pointer into unmapped memory (1, 0xfffffffffffff000) crashes the host. FreeBSD 11.4 sys_pipe2 copies the descriptors out after kern_pipe and, if that fails, closes both and returns EFAULT (sys/kern/sys_pipe.c:479-483).

getsockname and getpeername have the same problem with their address and length pointers but live in Udp.cpp, which several open PRs touch, so they are left out.

AI-assisted (Claude Code).

Activity

  1. MarcZX10 commented on Oct 25, 2026

    @MarcZX10
    Contributor

    One coordination point for the eventual fix: open PR #10975 adds a checked GuestCopyOut_nid_no_patch helper, but it is not merged and currently only routes the time-related outputs through it. The pipe fix will need to use that helper only after it is available on its base (declare Depends on: #10975 if the branch builds on it), or otherwise avoid introducing duplicate checked-copy behavior. Keep the failure cleanup from the FreeBSD pipe2 path: if copying out either descriptor fails, close both newly created descriptors and return EFAULT.

  2. xXPBSXx commented on Oct 25, 2026

    @xXPBSXx
    ContributorAuthor

    Thanks. GuestCopyOut_nid_no_patch is already on main: it came with #9618 (83f28bd67f, core/libs/prx/libc/src/General.cpp), not with #10975. #10979 is based on main and only calls it; it does not add or change the helper (its diff is Stdio.cpp, the new test and the CMake entry), so it does not depend on #10975. The failure path closes both new descriptors and returns EFAULT, as in sys_pipe2.

    AI-assisted (Claude Code).

  3. MarcZX10 commented on Oct 25, 2026

    @MarcZX10
    Contributor

    You're right; I missed that is already present on main from #9618. I checked the #10979 diff, and it only uses the existing helper, so no dependency on #10975 is needed. Thanks for correcting that.

  4. MarcZX10 commented on Oct 25, 2026

    @MarcZX10
    Contributor

    To be precise: GuestCopyOut_nid_no_patch is already present on main from #9618. I checked the #10979 diff, and it only uses that existing helper, so no dependency on #10975 is needed. Thanks for correcting my earlier comment.

  5. EternalCoderss commented on Oct 26, 2026

    @EternalCoderss
  6. MarcZX10 commented on Oct 26, 2026

    @MarcZX10
    Contributor

    Open PR #10979 implements the reported invalid-descriptor-array handling and closes descriptors when copy-out fails. Its Windows/Linux focused test report is from an older main; the branch is now 769 commits behind current main, so I requested a refresh and exact-head rerun before treating the issue as resolved. The issue remains open until the fix lands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions