79 Commits
Author SHA1 Message Date
Nicolas LacasseandgVisor bot 8184fa1db0 Clean up devpts code, and deduplicate the foreground process state.
We no longer store the foreground process directly in the terminal. Instead, we
get it from the terminal TTY's ThreadGroup. Added a new method:
tty.SignalForegroundProcessGroup to simplify this.

Cleaned up some things along the way:
* Terminal had a bunch of methods to get/set foreground process group and
  controlling TTY, but those methods were only usable by Ioctl, since they
  read/wrote to syscall arguments. I moved that logic to Ioctl, and deleted the
  methods from Terminal, which is now a very simple type.
* Fixed a bug in ThreadGroud.SetForegroundProcessGroup where we were
  overwriting the ID of an existing process group, rather than setting a new
  process group on the session.
* Simplified the construction of lineDiscipline type.

Reported-by: syzbot+ae5b769cec8ad969c086@syzkaller.appspotmail.com
PiperOrigin-RevId: 512330758
2023-02-25 14:08:58 -08:00
Wim a88680b765 Implement code review remarks 2023-02-23 13:16:56 +01:00
Wim 1dc92a8c71 Add reference to terminal in lineDiscipline 2023-02-22 22:33:37 +01:00
Wim 56458440b3 Support SIGQUIT 2023-02-19 20:00:26 +01:00
Wim a547fffe1e Support some PTY control characters 2023-02-19 17:08:17 +01:00
Lucas ManningandgVisor bot 3c93bb1040 Defer kernfs openflag handling to inode implementations.
Some implementations handle more flags than others, so it doesn't
make sense to have one set of rules for all.

This change should functionally be a no-op.

PiperOrigin-RevId: 502712415
2023-01-17 16:01:40 -08:00
Ayush RanjanandgVisor bot 175db901ca Replace pkg/refs with pkg/refsvfs2.
All VFS1 only bits have been deleted.

Updates #1624

PiperOrigin-RevId: 492273183
2022-12-01 12:46:11 -08:00
Ayush RanjanandgVisor bot 1fa3c06f1e Delete VFS1 completely.
- Delete pkg/sentry/fs/*.
- Move pkg/sentry/fs/fsutil out of VFS1 directory and remove VFS1 components.
- Remove remaining unused references to VFS1 from remaining codebase.
- Rename/refactor code to avoid even referencing VFS2, unless necessary.
- Rewrite VFS1-only tests to VFS2.

Updates #1624

PiperOrigin-RevId: 490064269
2022-11-21 13:57:52 -08:00
Ayush RanjanandgVisor bot 7eeeb796f8 Delete VFS1 filesystem implementations.
Updates #1624

PiperOrigin-RevId: 488986080
2022-11-16 11:05:10 -08:00
Ayush RanjanandgVisor bot bf4d27a6ca Add inotify support to kernfs and anonfs.
This is consistent with Linux. Some applications recursively add
files to inotify FD. They fail if they run into kernfs files
because inotify_add_watch(2) returns EPERM in that case.

PiperOrigin-RevId: 462642204
2022-07-22 09:45:24 -07:00
Ayush RanjanandgVisor bot f6ed4523dc Reformat codebase.
PiperOrigin-RevId: 449358041
2022-05-17 17:48:35 -07:00
Kevin KrakauerandgVisor bot 019e0c9301 use atomicbitops, not sync/atomic, in refsvfs2
Since refsvfs2 are used in netstack, we should use atomicbitops to avoid
breaking 32-bit builds.

On 64-bit builds there is no performance difference.

PiperOrigin-RevId: 439687980
2022-04-05 15:16:01 -07:00
Fabricio VoznikaandgVisor bot dfcf798425 Fix epoll_ctl(2) regular files and dirs
Linux behaves differently for regular files and dirs for poll(2)/select(2)
compared to epoll_ctl(2). The latter returns EPERM for file and dirs.
I've also changed host FDs to behave like the underlying FD in regards
to epoll to keep it compatible with docker.

Fixes #7134

PiperOrigin-RevId: 429412692
2022-02-17 15:12:36 -08:00
Fabricio VoznikaandgVisor bot 9768009a79 Don't eat error from epoll_ctl EPOLL_CTL_ADD
Docker maps stdin to `/dev/null` which doesn't support epoll. Host FD
was ignoring the error and suceeding the epoll_ctl call from the
container, giving false impressing that epoll would be notified.

This required plumbing failure to all waiter.Waitable.EventRegister
callers and implementers.

Closes #6795

PiperOrigin-RevId: 414797621
2021-12-07 12:36:00 -08:00
Adin ScannellandgVisor bot 91f58d2cc8 Update Waitable API.
Instead of passing the event mask at registratrion time, pass the mask as part
of the waiter. This makes the mask immutable and simplifies the architecture of
waiters. This is also necessary for a future fix that will allow the fdnotifier
to keep persistent entries, as opposed to requiring constant updates.

This change is intended to be a no-op in terms of function. The only exception
is signalfd, where this mask was abused. To handle this case, the operation of
signalfd changed to allow one layer of indirection.

PiperOrigin-RevId: 409702998
2021-11-13 12:54:39 -08:00
Zach KoopmansandgVisor bot ce58d71fd5 [syserror] Remove pkg syserror.
Removes package syserror and moves still relevant code to either linuxerr
or to syserr (to be later removed).

Internal errors are converted from random types to *errors.Error types used
in linuxerr. Internal errors are in linuxerr/internal.go.

PiperOrigin-RevId: 390724202
2021-08-13 17:16:52 -07:00
Zach KoopmansandgVisor bot 02370bbd31 [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
Zach KoopmansandgVisor bot e3fdd15932 [syserror] Update syserror to linuxerr for more errors.
Update the following from syserror to the linuxerr equivalent:
EEXIST
EFAULT
ENOTDIR
ENOTTY
EOPNOTSUPP
ERANGE
ESRCH

PiperOrigin-RevId: 384329869
2021-07-12 15:26:20 -07:00
Etienne PerotandgVisor bot 07f2c8b56b devpts: Notify of echo'd input queue bytes only after locks have been released.
PiperOrigin-RevId: 383684320
2021-07-08 12:04:56 -07:00
Zach KoopmansandgVisor bot 54b71221c0 [syserror] Change syserror to linuxerr for E2BIG, EADDRINUSE, and EINVAL
Remove three syserror entries duplicated in linuxerr. Because of the
linuxerr.Equals method, this is a mere change of return values from
syserror to linuxerr definitions.

Done with only these three errnos as CLs removing all grow to a significantly
large size.

PiperOrigin-RevId: 382173835
2021-06-29 15:08:46 -07:00
Bhasker HariharanandgVisor bot e7ca2a51a8 Add POLLRDNORM/POLLWRNORM support.
On Linux these are meant to be equivalent to POLLIN/POLLOUT. Rather
than hack these on in sys_poll etc it felt cleaner to just cleanup
the call sites to notify for both events. This is what linux does
as well.

Fixes #5544

PiperOrigin-RevId: 364859977
2021-03-24 12:11:44 -07:00
Rahat MahmoodandgVisor bot c5667022b6 Report filesystem-specific mount options.
PiperOrigin-RevId: 362406813
2021-03-11 16:49:36 -08:00
Kevin KrakauerandgVisor bot ae8d966f5a Assign controlling terminal when tty is opened and support NOCTTY
PiperOrigin-RevId: 357015186
2021-02-11 11:09:22 -08:00
Dean DengandgVisor bot 55332aca95 Move Lock/UnlockPOSIX into LockFD util.
PiperOrigin-RevId: 352904728
2021-01-20 16:55:07 -08:00
Dean DengandgVisor bot 0fb5353e45 Initialize references with a value of 1.
This lets us avoid treating a value of 0 as one reference. All references
using the refsvfs2 template must call InitRefs() before the reference is
incremented/decremented, or else a panic will occur. Therefore, it should be
pretty easy to identify missing InitRef calls during testing.

Updates #1486.

PiperOrigin-RevId: 341411151
2020-11-09 08:33:17 -08:00