summaryrefslogtreecommitdiffhomepage
path: root/runsc
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2021-03-09 01:00:40 +0000
committergVisor bot <gvisor-bot@google.com>2021-03-09 01:00:40 +0000
commit48fae14e51110b3d2c88fdb653797feb7726167d (patch)
tree0a328d16ec1de94f2eb1c42a1fc3d02008a91af7 /runsc
parentcbb1f472eb7fee6e721f9a851a2878ee7fbd5ef9 (diff)
parent8018bf62ba5db591ad179ef6a2236bd6179fc4d6 (diff)
Merge release-20210301.0-27-g8018bf62b (automated)
Diffstat (limited to 'runsc')
-rw-r--r--runsc/cmd/gofer.go8
-rw-r--r--runsc/config/config.go3
-rw-r--r--runsc/config/flags.go1
-rw-r--r--runsc/fsgofer/fsgofer.go21
4 files changed, 26 insertions, 7 deletions
diff --git a/runsc/cmd/gofer.go b/runsc/cmd/gofer.go
index 444153674..639b2219c 100644
--- a/runsc/cmd/gofer.go
+++ b/runsc/cmd/gofer.go
@@ -165,7 +165,8 @@ func (g *Gofer) Execute(_ context.Context, f *flag.FlagSet, args ...interface{})
// Start with root mount, then add any other additional mount as needed.
ats := make([]p9.Attacher, 0, len(spec.Mounts)+1)
ap, err := fsgofer.NewAttachPoint("/", fsgofer.Config{
- ROMount: spec.Root.Readonly || conf.Overlay,
+ ROMount: spec.Root.Readonly || conf.Overlay,
+ EnableXattr: conf.Verity,
})
if err != nil {
Fatalf("creating attach point: %v", err)
@@ -177,8 +178,9 @@ func (g *Gofer) Execute(_ context.Context, f *flag.FlagSet, args ...interface{})
for _, m := range spec.Mounts {
if specutils.Is9PMount(m) {
cfg := fsgofer.Config{
- ROMount: isReadonlyMount(m.Options) || conf.Overlay,
- HostUDS: conf.FSGoferHostUDS,
+ ROMount: isReadonlyMount(m.Options) || conf.Overlay,
+ HostUDS: conf.FSGoferHostUDS,
+ EnableXattr: conf.Verity,
}
ap, err := fsgofer.NewAttachPoint(m.Destination, cfg)
if err != nil {
diff --git a/runsc/config/config.go b/runsc/config/config.go
index e9fd7708f..34ef48825 100644
--- a/runsc/config/config.go
+++ b/runsc/config/config.go
@@ -64,6 +64,9 @@ type Config struct {
// Overlay is whether to wrap the root filesystem in an overlay.
Overlay bool `flag:"overlay"`
+ // Verity is whether there's one or more verity file system to mount.
+ Verity bool `flag:"verity"`
+
// FSGoferHostUDS enables the gofer to mount a host UDS.
FSGoferHostUDS bool `flag:"fsgofer-host-uds"`
diff --git a/runsc/config/flags.go b/runsc/config/flags.go
index 7e738dfdf..adbee506c 100644
--- a/runsc/config/flags.go
+++ b/runsc/config/flags.go
@@ -69,6 +69,7 @@ func RegisterFlags() {
// Flags that control sandbox runtime behavior: FS related.
flag.Var(fileAccessTypePtr(FileAccessExclusive), "file-access", "specifies which filesystem to use for the root mount: exclusive (default), shared. Volume mounts are always shared.")
flag.Bool("overlay", false, "wrap filesystem mounts with writable overlay. All modifications are stored in memory inside the sandbox.")
+ flag.Bool("verity", false, "specifies whether a verity file system will be mounted.")
flag.Bool("overlayfs-stale-read", true, "assume root mount is an overlay filesystem")
flag.Bool("fsgofer-host-uds", false, "allow the gofer to mount Unix Domain Sockets.")
flag.Bool("vfs2", false, "enables VFSv2. This uses the new VFS layer that is faster than the previous one.")
diff --git a/runsc/fsgofer/fsgofer.go b/runsc/fsgofer/fsgofer.go
index cfa3796b1..1e80a634d 100644
--- a/runsc/fsgofer/fsgofer.go
+++ b/runsc/fsgofer/fsgofer.go
@@ -66,6 +66,9 @@ type Config struct {
// HostUDS signals whether the gofer can mount a host's UDS.
HostUDS bool
+
+ // enableXattr allows Get/SetXattr for the mounted file systems.
+ EnableXattr bool
}
type attachPoint struct {
@@ -795,12 +798,22 @@ func (l *localFile) SetAttr(valid p9.SetAttrMask, attr p9.SetAttr) error {
return err
}
-func (*localFile) GetXattr(string, uint64) (string, error) {
- return "", unix.EOPNOTSUPP
+func (l *localFile) GetXattr(name string, size uint64) (string, error) {
+ if !l.attachPoint.conf.EnableXattr {
+ return "", unix.EOPNOTSUPP
+ }
+ buffer := make([]byte, size)
+ if _, err := unix.Fgetxattr(l.file.FD(), name, buffer); err != nil {
+ return "", err
+ }
+ return string(buffer), nil
}
-func (*localFile) SetXattr(string, string, uint32) error {
- return unix.EOPNOTSUPP
+func (l *localFile) SetXattr(name string, value string, flags uint32) error {
+ if !l.attachPoint.conf.EnableXattr {
+ return unix.EOPNOTSUPP
+ }
+ return unix.Fsetxattr(l.file.FD(), name, []byte(value), int(flags))
}
func (*localFile) ListXattr(uint64) (map[string]struct{}, error) {