diff --git a/pkg/cri/server/sandbox_run_linux.go b/pkg/cri/server/sandbox_run_linux.go index c4485e2fa..b8ceff7ec 100644 --- a/pkg/cri/server/sandbox_run_linux.go +++ b/pkg/cri/server/sandbox_run_linux.go @@ -101,12 +101,17 @@ func (c *criService) sandboxContainerSpec(id string, config *runtime.PodSandboxC if nsOptions.GetIpc() == runtime.NamespaceMode_NODE { sandboxDevShm = devShm } + // Remove the default /dev/shm mount from defaultMounts, it is added in oci/mounts.go. + specOpts = append(specOpts, oci.WithoutMounts(devShm)) + // In future the when user-namespace is enabled, the `nosuid, nodev, noexec` flags are + // required, otherwise the remount will fail with EPERM. Just use them unconditionally, + // they are nice to have anyways. specOpts = append(specOpts, oci.WithMounts([]runtimespec.Mount{ { Source: sandboxDevShm, Destination: devShm, Type: "bind", - Options: []string{"rbind", "ro"}, + Options: []string{"rbind", "ro", "nosuid", "nodev", "noexec"}, }, // Add resolv.conf for katacontainers to setup the DNS of pod VM properly. {