*: should align pipe's owner with init process

The containerd-shim creates pipes and passes them to the init container as
stdin, stdout, and stderr for logging purposes. By default, these pipes are
owned by the root user (UID/GID: 0/0). The init container can access them
directly through inheritance.

However, if the init container attempts to open any files pointing to these
pipes (e.g., /proc/1/fd/2, /dev/stderr), it will encounter a permission issue
since it is not the owner. To avoid this, we need to align the ownership of
the pipes with the init process.

Fixes: #10598

Signed-off-by: Wei Fu <fuweid89@gmail.com>
This commit is contained in:
Wei Fu
2024-10-28 19:00:53 +00:00
committed by k8s-infra-cherrypick-robot
parent 6e51f71621
commit cf07f28ee2
6 changed files with 245 additions and 0 deletions

View File

@@ -38,6 +38,7 @@ type ImageList struct {
VolumeOwnership string
ArgsEscaped string
DockerSchema1 string
Nginx string
}
var (
@@ -57,6 +58,7 @@ func initImages(imageListFile string) {
VolumeOwnership: "ghcr.io/containerd/volume-ownership:2.1",
ArgsEscaped: "cplatpublic.azurecr.io/args-escaped-test-image-ns:1.0",
DockerSchema1: "registry.k8s.io/busybox@sha256:4bdd623e848417d96127e16037743f0cd8b528c026e9175e22a84f639eca58ff",
Nginx: "ghcr.io/containerd/nginx:1.27.0",
}
if imageListFile != "" {
@@ -96,6 +98,8 @@ const (
ArgsEscaped
// DockerSchema1 image with docker schema 1
DockerSchema1
// Nginx image
Nginx
)
func initImageMap(imageList ImageList) map[int]string {
@@ -108,6 +112,7 @@ func initImageMap(imageList ImageList) map[int]string {
images[VolumeOwnership] = imageList.VolumeOwnership
images[ArgsEscaped] = imageList.ArgsEscaped
images[DockerSchema1] = imageList.DockerSchema1
images[Nginx] = imageList.Nginx
return images
}