Commit Graph

1090 Commits

Author SHA1 Message Date
Adin Scannell 6def8ea6ac Fix nested logging.
PiperOrigin-RevId: 297175316
2020-02-25 12:25:38 -08:00
Adin Scannell 98b693e61b Don't acquire contended lock with the OS thread locked.
Fixes #1049

PiperOrigin-RevId: 297175164
2020-02-25 12:22:29 -08:00
Adin Scannell 53504e29ca Fix mount refcount issue.
Each mount is holds a reference on a root Dirent, but the mount itself may
live beyond it's own reference. This means that a call to Root() can come
after the associated reference has been dropped.

Instead of introducing a separate layer of references for mount objects,
we simply change the Root() method to use TryIncRef() and allow it to return
nil if the mount is already gone. This requires updating a small number of
callers and minimizes the change (since VFSv2 will replace this code shortly).

PiperOrigin-RevId: 297174230
2020-02-25 12:17:52 -08:00
Ting-Yu Wang b8f56c79be Implement tap/tun device in vfs.
PiperOrigin-RevId: 296526279
2020-02-21 15:42:56 -08:00
gVisor bot 4a73bae269 Initial network namespace support.
TCP/IP will work with netstack networking. hostinet doesn't work, and sockets
will have the same behavior as it is now.

Before the userspace is able to create device, the default loopback device can
be used to test.

/proc/net and /sys/net will still be connected to the root network stack; this
is the same behavior now.

Issue #1833

PiperOrigin-RevId: 296309389
2020-02-20 15:20:40 -08:00
gVisor bot d90d71474f Remove bytes read/written from marshal.Marshallable API.
Users of the API only care about whether the copy in/out succeeds in
their entirety, which is already signalled by the returned error.

PiperOrigin-RevId: 296297843
2020-02-20 14:29:26 -08:00
gVisor bot 9bad87339a Better strace logging for epoll syscalls.
Example:

epoll_ctl(0x3 anon_inode:[eventpoll], EPOLL_CTL_ADD, 0x6 anon_inode:[eventfd], 0x7efe2fd92a80 {events=EPOLLIN|EPOLLOUT data=0x10203040506070a}) = 0x0 (4.411µs)

epoll_wait(0x3 anon_inode:[eventpoll], 0x7efe2fd92b50 {{events=EPOLLOUT data=0x102030405060708}{events=EPOLLOUT data=0x102030405060708}{events=EPOLLOUT data=0x102030405060708}}, 0x3, 0xffffffff) = 0x3 (29.891µs)

PiperOrigin-RevId: 296258146
2020-02-20 11:31:00 -08:00
gVisor bot 10ed60e477 VFS2: Support memory mapping in tmpfs.
tmpfs.fileDescription now implements ConfigureMMap. And tmpfs.regularFile
implement memmap.Mappable. The methods are mostly unchanged from VFS1 tmpfs.

PiperOrigin-RevId: 296234557
2020-02-20 09:58:10 -08:00
gVisor bot 2daa21e4d7 Internal change.
PiperOrigin-RevId: 296088213
2020-02-19 16:48:57 -08:00
gVisor bot 56fd9504aa Enable IPV6_RECVTCLASS socket option for datagram sockets
Added the ability to get/set the IP_RECVTCLASS socket option on UDP endpoints.
If enabled, traffic class from the incoming Network Header passed as ancillary
data in the ControlMessages.

Adding Get/SetSockOptBool to decrease the overhead of getting/setting simple
options. (This was absorbed in a CL that will be landing before this one).

Test:
* Added unit test to udp_test.go that tests getting/setting as well as
verifying that we receive expected TOS from incoming packet.
* Added a syscall test for verifying getting/setting
* Removed test skip for existing syscall test to enable end to end test.
PiperOrigin-RevId: 295840218
2020-02-18 15:45:36 -08:00
gVisor bot 906eb6295d atomicbitops package cleanups
- Redocument memory ordering from "no ordering" to "acquire-release". (No
  functional change: both LOCK WHATEVER on x86, and LDAXR/STLXR loops on ARM64,
  already have this property.)

- Remove IncUnlessZeroInt32 and DecUnlessOneInt32, which were only faster than
  the equivalent loops using sync/atomic before the Go compiler inlined
  non-unsafe.Pointer atomics many releases ago.

PiperOrigin-RevId: 295811743
2020-02-18 13:43:28 -08:00
gVisor bot 7fdb609b3e Merge pull request #1850 from kevinGC:jump2
PiperOrigin-RevId: 295785052
2020-02-18 11:41:54 -08:00
gVisor bot fae3de21af ring0/pagetables: fix typo
PiperOrigin-RevId: 295770717
2020-02-18 10:50:46 -08:00
gVisor bot a5069f820f Remove linux.EpollEvent.Fd.
glibc defines struct epoll_event in such a way that epoll_event.data.fd exists.
However, the kernel's definition of struct epoll_event makes epoll_event.data
an opaque uint64, so naming half of it "fd" just introduces confusion. Remove
the Fd field, and make Data a [2]int32 to compensate.

Also add required padding to linux.EpollEvent on ARM64.

PiperOrigin-RevId: 295250424
2020-02-14 16:19:48 -08:00
gVisor bot 5baf9dc2fb Synchronize signalling with S/R
This is to fix a data race between sending an external signal to
a ThreadGroup and kernel saving state for S/R.

PiperOrigin-RevId: 295244281
2020-02-14 15:49:09 -08:00
gVisor bot 3557b26651 Allow vfs.IterDirentsCallback.Handle() to return an error.
This is easier than storing errors from e.g. CopyOut in the callback.

PiperOrigin-RevId: 295230021
2020-02-14 14:40:35 -08:00
gVisor bot 87bc2834c9 Enable automated marshalling for RSeqCriticalSection.
PiperOrigin-RevId: 295226468
2020-02-14 14:24:27 -08:00
gVisor bot e4c7f3e6f6 Inline vfs.VirtualFilesystem in Kernel struct
This saves one pointer dereference per VFS access.

Updates #1623

PiperOrigin-RevId: 295216176
2020-02-14 13:40:39 -08:00
gVisor bot 3c26f5ecb0 Enable automated marshalling for struct stat.
This requires fixing a few build issues for non-am64 platforms.

PiperOrigin-RevId: 295196922
2020-02-14 12:08:12 -08:00
gVisor bot 4075de11be Plumb VFS2 inside the Sentry
- Added fsbridge package with interface that can be used to open
  and read from VFS1 and VFS2 files.
- Converted ELF loader to use fsbridge
- Added VFS2 types to FSContext
- Added vfs.MountNamespace to ThreadGroup

Updates #1623

PiperOrigin-RevId: 295183950
2020-02-14 11:12:47 -08:00
gVisor bot a6024f7f5f Add FileExec flag to OpenOptions
This allow callers to say whether the file is being
opened to be executed, so that the proper checks can
be done from FilesystemImpl.OpenAt()

Updates #1623

PiperOrigin-RevId: 295042595
2020-02-13 17:57:36 -08:00
Kevin Krakauer 6ef63cd7da We can now create and jump in iptables. For example:
$ iptables -N foochain
$ iptables -A INPUT -j foochain
2020-02-13 17:02:50 -08:00
gVisor bot 16308b9dc1 Merge pull request #1791 from kevinGC:uchains
PiperOrigin-RevId: 294957297
2020-02-13 11:19:09 -08:00
gVisor bot 69bf39e8a4 Internal change.
PiperOrigin-RevId: 294952610
2020-02-13 10:59:52 -08:00
Kevin Krakauer 6fdf2c53a1 iptables: User chains
- Adds creation of user chains via `-N <chainname>`
- Adds `-j RETURN` support for built-in chains, which triggers the
  chain's underflow rule (usually the default policy).
- Adds tests for chain creation, default policies, and `-j RETURN' from
  built-in chains.
2020-02-12 15:02:47 -08:00
gVisor bot 6dced977ea Ensure fsimpl/gofer.dentryPlatformFile.hostFileMapper is initialized.
Fixes #1812. (The more direct cause of the deadlock is panic unsafety because
the historically high cost of defer means that we avoid it in hot paths,
including much of MM; defer is much cheaper as of Go 1.14, but still a
measurable overhead.)

PiperOrigin-RevId: 294560316
2020-02-11 17:38:57 -08:00
Adin Scannell 115898e368 Prevent DATA RACE in UnstableAttr.
The slaveInodeOperations is currently copying the object when
truncate is called (which is a no-op). This may result in a
(unconsequential) data race when being modified concurrently.

PiperOrigin-RevId: 294484276
2020-02-11 11:38:08 -08:00
gVisor bot 762e4761cc Move Align{Up,Down} into binary package.
PiperOrigin-RevId: 294477647
2020-02-11 11:09:31 -08:00
gVisor bot 0dd9ee0d1e Merge pull request #1775 from kevinGC:tcp-matchers-submit
PiperOrigin-RevId: 294340468
2020-02-10 17:21:13 -08:00
Adin Scannell 71af006b6f Cleanup internal package group.
PiperOrigin-RevId: 294339229
2020-02-10 17:12:59 -08:00
Dean Deng 475316e87d Refactor getxattr.
Put most of the logic for getxattr in one place for clarity. This simplifies
FGetXattr and getXattrFromPath, which are just wrappers for getXattr.

PiperOrigin-RevId: 294308332
2020-02-10 14:47:47 -08:00
Adin Scannell 2889ffa84e Add context to note.
PiperOrigin-RevId: 294300040
2020-02-10 14:11:52 -08:00
Adin Scannell a6f9361c2f Add context to comments.
PiperOrigin-RevId: 294295852
2020-02-10 13:52:09 -08:00
Adin Scannell bb22ebd7fb Add contextual comment.
PiperOrigin-RevId: 294289066
2020-02-10 13:21:30 -08:00
Adin Scannell 4d4d47f0c0 Add contextual note.
PiperOrigin-RevId: 294285723
2020-02-10 13:05:27 -08:00
Adin Scannell c9a18b16ad Document MinimumTotalMemoryBytes.
PiperOrigin-RevId: 294273559
2020-02-10 12:08:32 -08:00
Fabricio Voznika bfa0bba72a Redirect FIXME to gvisor.dev
PiperOrigin-RevId: 294272755
2020-02-10 12:04:38 -08:00
Brad Burlage 20840bfec0 Move x86 state definition to its own file.
PiperOrigin-RevId: 294271541
2020-02-10 12:00:46 -08:00
Dean Deng 17b9f5e662 Support listxattr and removexattr syscalls.
Note that these are only implemented for tmpfs, and other impls will still
return EOPNOTSUPP.

PiperOrigin-RevId: 293899385
2020-02-07 14:47:13 -08:00
Ian Gudger e1587a2887 Log level, optname, optval and optlen in getsockopt/setsockopt in strace.
Log 8, 16, and 32 int optvals and dump the memory of other sizes.

Updates #1782

PiperOrigin-RevId: 293889388
2020-02-07 14:01:47 -08:00
Kevin Krakauer c141eb5f43 Address GH comments. 2020-02-07 13:47:57 -08:00
Kevin Krakauer d98287f5eb Merge branch 'master' into tcp-matchers-submit 2020-02-06 17:07:04 -08:00
Adin Scannell 1b6a12a768 Add notes to relevant tests.
These were out-of-band notes that can help provide additional context
and simplify automated imports.

PiperOrigin-RevId: 293525915
2020-02-05 22:46:35 -08:00
Eyal Soha f3d9560703 recv() on a closed TCP socket returns ENOTCONN
From RFC 793 s3.9 p58 Event Processing:

If RECEIVE Call arrives in CLOSED state and the user has access to such a
connection, the return should be "error: connection does not exist"

Fixes #1598

PiperOrigin-RevId: 293494287
2020-02-05 17:56:42 -08:00
Kevin Krakauer bf0ea204e9 Merge branch 'master' into tcp-matchers-submit 2020-02-05 14:43:11 -08:00
Nicolas Lacasse eea0eeee93 Disable get/set xattrs until list/remove exist too.
PiperOrigin-RevId: 293411655
2020-02-05 11:26:19 -08:00
Ting-Yu Wang 665b614e4a Support RTM_NEWADDR and RTM_GETLINK in (rt)netlink.
PiperOrigin-RevId: 293271055
2020-02-04 18:05:03 -08:00
gVisor bot b29aeebaf6 Merge pull request #1683 from kevinGC:ipt-udp-matchers
PiperOrigin-RevId: 293243342
2020-02-04 16:20:16 -08:00
Michael Pratt 6823b5e244 timer_create(2) should return 0 on success
The timer ID is copied out to the argument.

Fixes #1738

PiperOrigin-RevId: 293210801
2020-02-04 13:27:39 -08:00
Fabricio Voznika dcffddf0ca Remove argument from vfs.MountNamespace.DecRef()
Updates #1035

PiperOrigin-RevId: 293194631
2020-02-04 11:48:36 -08:00