9 Commits
Author SHA1 Message Date
Shailend ChandandgVisor bot b943164ed6 Make every user of a tty also refcount
A tty inode was kept alive by a single ownership chain: the stdio file
description's reference on the import-time dentry. Everything else that used
the inode referred to it uncounted: a file description opened via /dev/tty
pins only the devtmpfs dentry, and the controlling-terminal association
(ThreadGroup.tty) is a bare pointer.

PiperOrigin-RevId: 962479941
2026-08-10 18:19:56 -07:00
Nicolas LacasseandgVisor bot 21061daa40 Move host TTYOperations to the host inode struct.
The TTYOperations for a donated host TTY were on the TTYFileDescription, but
that scopes them per-FD, when they should be scoped per-inode.

This CL moves the TTYOperations logic to the host inode struct, rather than the
TTYFileDescription. It also renames TTYOperations.Open ->
TTYOperations.TTYOpen, to avoid a naming collision with kernfs.inodeOpen.

As a result, opening a TTY (like via /dev/tty) always goes through inode.open,
thus creating a new TTYFileDescrption every time, whereas previously we
incorrectly returned the same TTYFileDescription each time.

Fixes #11644

PiperOrigin-RevId: 752856291
2025-04-29 13:20:18 -07:00
Nicolas LacasseandgVisor bot 43d65c0f6c Implement /dev/tty for sentry-internal ttys.
The /dev/tty acts as a replica for the current thread group's controlling
terminal.

In a follow-up, I will make /dev/tty work for donated host ttys.

Updates #10925

PiperOrigin-RevId: 681629892
2024-10-02 16:23:54 -07:00
Ayush RanjanandgVisor bot b1d2398298 Delete devtmpfs and replace it with tmpfs.
Our devtmpfs implementation uses the same tmpfs filesystem instance for all
devtmpfs mounts in the sandbox. This would mean that devices mounted in a
container are visible and accessible to all other containers in the sandbox.

With GPU/TPU, the contents of devtmpfs can be different for different
containers within the same sandbox. So it is important to not share the same
devtmpfs contents.

It is better to drop support for devtmpfs, than to implement it incorrectly.
Instead, this change introduces a new dummy filesystem type named `dev`. This
filesystem can not be mounted or listed by the application. This filesystem
creates a new tmpfs instance on GetFilesystem() and populates it with all the
device files.

PiperOrigin-RevId: 578969556
2023-11-02 13:58:58 -07:00
Zach KoopmansandgVisor bot f26a93e634 [syserror] Convert remaining syserror definitions to linuxerr.
Convert remaining public errors (e.g. EINTR) from syserror to linuxerr.

PiperOrigin-RevId: 390471763
2021-08-12 15:19:12 -07:00
Adin ScannellandgVisor bot 75df87e081 Add basic stateify annotations.
Updates #1663

PiperOrigin-RevId: 333539293
2020-09-24 10:13:04 -07:00
Ayush RanjanandgVisor bot 23c69cd610 [vfs] Return EIO when opening /dev/tty.
This is in compliance with VFS1. See pkg/sentry/fs/dev/tty.go in the struct
ttyInodeOperations.

Fixes the failure of python runtime test_ioctl.
Updates #3515

PiperOrigin-RevId: 327042758
2020-08-17 10:05:43 -07:00
Nayana BidariandgVisor bot 4a8d0d3f20 Plumbing context.Context to DecRef() and Release().
context is passed to DecRef() and Release() which is
needed for SO_LINGER implementation.

PiperOrigin-RevId: 324672584
2020-08-03 13:36:05 -07:00
Nicolas LacasseandgVisor bot 966d2e6930 Port /dev/tty device to VFS2.
Support is limited to the functionality that exists in VFS1.

Updates #2923 #1035

PiperOrigin-RevId: 317981417
2020-06-23 18:48:37 -07:00