Skip to content

Require a path separator below the device-mount root - #2129

Open
v0ropaev wants to merge 1 commit into
NVIDIA:mainfrom
v0ropaev:fix/mount-device-root-separator
Open

v0ropaev wants to merge 1 commit into
NVIDIA:mainfrom
v0ropaev:fix/mount-device-root-separator

Conversation

@v0ropaev

@v0ropaev v0ropaev commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

requestsFromMounts checks the container mount destination against /var/run/nvidia-container-devices with strings.HasPrefix and then trims that prefix off. No separator is required, so a sibling path with the same leading characters is read as a device request.

Observed on main with accept-nvidia-visible-devices-as-volume-mounts enabled, host path /dev/null:

container mount destination result
/var/run/nvidia-container-devices-backup/GPU0 device -backup/GPU0
/var/run/nvidia-container-devices.old/GPU1 device .old/GPU1
/var/run/nvidia-container-devicesimex/0 IMEX channel 0
/var/run/nvidia-container-devicescdi/nvidia.com/gpu=0 CDI device nvidia.com/gpu=0

The first two fail the container with an unresolvable device name. The last two are quieter: the request that comes out is well formed, so a /dev/null mount at a path that is not below the device root requests an IMEX channel, or a fully qualified CDI device, which also makes OnlyFullyQualifiedCDIDevices return true and takes the container down the CDI path.

The fix requires the separator. A destination equal to the root is still ignored, which is what the existing Container path is only 'root' case asserts.

Tests

Added to TestGetVisibleDevicesFromMounts: a sibling of the root with two mounts, and the cdi prefix case. New TestImexChannelsFromMounts covers channels below the root and the imex prefix case, since nothing tested that path.

Three of the new subtests fail on main, each with the value from the table above. go test ./internal/... passes, go vet ./internal/config/... and gofmt clean.

requestsFromMounts tests the container mount destination with
strings.HasPrefix against /var/run/nvidia-container-devices and then trims
that prefix, so a sibling path with the same leading characters is read as a
device request:

  /var/run/nvidia-container-devices-backup/GPU0 -> device "-backup/GPU0"
  /var/run/nvidia-container-devicesimex/0       -> IMEX channel "0"
  /var/run/nvidia-container-devicescdi/n.com/gpu=0 -> CDI device "n.com/gpu=0"

The first fails the container with an unresolvable device name. The other two
are worse than that, because the request looks valid: a /dev/null mount at a
path that is not below the device root ends up requesting an IMEX channel, or
a fully qualified CDI device, which also sends the container down the
OnlyFullyQualifiedCDIDevices path.

Require the separator. A destination equal to the root is still ignored, as
before, and the existing "Container path is only 'root'" case covers it.

Signed-off-by: Dmitry Voropaev <dy.voropaev@gmail.com>
@copy-pr-bot

copy-pr-bot Bot commented Oct 8, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant