From a3ba2b01a0ef4eb9ed0d7ebe7ea7f3bf75f9b408 Mon Sep 17 00:00:00 2001 From: Rodrigo Campos Date: Mon, 21 Aug 2023 16:21:07 +0200 Subject: [PATCH] features-linux: Expose idmap information High level container runtimes sometimes need to know if the OCI runtime supports idmap mounts or not, as the OCI runtime silently ignores unknown fields. This means that if it doesn't support idmap mounts, a container with userns will be started, without idmap mounts, and the files created on the volumes will have a "garbage" owner/group. Furthermore, as the userns mapping is not guaranteed to be stable over time, it will be completely unusable. Let's expose idmap support in the features subcommand, so high level container runtimes use the feature safely. Signed-off-by: Rodrigo Campos --- features-linux.md | 18 ++++++++++++++++++ schema/features-linux.json | 13 +++++++++++++ specs-go/features/features.go | 24 +++++++++++++++++++----- 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/features-linux.md b/features-linux.md index 452514387..39df03dad 100644 --- a/features-linux.md +++ b/features-linux.md @@ -209,3 +209,21 @@ Irrelevant to the availability of Intel RDT on the host operating system. "enabled": true } ``` + +## MountExtensions + +**`mountExtensions`** (object, OPTIONAL) represents the runtime's implementation status of different mount features. +Irrelevant to the availability of the features on the host operating system. + +* **`idmap`** (object, OPTIONAL) represents whether the runtime supports idmap mounts using the uidMappings and gidMappings properties of the mount. + * **`enabled`** (bool, OPTIONAL) represents whether the feature is enabled. + +### Example + +```json +"mountExtensions": { + "idmap":{ + "enabled": true + } +} +``` diff --git a/schema/features-linux.json b/schema/features-linux.json index 723ee67b8..cb01fa862 100644 --- a/schema/features-linux.json +++ b/schema/features-linux.json @@ -97,6 +97,19 @@ "type": "boolean" } } + }, + "mountExtensions": { + "type": "object", + "properties": { + "idmap": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + } + } + } + } } } } diff --git a/specs-go/features/features.go b/specs-go/features/features.go index 230e88f56..39009c79d 100644 --- a/specs-go/features/features.go +++ b/specs-go/features/features.go @@ -36,11 +36,12 @@ type Linux struct { // Nil value means "unknown", not "no support for any capability". Capabilities []string `json:"capabilities,omitempty"` - Cgroup *Cgroup `json:"cgroup,omitempty"` - Seccomp *Seccomp `json:"seccomp,omitempty"` - Apparmor *Apparmor `json:"apparmor,omitempty"` - Selinux *Selinux `json:"selinux,omitempty"` - IntelRdt *IntelRdt `json:"intelRdt,omitempty"` + Cgroup *Cgroup `json:"cgroup,omitempty"` + Seccomp *Seccomp `json:"seccomp,omitempty"` + Apparmor *Apparmor `json:"apparmor,omitempty"` + Selinux *Selinux `json:"selinux,omitempty"` + IntelRdt *IntelRdt `json:"intelRdt,omitempty"` + MountExtensions *MountExtensions `json:"mountExtensions,omitempty"` } // Cgroup represents the "cgroup" field. @@ -123,3 +124,16 @@ type IntelRdt struct { // Nil value means "unknown", not "false". Enabled *bool `json:"enabled,omitempty"` } + +// MountExtensions represents the "mountExtensions" field. +type MountExtensions struct { + // IDMap represents the status of idmap mounts support. + IDMap *IDMap `json:"idmap,omitempty"` +} + +type IDMap struct { + // Enabled represents whether idmap mounts supports is compiled in. + // Unrelated to whether the host supports it or not. + // Nil value means "unknown", not "false". + Enabled *bool `json:"enabled,omitempty"` +}