27 Commits

Author SHA1 Message Date
Lucas Manning 3e952d1e30 Modify FUSE inodes so they're not always assumed to be valid.
PiperOrigin-RevId: 621954030
2024-04-04 13:35:04 -07:00
Jamie Liu 075a9df798 Fix async-signal-unsafety in mount test.
- JoinPath returns a std::string and can therefore heap-allocate.

- exit(3) is async-signal-unsafe since it executes arbitrary functions
  registered by atexit(3) / on_exit(3).

- Before this CL, TempPath::path() returns a std::string (by value) and can
  therefore heap-allocate.

PiperOrigin-RevId: 615143819
2024-03-12 13:05:16 -07:00
Ayush Ranjan a58df80df3 Make directory open flags checks consistent in tmpfs and kernfs.
Overlayfs and goferfs seem to be up to date.
Updated syscall tests.

PiperOrigin-RevId: 503521750
2023-01-20 14:22:38 -08:00
Derek Mauro bf8062b8db Internal change.
PiperOrigin-RevId: 481202690
2022-10-14 12:11:32 -07:00
Ayush Ranjan 9dfac31f0a Add O_DIRECTORY support to openat(O_PATH) in VFS2.
VFS2 earlier was ignoring the effect of O_DIRECTORY with O_PATH.

PiperOrigin-RevId: 456147699
2022-06-20 18:43:52 -07:00
Ayush Ranjan 37ce125750 Remove VFS1 special handling in tests.
Also clean up usage of GVISOR_VFS environment variable.
Updates #1624

PiperOrigin-RevId: 429100450
2022-02-16 11:41:51 -08:00
Fabricio Voznika e1149179f3 Remove side effect from test cases
Restore capabilities for tests that need to change them.

PiperOrigin-RevId: 371007047
2021-04-28 16:22:24 -07:00
Adin Scannell e83cc06f1b Remove _NoRandomSave tests.
We do not currently run random save tests.

PiperOrigin-RevId: 368309921
2021-04-13 15:42:41 -07:00
Fabricio Voznika ccf9138e6d Remove side effect from open tests
Individual test cases must not rely on being executed in a clean environment.

PiperOrigin-RevId: 354730126
2021-01-30 13:38:05 -08:00
gVisor bot d8c330254a Add O_PATH support in vfs2
PiperOrigin-RevId: 354367665
2021-01-28 12:24:37 -08:00
Dean Deng 4691a81253 Add test for open(2) with O_WRONLY|O_RDWR.
PiperOrigin-RevId: 349607959
2020-12-30 15:22:35 -08:00
Ayush Ranjan e3e1b36896 [vfs] Do O_DIRECTORY check after resolving symlinks.
Fixes python runtime test test_glob.
Updates #3515

We were checking is the to-be-opened dentry is a dir or not before resolving
symlinks. We should check that after resolving symlinks.
This was preventing us from opening a symlink which pointed to a directory
with O_DIRECTORY.

Also added this check in tmpfs and removed a duplicate check.

PiperOrigin-RevId: 327085895
2020-08-17 13:26:31 -07:00
Ayush Ranjan d6520e1d05 [vfs2][gofer] Fix file creation flags sent to gofer.
Fixes php runtime test ext/standard/tests/file/readfile_basic.phpt
Fixes #3516

fsgofers only want the access mode in the OpenFlags passed to Create(). If more
flags are supplied (like O_APPEND in this case), read/write from that fd will
fail with EBADF. See runsc/fsgofer/fsgofer.go:WriteAt()
VFS2 was providing more than just access modes. So filtering the flags using
p9.OpenFlagsModeMask == linux.O_ACCMODE fixes the issue.

Gofer in VFS1 also only extracts the access mode flags while making the create
RPC. See pkg/sentry/fs/gofer/path.go:Create()

Even in VFS2, when we open a handle, we extract out only the access mode flags
+ O_TRUNC.
See third_party/gvisor/pkg/sentry/fsimpl/gofer/handle.go:openHandle()

Added a test for this.

PiperOrigin-RevId: 326574829
2020-08-13 19:33:56 -07:00
Ayush Ranjan 42b610d567 [vfs2][gofer] Return appropriate errors when opening and creating files.
Fixes php test ext/standard/tests/file/touch_variation5.phpt on vfs2.
Updates #3516

Also spotted a bug with O_EXCL, where we did not return EEXIST when we tried
to open the root of the filesystem with O_EXCL | O_CREAT.

Added some more tests for open() corner cases.

PiperOrigin-RevId: 326346863
2020-08-12 17:19:09 -07:00
Ayush Ranjan 39525d64cb Add O_APPEND support in vfs2 gofer.
Helps in fixing open syscall tests: AppendConcurrentWrite and AppendOnly.

We also now update the file size for seekable special files (regular files)
which we were not doing earlier.

Updates #2923

PiperOrigin-RevId: 322670843
2020-07-22 15:42:33 -07: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
Zach Koopmans d8d86f0f3a Add test for O_TRUNC
b/36576592 calls out an edge case previously not supported
by HostFS. HostFS is currently being removed, meaning gVisor
supports this feature. Simply add the test to open_test.

PiperOrigin-RevId: 314610226
2020-06-03 14:56:04 -07:00
Fabricio Voznika 94319a8241 Make gofer.dentry.destroyLocked idempotent
gofer operations accumulate dentries touched in a slice to call
checkCachingLocked on them when the operation is over. In case
the same dentry is touched multiple times during the operation,
checkCachingLocked, and consequently destroyLocked, may be called
more than once for the same dentry.

Updates #1198

PiperOrigin-RevId: 305276819
2020-04-07 09:41:58 -07:00
Adin Scannell 2296b47344 Change to standard types.
PiperOrigin-RevId: 290846481
2020-01-21 17:28:57 -08:00
gVisor bot 45a8edbd5a Merge pull request #1492 from majek:err_typo_in_netstack_tests
PiperOrigin-RevId: 290840370
2020-01-21 16:32:49 -08:00
Kevin Krakauer 339536de5e Check that a file is a regular file with open(O_TRUNC).
It was possible to panic the sentry by opening a cache revalidating folder with
O_TRUNC|O_CREAT.

Avoids breaking php tests.

PiperOrigin-RevId: 280533213
2019-11-14 16:08:34 -08:00
Adin Scannell 888e87909e Add C++ toolchain and fix compile issues.
This was accidentally introduced in 31f05d5d4f.

Fixes #788.

PiperOrigin-RevId: 266462843
2019-08-30 15:03:15 -07:00
Andrei Vagin e9ea7230f7 fs: synchronize concurrent writes into files with O_APPEND
For files with O_APPEND, a file write operation gets a file size and uses it as
offset to call an inode write operation. This means that all other operations
which can change a file size should be blocked while the write operation doesn't
complete.

PiperOrigin-RevId: 254873771
2019-06-24 17:45:02 -07:00
Michael Pratt 4d52a55201 Change copyright notice to "The gVisor Authors"
Based on the guidelines at
https://opensource.google.com/docs/releasing/authors/.

1. $ rg -l "Google LLC" | xargs sed -i 's/Google LLC.*/The gVisor Authors./'
2. Manual fixup of "Google Inc" references.
3. Add AUTHORS file. Authors may request to be added to this file.
4. Point netstack AUTHORS to gVisor AUTHORS. Drop CONTRIBUTORS.

Fixes #209

PiperOrigin-RevId: 245823212
Change-Id: I64530b24ad021a7d683137459cafc510f5ee1de9
2019-04-29 14:26:23 -07:00
Nicolas Lacasse f4ce43e1f4 Allow and document bug ids in gVisor codebase.
PiperOrigin-RevId: 245818639
Change-Id: I03703ef0fb9b6675955637b9fe2776204c545789
2019-04-29 14:04:14 -07:00