diff --git a/cmd/nvidia-container-runtime-hook/container_config.go b/cmd/nvidia-container-runtime-hook/container_config.go index 3ae8c98f..ae3aca75 100644 --- a/cmd/nvidia-container-runtime-hook/container_config.go +++ b/cmd/nvidia-container-runtime-hook/container_config.go @@ -198,6 +198,10 @@ func getMigDevices(image image.CUDA, envvar string) *string { } func (hookConfig *hookConfig) getImexChannels(image image.CUDA, privileged bool) []string { + if hookConfig.Features.IgnoreImexChannelRequests.IsEnabled() { + return nil + } + // If enabled, try and get the device list from volume mounts first if hookConfig.AcceptDeviceListAsVolumeMounts { devices := image.ImexChannelsFromMounts() diff --git a/internal/config/features.go b/internal/config/features.go index a326e4ee..913f1452 100644 --- a/internal/config/features.go +++ b/internal/config/features.go @@ -34,6 +34,14 @@ type features struct { // DisableImexChannelCreation ensures that the implicit creation of // requested IMEX channels is skipped when invoking the nvidia-container-cli. DisableImexChannelCreation *feature `toml:"disable-imex-channel-creation,omitempty"` + // IgnoreImexChannelRequests configures the NVIDIA Container Toolkit to + // ignore IMEX channel requests through the NVIDIA_IMEX_CHANNELS envvar or + // volume mounts. + // This ensures that the NVIDIA Container Toolkit cannot be used to provide + // access to an IMEX channel by simply specifying an environment variable, + // possibly bypassing other checks by an orchestration system such as + // kubernetes. + IgnoreImexChannelRequests *feature `toml:"ignore-imex-channel-requests,omitempty"` } type feature bool