summary refs log tree commit diff
path: root/devices/src/virtio/fs
diff options
context:
space:
mode:
authorChirantan Ekbote <chirantan@chromium.org>2019-10-19 03:31:32 +0900
committerCommit Bot <commit-bot@chromium.org>2019-11-08 04:07:55 +0000
commitf68a2940f4734687fba96380d1111bfae2c43ffa (patch)
treedb5f2f97ee5772fff43b2e14bfc3258a7140c3e0 /devices/src/virtio/fs
parentcfabb882f14db178cd6490371f3944052f7b4c27 (diff)
downloadcrosvm-f68a2940f4734687fba96380d1111bfae2c43ffa.tar
crosvm-f68a2940f4734687fba96380d1111bfae2c43ffa.tar.gz
crosvm-f68a2940f4734687fba96380d1111bfae2c43ffa.tar.bz2
crosvm-f68a2940f4734687fba96380d1111bfae2c43ffa.tar.lz
crosvm-f68a2940f4734687fba96380d1111bfae2c43ffa.tar.xz
crosvm-f68a2940f4734687fba96380d1111bfae2c43ffa.tar.zst
crosvm-f68a2940f4734687fba96380d1111bfae2c43ffa.zip
devices: fs: Disable HANDLE_KILLPRIV when writeback caching is enabled
The HANDLE_KILLPRIV feature tells the kernel that the file system will
take care of clearing the setuid and setgid bits when a file is written
to by someone other than the owner.

However, this doesn't work when writeback caching is enabled as the
write may be buffered and flushed later, which would prevent the bits
from being cleared on write.

Remove the HANDLE_KILLPRIV feature when writeback caching is enabled.

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

Change-Id: Icef98e878603cc428f83db37857d69bc6da4486c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1890582
Tested-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Diffstat (limited to 'devices/src/virtio/fs')
-rw-r--r--devices/src/virtio/fs/server.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/devices/src/virtio/fs/server.rs b/devices/src/virtio/fs/server.rs
index 1914c9b..9c3136d 100644
--- a/devices/src/virtio/fs/server.rs
+++ b/devices/src/virtio/fs/server.rs
@@ -835,7 +835,13 @@ impl<F: FileSystem + Sync> Server<F> {
 
         match self.fs.init(capable) {
             Ok(want) => {
-                let enabled = capable & (want | supported);
+                let mut enabled = capable & (want | supported);
+
+                // HANDLE_KILLPRIV doesn't work correctly when writeback caching is enabled so turn
+                // it off.
+                if enabled.contains(FsOptions::WRITEBACK_CACHE) {
+                    enabled.remove(FsOptions::HANDLE_KILLPRIV);
+                }
 
                 let out = InitOut {
                     major: KERNEL_VERSION,