Commit Graph

1311 Commits

Author SHA1 Message Date
Nicolas Lacasse d0b1d0233d Move pkg/sentry/vfs/{eventfd,timerfd} to new packages in pkg/sentry/fsimpl.
They don't depend on anything in VFS2, so they should be their own packages.

PiperOrigin-RevId: 310416807
2020-05-07 12:44:03 -07:00
Nicolas Lacasse 26c60d7d5d Port signalfd to vfs2.
PiperOrigin-RevId: 310404113
2020-05-07 11:41:50 -07:00
Dean Deng 16da7e790f Update privateunixsocket TODOs.
Synthetic sockets do not have the race condition issue in VFS2, and we will
get rid of privateunixsocket as well.

Fixes #1200.

PiperOrigin-RevId: 310386474
2020-05-07 10:20:48 -07:00
Dean Deng e0089a20e4 Remove outdated TODO for VFS2 AccessAt.
Fixes #1965.

PiperOrigin-RevId: 310380433
2020-05-07 09:53:52 -07:00
gVisor bot feece24bf5 Merge pull request #2570 from lubinszARM:pr_clean
PiperOrigin-RevId: 310259686
2020-05-06 17:19:55 -07:00
Jamie Liu 7cd54c1f14 Remove vfs.FileDescriptionOptions.InvalidWrite.
Compare:
https://elixir.bootlin.com/linux/v5.6/source/fs/timerfd.c#L431
PiperOrigin-RevId: 310246908
2020-05-06 16:08:12 -07:00
Adin Scannell 279f1eb7ab Fix runsc syscall documentation generation.
We can register any number of tables with any number of architectures, and
need not limit the definitions to the architecture in question. This allows
runsc to generate documentation for all architectures simultaneously.

Similarly, this simplifies the VFSv2 patching process.

PiperOrigin-RevId: 310224827
2020-05-06 14:13:48 -07:00
Nicolas Lacasse 591ff0e424 Add maximum memory limit.
PiperOrigin-RevId: 310179277
2020-05-06 10:30:18 -07:00
gVisor bot 8416da33d2 Internal change.
PiperOrigin-RevId: 310057834
2020-05-05 17:58:47 -07:00
Dean Deng faf89dd31a Update vfs2 socket TODOs.
Three updates:
- Mark all vfs2 socket syscalls as supported.
- Use the same dev number and ino number generator for all types of sockets,
  unlike in VFS1.
- Do not use host fd for hostinet metadata.

Fixes #1476, #1478, #1484, 1485, #2017.

PiperOrigin-RevId: 309994579
2020-05-05 12:11:14 -07:00
Dean Deng a6dbf9596d Update comments for synthetic gofer files in vfs2.
PiperOrigin-RevId: 309966538
2020-05-05 10:01:28 -07:00
Fabricio Voznika b3bd41434c Return correct name for imported host files
Implement PrependPath() in host.filesystem to correctly format
name for host files.

Updates #1672

PiperOrigin-RevId: 309959135
2020-05-05 09:21:14 -07:00
Jamie Liu 35951c3671 Translate p9.NoUID/GID to OverflowUID/GID.
p9.NoUID/GID (== uint32(-1) == auth.NoID) is not a valid auth.KUID/KGID; in
particular, using it for file ownership causes capabilities to be ineffective
since file capabilities require that the file's KUID and KGID are mapped into
the capability holder's user namespace [1], and auth.NoID is not mapped into
any user namespace. Map p9.NoUID/GID to a different, valid KUID/KGID; in the
unlikely case that an application actually using the overflow KUID/KGID
attempts an operation that is consequently permitted by client permission
checks, the remote operation will still fail with EPERM.

Since this changes the VFS2 gofer client to no longer ignore the invalid IDs
entirely, this CL both permits and requires that we change synthetic mount point
creation to use root credentials.

[1] See fs.Inode.CheckCapability or vfs.GenericCheckPermissions.

PiperOrigin-RevId: 309856455
2020-05-05 09:19:52 -07:00
Nicolas Lacasse da71dc7fdd Port eventfd to VFS2.
And move sys_timerfd.go to just timerfd.go for consistency.

Updates #1475.

PiperOrigin-RevId: 309835029
2020-05-04 16:02:07 -07:00
Fabricio Voznika 57dbd7f362 Remove kernfs.Filesystem cast from GenericDirectoryFD
This allows for kerfs.Filesystem to be overridden by
different implementations.

Updates #1672

PiperOrigin-RevId: 309809321
2020-05-04 13:40:37 -07:00
gVisor bot 711439b1c3 Merge pull request #2275 from nybidari:iptables
PiperOrigin-RevId: 309783486
2020-05-04 11:23:55 -07:00
Fabricio Voznika cbc5bef2a6 Add TTY support on VFS2 to runsc
Updates #1623, #1487

PiperOrigin-RevId: 309777922
2020-05-04 10:59:20 -07:00
Adin Scannell 2c986870e3 Fix flaky monotonic time.
This change ensures that even platforms with some TSC issues (e.g. KVM),
can get reliable monotonic time by applied a lower bound on each read.

PiperOrigin-RevId: 309773801
2020-05-04 10:40:51 -07:00
Nayana Bidari b660f16d18 Support for connection tracking of TCP packets.
Connection tracking is used to track packets in prerouting and
output hooks of iptables. The NAT rules modify the tuples in
connections. The connection tracking code modifies the packets by
looking at the modified tuples.
2020-05-01 16:59:40 -07:00
Kevin Krakauer 5e1e61fbcb Automated rollback of changelist 308674219
PiperOrigin-RevId: 309491861
2020-05-01 16:09:53 -07:00
Dean Deng 82bae30cee Port netstack, hostinet, and netlink sockets to VFS2.
All three follow the same pattern:
1. Refactor VFS1 sockets into socketOpsCommon, so that most of the methods can
   be shared with VFS2.
2. Create a FileDescriptionImpl with the corresponding socket operations,
   rewriting the few that cannot be shared with VFS1.
3. Set up a VFS2 socket provider that creates a socket by setting up a dentry
   in the global Kernel.socketMount and connecting it with a new
   FileDescription.

This mostly completes the work for porting sockets to VFS2, and many syscall
tests can be enabled as a result.
There are several networking-related syscall tests that are still not passing:
1. net gofer tests
2. socketpair gofer tests
2. sendfile tests (splice is not implemented in VFS2 yet)

Updates #1478, #1484, #1485

PiperOrigin-RevId: 309457331
2020-05-01 12:54:41 -07:00
Jamie Liu 01beec3bb4 Add gofer.InternalFilesystemOptions.LeakConnection.
PiperOrigin-RevId: 309317605
2020-04-30 16:04:21 -07:00
Nicolas Lacasse bae30a0c69 Implement waiter.Waitable methods on VFS2 host inodes.
This fixes bash in Ubuntu.

Updates #1672.

PiperOrigin-RevId: 309298252
2020-04-30 14:19:45 -07:00
Dean Deng 442fde405d Fix proc net bugs in VFS2.
The /proc/net/udp header was missing, and /proc/sys/net was set up as
/proc/sys/net/net. Discovered while trying to run networking tests for VFS2.

PiperOrigin-RevId: 309243758
2020-04-30 09:48:00 -07:00
Dean Deng ef94401955 Add read/write timeouts for VFS2 socket files.
Updates #1476

PiperOrigin-RevId: 309098590
2020-04-29 14:35:43 -07:00
Kevin Krakauer a105d185ff iptables: don't pollute logs
The netfilter package uses logs to make debugging the (de)serialization of
structs easier. This generates a lot of (usually irrelevant) logs. Logging is
now hidden behind a debug flag.

PiperOrigin-RevId: 309087115
2020-04-29 13:38:14 -07:00
Dean Deng ce19497c1c Fix Unix socket permissions.
Enforce write permission checks in BoundEndpointAt, which corresponds to the
permission checks in Linux (net/unix/af_unix.c:unix_find_other).
Also, create bound socket files with the correct permissions in VFS2.

Fixes #2324.

PiperOrigin-RevId: 308949084
2020-04-28 20:13:01 -07:00
Dean Deng f93f2fda74 Deduplicate unix socket Release() method.
PiperOrigin-RevId: 308932254
2020-04-28 17:43:14 -07:00
Dean Deng f3ca5ca82a Support pipes and sockets in VFS2 gofer fs.
Named pipes and sockets can be represented in two ways in gofer fs:
1. As a file on the remote filesystem. In this case, all file operations are
   passed through 9p.
2. As a synthetic file that is internal to the sandbox. In this case, the
   dentry stores an endpoint or VFSPipe for sockets and pipes respectively,
   which replaces interactions with the remote fs through the gofer.
In gofer.filesystem.MknodAt, we attempt to call mknod(2) through 9p,
and if it fails, fall back to the synthetic version.

Updates #1200.

PiperOrigin-RevId: 308828161
2020-04-28 08:34:00 -07:00
Bin Lu 44d780aa4b code clean in arch module
Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-04-28 01:15:43 -04:00
Dean Deng 1c2ecbb1a0 Import host sockets.
The FileDescription implementation for hostfs sockets uses the standard Unix
socket implementation (unix.SocketVFS2), but is also tied to a hostfs dentry.

Updates #1672, #1476

PiperOrigin-RevId: 308716426
2020-04-27 16:02:18 -07:00
Fabricio Voznika 003e79a6d1 Dump stack for stuck start and stuck watchdog
The meaning for skipDump was reversed, but not all callers
were updated. Change the meaning once again to forceDump, so
that the period between stack dump is respected from all
callers.

PiperOrigin-RevId: 308674373
2020-04-27 12:30:49 -07:00
gVisor bot 55f0c3316a Automated rollback of changelist 308163542
PiperOrigin-RevId: 308674219
2020-04-27 12:26:32 -07:00
Jamie Liu 292f3f99b7 Don't leak vfs.MountNamespace reference if kernel.TaskSet.NewTask fails.
PiperOrigin-RevId: 308617610
2020-04-27 07:39:10 -07:00
Rahat Mahmood 3c67754663 Enable automated marshalling for signals and the arch package.
PiperOrigin-RevId: 308472331
2020-04-25 23:56:04 -07:00
Zach Koopmans 15a822a193 VFS2: Get HelloWorld image tests to pass with VFS2
This change includes:
- Modifications to loader_test.go to get TestCreateMountNamespace to
pass with VFS2.
- Changes necessary to get TestHelloWorld in image tests to pass with
VFS2. This means runsc can run the hello-world container with docker
on VSF2.

Note: Containers that use sockets will not run with these changes.
See "//test/image/...". Any tests here with sockets currently fail
(which is all of them but HelloWorld).
PiperOrigin-RevId: 308363072
2020-04-24 18:23:37 -07:00
gVisor bot 10725475c3 Merge pull request #1707 from lubinszARM:pr_lazy_fpsimd_2
PiperOrigin-RevId: 308347744
2020-04-24 16:23:16 -07:00
Dean Deng f13f26d17d Port SCM Rights to VFS2.
Fixes #1477.

PiperOrigin-RevId: 308317511
2020-04-24 13:46:58 -07:00
Dean Deng 632b104aff Plumb context.Context into kernfs.Inode.Open().
PiperOrigin-RevId: 308304793
2020-04-24 12:37:49 -07:00
Fabricio Voznika 2cc0fd42f4 Fixes for procfs
- Return ENOENT for /proc/[pid]/task if task is zoombied or terminated
- Allow directory to be Seek() to the end
- Construct synthetic files for /proc/[pid]/ns/*
- Changed GenericDirectoryFD.Init to not register with FileDescription,
  otherwise other implementation cannot change behavior.

Updates #1195,1193

PiperOrigin-RevId: 308294649
2020-04-24 11:45:19 -07:00
Dean Deng 1b88c63b3e Move hostfs mount to Kernel struct.
This is needed to set up host fds passed through a Unix socket. Note that
the host package depends on kernel, so we cannot set up the hostfs mount
directly in Kernel.Init as we do for sockfs and pipefs.

Also, adjust sockfs to make its setup look more like hostfs's and pipefs's.

PiperOrigin-RevId: 308274053
2020-04-24 10:03:43 -07:00
Dean Deng 40a712c57c Refactor syscall.Fstat calls in hostfs.
Just call syscall.Fstat directly each time mode/file owner are needed. This
feels more natural than using i.getPermissions().

PiperOrigin-RevId: 308257405
2020-04-24 08:20:28 -07:00
Rahat Mahmood f01f2132d8 Enable automated marshalling for mempolicy syscalls.
PiperOrigin-RevId: 308170679
2020-04-23 18:20:21 -07:00
Nicolas Lacasse 696feaf10c Port devpts to VFS2.
PiperOrigin-RevId: 308164359
2020-04-23 17:34:29 -07:00
Kevin Krakauer eccae0f77d Remove View.First() and View.RemoveFirst()
These methods let users eaily break the VectorisedView abstraction, and
allowed netstack to slip into pseudo-enforcement of the "all headers are
in the first View" invariant. Removing them and replacing with PullUp(n)
breaks this reliance and will make it easier to add iptables support and
rework network buffer management.

The new View.PullUp(n) method is low cost in the common case, when when
all the headers fit in the first View.

PiperOrigin-RevId: 308163542
2020-04-23 17:28:49 -07:00
Rahat Mahmood 93dd471461 Enable automated marshalling for epoll events.
Ensure we use the correct architecture-specific defintion of epoll
event, and use go-marshal for serialization.

PiperOrigin-RevId: 308145677
2020-04-23 15:49:05 -07:00
Jamie Liu 5042ea7e2c Add vfs.MkdirOptions.ForSyntheticMountpoint.
PiperOrigin-RevId: 308143529
2020-04-23 15:37:10 -07:00
gVisor bot ded5c963ae Merge pull request #1819 from lubinszARM:pr_signal_2
PiperOrigin-RevId: 308100771
2020-04-23 12:01:38 -07:00
Adin Scannell 1481499fe2 Simplify Docker test infrastructure.
This change adds a layer of abstraction around the internal Docker APIs,
and eliminates all direct dependencies on Dockerfiles in the infrastructure.

A subsequent change will automated the generation of local images (with
efficient caching). Note that this change drops the use of bazel container
rules, as that experiment does not seem to be viable.

PiperOrigin-RevId: 308095430
2020-04-23 11:33:30 -07:00
Jamie Liu e0c67014cb Factor fsimpl/gofer.host{Preadv,Pwritev} out of fsimpl/gofer.
Also fix returning EOF when 0 bytes are read.

PiperOrigin-RevId: 308089875
2020-04-23 11:08:24 -07:00