summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs/tmpfs/tmpfs.go
diff options
context:
space:
mode:
authorNicolas Lacasse <nlacasse@google.com>2020-05-12 13:41:47 -0700
committergVisor bot <gvisor-bot@google.com>2020-05-12 13:43:48 -0700
commit7b691ab73c7a3534e3351a5ca55a82e73ec63f75 (patch)
tree21ccc1af8ae2a5fc94220b5de4e6f6e81d8ae6a0 /pkg/sentry/fs/tmpfs/tmpfs.go
parenta3f97a757a8d6e18f03acecb68b484cc1608c3ae (diff)
Don't allow rename across different gofer or tmpfs mounts.
Fixes #2651. PiperOrigin-RevId: 311193661
Diffstat (limited to 'pkg/sentry/fs/tmpfs/tmpfs.go')
-rw-r--r--pkg/sentry/fs/tmpfs/tmpfs.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/pkg/sentry/fs/tmpfs/tmpfs.go b/pkg/sentry/fs/tmpfs/tmpfs.go
index 3c2b583ae..b095312fe 100644
--- a/pkg/sentry/fs/tmpfs/tmpfs.go
+++ b/pkg/sentry/fs/tmpfs/tmpfs.go
@@ -39,14 +39,13 @@ var fsInfo = fs.Info{
// rename implements fs.InodeOperations.Rename for tmpfs nodes.
func rename(ctx context.Context, oldParent *fs.Inode, oldName string, newParent *fs.Inode, newName string, replacement bool) error {
- op, ok := oldParent.InodeOperations.(*Dir)
- if !ok {
- return syserror.EXDEV
- }
- np, ok := newParent.InodeOperations.(*Dir)
- if !ok {
+ // Don't allow renames across different mounts.
+ if newParent.MountSource != oldParent.MountSource {
return syserror.EXDEV
}
+
+ op := oldParent.InodeOperations.(*Dir)
+ np := newParent.InodeOperations.(*Dir)
return ramfs.Rename(ctx, op.ramfsDir, oldName, np.ramfsDir, newName, replacement)
}