summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs/inode_overlay.go
diff options
context:
space:
mode:
authorDean Deng <deandeng@google.com>2020-01-16 18:13:27 -0800
committergVisor bot <gvisor-bot@google.com>2020-01-16 18:15:02 -0800
commit7a45ae7e67438697296fc12345202e3c76304096 (patch)
treeeb022f8f55b45d59873b449b8ca741f67814295b /pkg/sentry/fs/inode_overlay.go
parent1e7f0c822b3a7c643d532d40a14ab79eb1df85c6 (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.go13
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) {