Skip to content

viewer: socket identity check misses a replaced socket on ext4 #404

Closed

Description

@ElbertePlinio

Found in the release dry run 40748393366 for PR #400. The Lab gates failed in packages/cli/test/native-viewer.test.ts > "refuses dead readiness whose socket was replaced": stopNativeViewerHost resolved instead of throwing "Unsafe stale viewer socket".

removeDeadReadiness in packages/desktop-linux/src/viewer-host.ts and removeNativeReadiness in packages/desktop-linux/src/viewer-state.ts decide that host.sock is the recorded socket when its ino and dev match host.json. ext4 gives a freed inode number to the next file created in the same directory. A socket replaced at host.sock therefore usually keeps the recorded ino and dev. On an ext4 loop mount, a new socket at the same path reused the inode in 50 of 50 tries. tmpfs and btrfs did not reuse it. GitHub runners keep /tmp on ext4, so the test fails there whenever no other file takes the inode first.

Impact: stop or prune can unlink a socket that another process of the same user created at host.sock after the host died. The path is inside Pickforge's private viewer directory and the check runs under the session lock, so the impact is low.

  • Record and compare a socket identity that a replacement cannot share, such as the ctime in nanoseconds from a bigint lstat
  • Make the test replace the socket on any filesystem and expect the refusal again

PR #400 changes the test to record a socket identity that cannot match, so it checks the refusal itself until this is fixed.

Activity

  1. ElbertePlinio commented on Oct 28, 2026

    @ElbertePlinio
    MemberAuthor

    The same ino and dev pair also decides whether a request may use host.sock, in packages/desktop-linux/src/viewer-host.ts:49. A fix should cover that check too.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions