diff options
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/sentry/fsimpl/mqfs/registry.go | 5 | ||||
-rw-r--r-- | pkg/sentry/fsimpl/overlay/overlay.go | 5 | ||||
-rw-r--r-- | pkg/sentry/kernel/kernel.go | 17 | ||||
-rw-r--r-- | pkg/sentry/vfs/mount.go | 8 | ||||
-rw-r--r-- | pkg/sentry/vfs/vfs.go | 7 |
5 files changed, 9 insertions, 33 deletions
diff --git a/pkg/sentry/fsimpl/mqfs/registry.go b/pkg/sentry/fsimpl/mqfs/registry.go index e470ffadc..69182965c 100644 --- a/pkg/sentry/fsimpl/mqfs/registry.go +++ b/pkg/sentry/fsimpl/mqfs/registry.go @@ -71,10 +71,7 @@ func NewRegistryImpl(ctx context.Context, vfsObj *vfs.VirtualFilesystem, creds * var dentry kernfs.Dentry dentry.InitRoot(&fs.Filesystem, fs.newRootInode(ctx, creds)) - mount, err := vfsObj.NewDisconnectedMount(vfsfs, dentry.VFSDentry(), &vfs.MountOptions{}) - if err != nil { - return nil, err - } + mount := vfsObj.NewDisconnectedMount(vfsfs, dentry.VFSDentry(), &vfs.MountOptions{}) return &RegistryImpl{ root: &dentry, diff --git a/pkg/sentry/fsimpl/overlay/overlay.go b/pkg/sentry/fsimpl/overlay/overlay.go index 46d9f1f1d..327c37477 100644 --- a/pkg/sentry/fsimpl/overlay/overlay.go +++ b/pkg/sentry/fsimpl/overlay/overlay.go @@ -314,10 +314,7 @@ func clonePrivateMount(vfsObj *vfs.VirtualFilesystem, vd vfs.VirtualDentry, forc if forceReadOnly { opts.ReadOnly = true } - newmnt, err := vfsObj.NewDisconnectedMount(oldmnt.Filesystem(), vd.Dentry(), &opts) - if err != nil { - return vfs.VirtualDentry{}, err - } + newmnt := vfsObj.NewDisconnectedMount(oldmnt.Filesystem(), vd.Dentry(), &opts) // Take a reference on the dentry which will be owned by the returned // VirtualDentry. d := vd.Dentry() diff --git a/pkg/sentry/kernel/kernel.go b/pkg/sentry/kernel/kernel.go index d4851ccda..83299a9fb 100644 --- a/pkg/sentry/kernel/kernel.go +++ b/pkg/sentry/kernel/kernel.go @@ -418,10 +418,7 @@ func (k *Kernel) Init(args InitKernelArgs) error { return fmt.Errorf("failed to create pipefs filesystem: %v", err) } defer pipeFilesystem.DecRef(ctx) - pipeMount, err := k.vfs.NewDisconnectedMount(pipeFilesystem, nil, &vfs.MountOptions{}) - if err != nil { - return fmt.Errorf("failed to create pipefs mount: %v", err) - } + pipeMount := k.vfs.NewDisconnectedMount(pipeFilesystem, nil, &vfs.MountOptions{}) k.pipeMount = pipeMount tmpfsFilesystem, tmpfsRoot, err := tmpfs.NewFilesystem(ctx, &k.vfs, auth.NewRootCredentials(k.rootUserNamespace)) @@ -430,22 +427,14 @@ func (k *Kernel) Init(args InitKernelArgs) error { } defer tmpfsFilesystem.DecRef(ctx) defer tmpfsRoot.DecRef(ctx) - shmMount, err := k.vfs.NewDisconnectedMount(tmpfsFilesystem, tmpfsRoot, &vfs.MountOptions{}) - if err != nil { - return fmt.Errorf("failed to create tmpfs mount: %v", err) - } - k.shmMount = shmMount + k.shmMount = k.vfs.NewDisconnectedMount(tmpfsFilesystem, tmpfsRoot, &vfs.MountOptions{}) socketFilesystem, err := sockfs.NewFilesystem(&k.vfs) if err != nil { return fmt.Errorf("failed to create sockfs filesystem: %v", err) } defer socketFilesystem.DecRef(ctx) - socketMount, err := k.vfs.NewDisconnectedMount(socketFilesystem, nil, &vfs.MountOptions{}) - if err != nil { - return fmt.Errorf("failed to create sockfs mount: %v", err) - } - k.socketMount = socketMount + k.socketMount = k.vfs.NewDisconnectedMount(socketFilesystem, nil, &vfs.MountOptions{}) k.socketsVFS2 = make(map[*vfs.FileDescription]*SocketRecord) diff --git a/pkg/sentry/vfs/mount.go b/pkg/sentry/vfs/mount.go index 05a416775..9ab9a8fca 100644 --- a/pkg/sentry/vfs/mount.go +++ b/pkg/sentry/vfs/mount.go @@ -178,12 +178,12 @@ func (vfs *VirtualFilesystem) NewMountNamespace(ctx context.Context, creds *auth // (which may be nil). The new Mount is not associated with any MountNamespace // and is not connected to any other Mounts. References are taken on fs and // root. -func (vfs *VirtualFilesystem) NewDisconnectedMount(fs *Filesystem, root *Dentry, opts *MountOptions) (*Mount, error) { +func (vfs *VirtualFilesystem) NewDisconnectedMount(fs *Filesystem, root *Dentry, opts *MountOptions) *Mount { fs.IncRef() if root != nil { root.IncRef() } - return newMount(vfs, fs, root, nil /* mntns */, opts), nil + return newMount(vfs, fs, root, nil /* mntns */, opts) } // MountDisconnected creates a Filesystem configured by the given arguments, @@ -201,9 +201,7 @@ func (vfs *VirtualFilesystem) MountDisconnected(ctx context.Context, creds *auth if err != nil { return nil, err } - defer root.DecRef(ctx) - defer fs.DecRef(ctx) - return vfs.NewDisconnectedMount(fs, root, opts) + return newMount(vfs, fs, root, nil /* mntns */, opts), nil } // ConnectMountAt connects mnt at the path represented by target. diff --git a/pkg/sentry/vfs/vfs.go b/pkg/sentry/vfs/vfs.go index 1b2a668c0..9c1ee549a 100644 --- a/pkg/sentry/vfs/vfs.go +++ b/pkg/sentry/vfs/vfs.go @@ -150,12 +150,7 @@ func (vfs *VirtualFilesystem) Init(ctx context.Context) error { } anonfs.vfsfs.Init(vfs, &anonFilesystemType{}, &anonfs) defer anonfs.vfsfs.DecRef(ctx) - anonMount, err := vfs.NewDisconnectedMount(&anonfs.vfsfs, nil, &MountOptions{}) - if err != nil { - // We should not be passing any MountOptions that would cause - // construction of this mount to fail. - panic(fmt.Sprintf("VirtualFilesystem.Init: anonfs mount failed: %v", err)) - } + anonMount := vfs.NewDisconnectedMount(&anonfs.vfsfs, nil, &MountOptions{}) vfs.anonMount = anonMount return nil |