Skip to content

devpts: return ESPIPE for positional I/O on PTYs - #14111

Open
copybara-service[bot] wants to merge 1 commit into
masterfrom
test/cl964247273
Open

devpts: return ESPIPE for positional I/O on PTYs#14111
copybara-service[bot] wants to merge 1 commit into
masterfrom
test/cl964247273

Conversation

@copybara-service

Copy link
Copy Markdown

devpts: return ESPIPE for positional I/O on PTYs

Description

PTY master and replica file descriptions currently fall through to the default
PRead and PWrite implementations, which return EINVAL. Mark both endpoints as
denying positional reads and writes so VFS returns ESPIPE before dispatching the
operation.

This matches Linux for preadv, preadv2, pwritev, and pwritev2 with explicit
offsets while preserving preadv2 and pwritev2 with offset -1 as streaming I/O.
It also lets callers such as Zig file writers recognize PTYs as unseekable and
fall back to normal streaming writes.

Fixes #13737.

Tests

  • //test/syscalls:preadv2_test_runsc_systrap_directfs
  • //test/syscalls:preadv2_test_runsc_ptrace
  • bazel-bin/test/syscalls/linux/preadv2_test --gtest_filter=Preadv2Test.PtyWithOffset (native Linux)
  • //test/syscalls:pwritev2_test_runsc_systrap_directfs
  • //test/syscalls:pwritev2_test_runsc_ptrace
  • //test/syscalls:pwritev2_test_native (focused PTY regression)
  • //pkg/sentry/fsimpl/devpts:devpts_test
  • //pkg/sentry/fsimpl/devpts:devpts_nogo
  • //pkg/sentry/fsimpl/devpts:devpts_test_nogo

Assisted-by: Codex
FUTURE_COPYBARA_INTEGRATE_REVIEW=#14097 from ryux1:fix/pty-positional-write-espipe 7308f5f

@copybara-service copybara-service Bot added the exported Issue was exported automatically label Aug 13, 2026
@copybara-service
copybara-service Bot force-pushed the test/cl964247273 branch 5 times, most recently from f058572 to 27cdeb7 Compare August 14, 2026 18:55
Description

PTY master and replica file descriptions currently fall through to the default
PRead and PWrite implementations, which return EINVAL. Mark both endpoints as
denying positional reads and writes so VFS returns ESPIPE before dispatching the
operation.

This matches Linux for preadv, preadv2, pwritev, and pwritev2 with explicit
offsets while preserving preadv2 and pwritev2 with offset -1 as streaming I/O.
It also lets callers such as Zig file writers recognize PTYs as unseekable and
fall back to normal streaming writes.

Fixes #13737.

Tests

- //test/syscalls:preadv2_test_runsc_systrap_directfs
- //test/syscalls:preadv2_test_runsc_ptrace
- bazel-bin/test/syscalls/linux/preadv2_test --gtest_filter=Preadv2Test.PtyWithOffset (native Linux)
- //test/syscalls:pwritev2_test_runsc_systrap_directfs
- //test/syscalls:pwritev2_test_runsc_ptrace
- //test/syscalls:pwritev2_test_native (focused PTY regression)
- //pkg/sentry/fsimpl/devpts:devpts_test
- //pkg/sentry/fsimpl/devpts:devpts_nogo
- //pkg/sentry/fsimpl/devpts:devpts_test_nogo

Assisted-by: Codex
FUTURE_COPYBARA_INTEGRATE_REVIEW=#14097 from ryux1:fix/pty-positional-write-espipe 7308f5f
PiperOrigin-RevId: 964247273
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

exported Issue was exported automatically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pty: pwritev/pwritev2 with an offset return EINVAL; Linux returns ESPIPE

1 participant