Commit graph

8 commits

Author SHA1 Message Date
Victor Hsieh
bae88f4f65 fuse: extract FUSE as a crate from virtio/fs
The current crate still require some work to be really reusable as a
regular FUSE, i.e. with a new reader/writer against /dev/fuse. This
change intends to focus on creating the crate, without trying to find
the optimal interface, and still keep virtio/fs working.

BUG=b:168305155
TEST=./build_test
TEST=USE='asan fuzzer' emerge-hatch crosvm

Change-Id: I8b623c9262221113b720c10125a6770763f14dc8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2466484
Tested-by: Victor Hsieh <victorhsieh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Victor Hsieh <victorhsieh@chromium.org>
2020-10-27 16:18:51 +00:00
Chirantan Ekbote
bf2c3eb497 fs: Clean up readdir handling
Switch from an FnMut for adding entries to an iterator-like approach.
We can't use the Iterator trait directly because the DirEntry struct has
a generic lifetime parameter and generic associated types are not
currently supported by the language.

Also provide an automatic implementation of readdirplus so that file
systems don't have to deal with some of its fiddly details.

Move the directory entry enumeration code into a separate re-usable
struct as we will need it for the casefold support in the next change.

BUG=b:162388795
TEST=vm.Virtiofs

Change-Id: I40c92468a4852f1e302c2e67877b7189268e9c9b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2403420
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Tested-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2020-09-17 03:51:49 +00:00
Chirantan Ekbote
ba3269fd39 devices: fs: Initialize security context on creation
Set the security context (via /proc/thread-self/attr/fscreate) before
creating files, directories, nodes, or symlinks.  This ensures that
these entries appear atomically with the correct selinux labels.

BUG=b:155441848,b:158326112
TEST=vm.Virtiofs, arc.PlayStore.vm
TEST=Use strace to verify that selinux contexts are written to the
     fscreate proc file before creation.

Cq-Depend: chromium:2291828
Change-Id: Id960dbc821540373f2df073768e3ebfcb1a1c3f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2239728
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
2020-08-12 04:38:27 +00:00
Daniel Verkamp
e1952dd7d4 Remove redundant single-component imports
Fix clippy 1.43.0 clippy::single-component-path-imports warnings.

BUG=None
TEST=bin/clippy

Change-Id: I3f4f54138bedce16dc1ca937bb8bc00a94594f69
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2163203
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2020-04-26 00:15:36 +00:00
Chirantan Ekbote
80d61873eb devices: fs: Strip padding from directory entry names
When calling `getdents64`, the kernel will add additional nul bytes to
the name of the directory entry to make sure the whole thing is 8-byte
aligned.

Previously we would pass on this padded name to the kernel driver.
However, this seems to prevent the driver from detecting the "." and
".." entries, leading to the driver printing warnings like

  VFS: Lookup of '.' in virtiofs virtiofs would have caused loop

Strip out the padding so that the kernel detection of the "." and ".."
entries can work properly.

BUG=b:153677176
TEST=vm.Virtiofs and manually start a vm and check that the kernel
     doesn't print warnings about lookups causing loops

Change-Id: Id015182186cc3cb076e27556a1ab0a2de710aa59
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2145547
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2020-04-16 06:32:41 +00:00
Chirantan Ekbote
a07d84ad68 devices: fs: Add support for fuse minor version 28
BUG=b:150264964
TEST=vm.Virtiofs

Change-Id: I544329b63352956647d07aefdfce3118947d0821
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2105820
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2020-03-19 08:13:29 +00:00
Chirantan Ekbote
4f9f5c7479 devices: fs: Support fs crypto ioctls
Add support for FS_IOC_{GET,SET}_ENCRYPTION_POLICY.  Unfortunately,
since the I/O direction is encoded backwards in the ioctl definitions,
these will only work with on a kernel that's compiled with a patch to
mark them as unrestricted FUSE ioctls.

BUG=b:136127632
TEST=Compile and run the vfs_crypto.c program on a virtio-fs mount
     inside a VM

Change-Id: I124c5a943111b453dd44921a079a2baa1036dfd4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1952570
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2019-12-10 03:10:57 +00:00
Chirantan Ekbote
a24f033593 devices: fs: Add Filesystem trait
Add the `Filesystem` trait, which is the main interface between the
transport and the actual file system implementation.

BUG=b:136128319
TEST=`tast run vm.VirtioFs`

Change-Id: Ic8bc9e231652020501e10ad0be810a9f66e90b8e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1757241
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Tested-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2019-10-27 14:25:58 +00:00