Commit Graph

5083 Commits

Author SHA1 Message Date
gVisor bot cab13958a5 Merge release-20200608.0-118-g399c52888 (automated) 2020-06-24 03:08:21 +00:00
Dean Deng 399c52888d Resolve remaining inotify TODOs.
Also refactor HandleDeletion().

Updates #1479.

PiperOrigin-RevId: 317989000
2020-06-23 20:05:28 -07:00
gVisor bot 02d43f5e75 Merge release-20200608.0-117-g2189e0a66 (automated) 2020-06-24 02:28:05 +00:00
Dean Deng 2189e0a660 Clean up hostfs TODOs.
This CL does a handful of things:
- Support O_DSYNC, O_SYNC
- Support O_APPEND and document an unavoidable race condition
- Ignore O_DIRECT; we probably don't want to allow applications to set O_DIRECT
  on the host fd itself.
- Leave a TODO for supporting O_NONBLOCK, which is a simple fix once RWF_NOWAIT
  is supported.
- Get rid of caching TODO; force_page_cache is not configurable for host fs in
  vfs1 or vfs2 after whitelist fs was removed.
- For the remaining TODOs, link to more specific bugs.

Fixes #1672.

PiperOrigin-RevId: 317985269
2020-06-23 19:24:43 -07:00
gVisor bot db49edb581 Merge release-20200608.0-116-g2141013dc (automated) 2020-06-24 02:19:18 +00:00
Ian Gudger 2141013dce Add support for SO_REUSEADDR to TCP sockets/endpoints.
For TCP sockets, SO_REUSEADDR relaxes the rules for binding addresses.

gVisor/netstack already supported a behavior similar to SO_REUSEADDR, but did
not allow disabling it. This change brings the SO_REUSEADDR behavior closer to
the behavior implemented by Linux and adds a new SO_REUSEADDR disabled
behavior. Like Linux, SO_REUSEADDR is now disabled by default.

PiperOrigin-RevId: 317984380
2020-06-23 19:15:38 -07:00
gVisor bot 05071f759f Merge release-20200608.0-115-g0f328beb0 (automated) 2020-06-24 01:51:35 +00:00
Nicolas Lacasse 0f328beb0d 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
gVisor bot a68597c504 Merge release-20200608.0-114-g65a587ded (automated) 2020-06-24 01:35:38 +00:00
Dean Deng 65a587dedf Complete inotify IN_EXCL_UNLINK implementation in VFS2.
Events were only skipped on parent directories after their children were
unlinked; events on the unlinked file itself need to be skipped as well.

As a result, all Watches.Notify() calls need to know whether the dentry where
the call came from was unlinked.

Updates #1479.

PiperOrigin-RevId: 317979476
2020-06-23 18:33:04 -07:00
gVisor bot 31c8bed739 Merge release-20200608.0-113-gacf519a77 (automated) 2020-06-24 00:48:48 +00:00
Ting-Yu Wang acf519a77b Nit fix: Create and use a std::string object for `const char*`.
PiperOrigin-RevId: 317973144
2020-06-23 17:44:34 -07:00
gVisor bot 6cc57634d5 Merge release-20200608.0-112-g0c628c315 (automated) 2020-06-23 23:17:59 +00:00
Dean Deng 0c628c3152 Support inotify in vfs2 gofer fs.
Because there is no inode structure stored in the sandbox, inotify watches
must be held on the dentry. This would be an issue in the presence of hard
links, where multiple dentries would need to share the same set of watches,
but in VFS2, we do not support the internal creation of hard links on gofer
fs. As a result, we make the assumption that every dentry corresponds to a
unique inode.

Furthermore, dentries can be cached and then evicted, even if the underlying
file has not be deleted. We must prevent this from occurring if there are any
watches that would be lost. Note that if the dentry was deleted or invalidated
(d.vfsd.IsDead()), we should still destroy it along with its watches.

Additionally, when a dentry’s last watch is removed, we cache it if it also
has zero references. This way, the dentry can eventually be evicted from
memory if it is no longer needed. This is accomplished with a new dentry
method, OnZeroWatches(), which is called by Inotify.RmWatch and
Inotify.Release. Note that it must be called after all inotify locks are
released to avoid violating lock order. Stress tests are added to make sure
that inotify operations don't deadlock with gofer.OnZeroWatches.

Updates #1479.

PiperOrigin-RevId: 317958034
2020-06-23 16:14:56 -07:00
gVisor bot bb7e27b64d Merge release-20200608.0-111-g793edf4cb (automated) 2020-06-23 23:10:04 +00:00
Ting-Yu Wang 793edf4cb4 Deflake proc test: Don't fail on DT_UNKNOWN.
Per manual page:
"All applications must properly handle a return of DT_UNKNOWN."

PiperOrigin-RevId: 317957013
2020-06-23 16:07:26 -07:00
gVisor bot e746298f06 Merge release-20200608.0-110-gedea9a8d0 (automated) 2020-06-23 21:56:32 +00:00
Nicolas Lacasse edea9a8d02 Port readahead to VFS2.
It preserves the same functionality (almost none) as in VFS1.

Updates #2923 #1035

PiperOrigin-RevId: 317943522
2020-06-23 14:53:33 -07:00
gVisor bot 881d924f39 Merge release-20200608.0-109-gca1bc46f1 (automated) 2020-06-23 21:45:26 +00:00
gVisor bot ca1bc46f15 Internal change.
PiperOrigin-RevId: 317941748
2020-06-23 14:42:15 -07:00
gVisor bot a927feb094 Merge release-20200608.0-108-g44dd65ce1 (automated) 2020-06-23 20:59:45 +00:00
gVisor bot 44dd65ce1e Merge pull request #2272 from lubinszARM:pr_serr_injection
PiperOrigin-RevId: 317933650
2020-06-23 13:53:56 -07:00
gVisor bot 94040b1d6f Merge release-20200608.0-106-g38d7b2fe5 (automated) 2020-06-23 04:33:28 +00:00
Dean Deng 38d7b2fe56 Only allow regular files, sockets, pipes, and char devices to be imported.
PiperOrigin-RevId: 317796028
2020-06-22 21:30:54 -07:00
gVisor bot 788f83505a Merge release-20200608.0-105-gc9e697806 (automated) 2020-06-22 23:39:30 +00:00
Ayush Ranjan c9e6978062 Fix the way PR build clones gVisor.
Copybara force-pushes to the PR immediately before merging which triggers a PR
build. Since the PR is merged, the refspec +refs/pull/{pr_num}/merge is not
available and the build fails causing all master commit CI builds to show a
failure.

This change remove the clone step from travis and clone manually in a way
which always would succeed. We fetch +refs/pull/{pr_num}/head and cherry pick
that onto the target branch.

I have tested this in https://github.com/ayushr2/gvisor/pull/1 and
https://github.com/ayushr2/gvisor/pull/2.

PiperOrigin-RevId: 317759891
2020-06-22 16:36:52 -07:00
gVisor bot ccdba983c5 Merge release-20200608.0-104-g4573e7d86 (automated) 2020-06-22 18:43:09 +00:00
Dean Deng 4573e7d863 Check for invalid trailing / when traversing path in gofer OpenAt.
Updates #2923.

PiperOrigin-RevId: 317700049
2020-06-22 11:39:41 -07:00
gVisor bot 160edcbf44 Merge release-20200608.0-103-g282a6aea1 (automated) 2020-06-22 17:34:24 +00:00
Bruno Dal Bo 282a6aea1b Extract common nested LinkEndpoint pattern
... and unify logic for detached netsted endpoints.

sniffer.go caused crashes if a packet delivery is attempted when the dispatcher
is nil.

Extracted the endpoint nesting logic into a common composable type so it can be
used by the Fuchsia Netstack (the pattern is widespread there).

PiperOrigin-RevId: 317682842
2020-06-22 10:31:45 -07:00
gVisor bot 5dc2c5ea84 Merge release-20200608.0-102-ga480b4faf (automated) 2020-06-22 16:57:09 +00:00
Nicolas Lacasse a480b4faf4 Allow readdir(/proc/[tid]/net) to return EINVAL on a zombie task.
Despite what the man page says, linux will return EINVAL when calling
getdents() an a /proc/[tid]/net file corresponding to a zombie task. This
causes readdir() to return a null pointer AND errno=EINVAL.

See fs/proc/proc_net.c:proc_tgid_net_readdir() for where this occurs.

We have tests that recursively read /proc, and are likely to hit this when
running natively, so we must catch and handle this case.

PiperOrigin-RevId: 317674168
2020-06-22 09:54:22 -07:00
gVisor bot aff762b156 Merge release-20200608.0-101-g00928d142 (automated) 2020-06-22 04:56:15 +00:00
Dean Deng 00928d142d Fix vfs2 extended attributes.
Correct behavior when given zero size arguments and trying to set user.* xattrs
on files other than regular files or directories.

Updates #2923.

PiperOrigin-RevId: 317590409
2020-06-21 21:48:19 -07:00
gVisor bot fa6566267d Merge release-20200608.0-100-gf46f4a2af (automated) 2020-06-20 01:30:49 +00:00
Dean Deng f46f4a2af9 Enable passing vfs2 tests.
I forgot to update getdents earlier. Several thousand runs of the fsync and
proc_net_unix tests all passed as well.

Updates #2923.

PiperOrigin-RevId: 317415488
2020-06-19 18:27:29 -07:00
gVisor bot 6fc5c7d531 Merge release-20200608.0-99-gad9f46917 (automated) 2020-06-19 21:43:46 +00:00
Dean Deng ad9f469174 Fix bugs in vfs2 to make symlink tests pass.
- Return ENOENT if target path is empty.
- Make sure open(2) with O_CREAT|O_EXCL returns EEXIST when necessary.
- Correctly update atime in tmpfs using touchATime().

Updates #2923.

PiperOrigin-RevId: 317382655
2020-06-19 14:41:14 -07:00
gVisor bot e0cfb2ae4f Merge release-20200608.0-98-gf0feada89 (automated) 2020-06-19 21:16:59 +00:00
Nicolas Lacasse f0feada89c Use internal tmpfs in test runner, even when running with overlay.
PiperOrigin-RevId: 317377571
2020-06-19 14:14:21 -07:00
gVisor bot 2e6b8ba1d4 Merge release-20200608.0-97-g8655fb724 (automated) 2020-06-19 20:39:15 +00:00
Dean Deng 8655fb7248 Fix vfs2 proc/self/fd dirent iteration.
Make proc/self/fd iteration work properly. Also, the comment on
kernfs.Inode.IterDirents did not accurately reflect how parameters should be
used/were used in kernfs.Inode impls other than fdDir.

Updates #2923.

PiperOrigin-RevId: 317370325
2020-06-19 13:36:18 -07:00
gVisor bot ea9059bf2a Merge release-20200608.0-96-g7db196c4d (automated) 2020-06-19 18:52:42 +00:00
Dean Deng 7db196c4db Port fadvise64 to vfs2.
Like vfs1, we have a trivial implementation that ignores all valid advice.

Updates #2923.

PiperOrigin-RevId: 317349505
2020-06-19 11:50:09 -07:00
gVisor bot 0a0d92d762 Merge release-20200608.0-95-gd962f9f38 (automated) 2020-06-19 18:45:56 +00:00
gVisor bot d962f9f384 Implement UDP cheksum verification.
Test:
 - TestIncrementChecksumErrors

Fixes #2943

PiperOrigin-RevId: 317348158
2020-06-19 11:43:20 -07:00
gVisor bot bb211be090 Merge release-20200608.0-94-ga609fff9d (automated) 2020-06-19 17:22:13 +00:00
Dean Deng a609fff9d1 Fix vfs2 handling of preadv2/pwritev2 flags.
Check for unsupported flags, and silently support RWF_HIPRI by doing nothing.
From pkg/abi/linux/file.go: "gVisor does not implement the RWF_HIPRI feature,
but the flag is accepted as a valid flag argument for preadv2/pwritev2."

Updates #2923.

PiperOrigin-RevId: 317330631
2020-06-19 10:19:46 -07:00
gVisor bot 8f2d48b38b Merge release-20200608.0-93-gf40d023ad (automated) 2020-06-19 15:48:16 +00:00
Dean Deng f40d023ad6 Don't adjust parent link count if we replace a child dir with another.
Updates #2923.

PiperOrigin-RevId: 317314460
2020-06-19 08:45:40 -07:00