diff options
author | Dean Deng <deandeng@google.com> | 2020-01-16 18:13:27 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-01-16 18:15:02 -0800 |
commit | 7a45ae7e67438697296fc12345202e3c76304096 (patch) | |
tree | eb022f8f55b45d59873b449b8ca741f67814295b /pkg/sentry/fs/inode_overlay.go | |
parent | 1e7f0c822b3a7c643d532d40a14ab79eb1df85c6 (diff) |
Implement setxattr for overlays.
PiperOrigin-RevId: 290186303
Diffstat (limited to 'pkg/sentry/fs/inode_overlay.go')
-rw-r--r-- | pkg/sentry/fs/inode_overlay.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/pkg/sentry/fs/inode_overlay.go b/pkg/sentry/fs/inode_overlay.go index b90da20d0..c477de837 100644 --- a/pkg/sentry/fs/inode_overlay.go +++ b/pkg/sentry/fs/inode_overlay.go @@ -552,9 +552,16 @@ func overlayGetXattr(ctx context.Context, o *overlayEntry, name string, size uin return s, err } -// TODO(b/146028302): Support setxattr for overlayfs. -func overlaySetxattr(ctx context.Context, o *overlayEntry, name, value string, flags uint32) error { - return syserror.EOPNOTSUPP +func overlaySetxattr(ctx context.Context, o *overlayEntry, d *Dirent, name, value string, flags uint32) error { + // Don't allow changes to overlay xattrs through a setxattr syscall. + if strings.HasPrefix(XattrOverlayPrefix, name) { + return syserror.EPERM + } + + if err := copyUp(ctx, d); err != nil { + return err + } + return o.upper.SetXattr(ctx, d, name, value, flags) } func overlayListXattr(ctx context.Context, o *overlayEntry) (map[string]struct{}, error) { |