diff options
author | Fabricio Voznika <fvoznika@google.com> | 2018-10-11 17:44:50 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-10-11 17:45:51 -0700 |
commit | f074f0c2c77c4aec24700a49ebcbca1a7f2285e0 (patch) | |
tree | 6c76d302edcf4ebe935170a14766e915f1607a8b /runsc/container | |
parent | 3bc5e6482b110a03651abcfb02c93eef8a7ee90f (diff) |
Make the gofer process enter namespaces
This is done to further isolate the gofer from the host.
PiperOrigin-RevId: 216790991
Change-Id: Ia265b77e4e50f815d08f743a05669f9d75ad7a6f
Diffstat (limited to 'runsc/container')
-rw-r--r-- | runsc/container/container.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/runsc/container/container.go b/runsc/container/container.go index 10108db5a..37e607bed 100644 --- a/runsc/container/container.go +++ b/runsc/container/container.go @@ -726,11 +726,21 @@ func (c *Container) createGoferProcess(spec *specs.Spec, conf *boot.Config, bund cmd := exec.Command(binPath, args...) cmd.ExtraFiles = goferEnds + // Enter new namespaces to isolate from the rest of the system. Don't unshare + // cgroup because gofer is added to a cgroup in the caller's namespace. + nss := []specs.LinuxNamespace{ + {Type: specs.IPCNamespace}, + {Type: specs.MountNamespace}, + {Type: specs.NetworkNamespace}, + {Type: specs.PIDNamespace}, + {Type: specs.UTSNamespace}, + } + // Setup any uid/gid mappings, and create or join the configured user // namespace so the gofer's view of the filesystem aligns with the // users in the sandbox. + nss = append(nss, specutils.FilterNS([]specs.LinuxNamespaceType{specs.UserNamespace}, spec)...) specutils.SetUIDGIDMappings(cmd, spec) - nss := specutils.FilterNS([]specs.LinuxNamespaceType{specs.UserNamespace}, spec) // Start the gofer in the given namespace. log.Debugf("Starting gofer: %s %v", binPath, args) |