summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs/host
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2020-06-09 16:34:42 -0700
committergVisor bot <gvisor-bot@google.com>2020-06-09 16:36:56 -0700
commit6722b1e56fa63f3409f222a63241705aa3f3ace4 (patch)
tree6697b48ecbb321e22628a0db9556a4464d595442 /pkg/sentry/fs/host
parent0ae5bd24d72a6809a8ffb9c6a31fd2621180e3df (diff)
Don't WriteOut to readonly mounts
When the file closes, it attempts to write dirty cached attributes to the file. This should not be done when the mount is readonly. PiperOrigin-RevId: 315585058
Diffstat (limited to 'pkg/sentry/fs/host')
-rw-r--r--pkg/sentry/fs/host/inode.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/pkg/sentry/fs/host/inode.go b/pkg/sentry/fs/host/inode.go
index 62f1246aa..fbfba1b58 100644
--- a/pkg/sentry/fs/host/inode.go
+++ b/pkg/sentry/fs/host/inode.go
@@ -368,6 +368,9 @@ func (i *inodeOperations) Allocate(ctx context.Context, inode *fs.Inode, offset,
// WriteOut implements fs.InodeOperations.WriteOut.
func (i *inodeOperations) WriteOut(ctx context.Context, inode *fs.Inode) error {
+ if inode.MountSource.Flags.ReadOnly {
+ return nil
+ }
// Have we been using host kernel metadata caches?
if !inode.MountSource.Flags.ForcePageCache || !canMap(inode) {
// Then the metadata is already up to date on the host.