diff options
author | Fabricio Voznika <fvoznika@google.com> | 2020-03-14 13:46:55 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-03-14 13:48:06 -0700 |
commit | 97127750289b49dd5e29f8ddb4209137e47fe52d (patch) | |
tree | 592b9ea2217ede2e7093b01fddac8bb185910797 /pkg/sentry/fsimpl/sys/sys.go | |
parent | 5e413cad10d2358a21dd08216953faee70e62a0b (diff) |
Disallow kernfs.Inode.SetStat for readonly inodes
Updates #1195, #1193
PiperOrigin-RevId: 300950993
Diffstat (limited to 'pkg/sentry/fsimpl/sys/sys.go')
-rw-r--r-- | pkg/sentry/fsimpl/sys/sys.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/pkg/sentry/fsimpl/sys/sys.go b/pkg/sentry/fsimpl/sys/sys.go index c36c4fa11..3928ff2c8 100644 --- a/pkg/sentry/fsimpl/sys/sys.go +++ b/pkg/sentry/fsimpl/sys/sys.go @@ -94,15 +94,17 @@ func (fs *filesystem) newDir(creds *auth.Credentials, mode linux.FileMode, conte return &d.dentry } -// SetStat implements kernfs.Inode.SetStat. -func (d *dir) SetStat(fs *vfs.Filesystem, opts vfs.SetStatOptions) error { +// SetStat implements Inode.SetStat not allowing inode attributes to be changed. +func (*dir) SetStat(*vfs.Filesystem, vfs.SetStatOptions) error { return syserror.EPERM } // Open implements kernfs.Inode.Open. func (d *dir) Open(rp *vfs.ResolvingPath, vfsd *vfs.Dentry, opts vfs.OpenOptions) (*vfs.FileDescription, error) { fd := &kernfs.GenericDirectoryFD{} - fd.Init(rp.Mount(), vfsd, &d.OrderedChildren, &opts) + if err := fd.Init(rp.Mount(), vfsd, &d.OrderedChildren, &opts); err != nil { + return nil, err + } return fd.VFSFileDescription(), nil } |