152 Commits
Author SHA1 Message Date
Nayana BidariandgVisor bot c050619971 Fix spec validation for entrypoint.
The OCI spec has entrypoint as the first argument in specs.Process.Args.
During testing, we observed inconsistencies in entrypoint resolution: it
was resolved during checkpoint but not during restore (or vice versa),
leading to spec validation failures. This CL corrects this by comparing the
absolute paths of entrypoints in spec validation.

PiperOrigin-RevId: 733200146
2025-03-03 23:31:15 -08:00
Stepan Koltsov 522d089494 [runsc] When mount files, add arguments to error message 2025-02-10 17:57:29 +00:00
Andrei Vagin f010ae01ac Fix a few typos 2025-01-29 21:16:51 -08:00
Nayana BidariandgVisor bot 1c38b6cbed Add levels for handling spec validation via flag.
Replaces the flag "unsafe-skip-restore-spec-validation" with
"restore-spec-validation" which allows the user to set the level of restore
spec validation such as ignore, warning or enforce. This allows user to skip
validation if required. By default, the flag will be set to "enforce" which
will perform spec validation.

This is a breaking change for users who have enabled
--unsafe-skip-restore-spec-validation flag. We advise these users to use the
new flag introduced in this change: --restore-spec-validation and set it to
"warning" or "ignore". This setting (--restore-spec-validation=warning) gives
the same behavior as when the old flag was enabled.

PiperOrigin-RevId: 719045616
2025-01-23 16:00:25 -08:00
Etienne PerotandgVisor bot 1af6da4bdc Propagate NVIDIA driver capabilities to nvproxy and seccomp filters.
Updates #10856

PiperOrigin-RevId: 700440037
2024-11-26 13:21:46 -08:00
Etienne PerotandgVisor bot 6953ca0ca3 Add NVIDIA driver capability segmentation support to nvproxy.
This wraps `nvproxy`'s `ioctl` handlers with wrappers that are
driver-capability-aware, and initially populates the ABI tree
with all functions marked as being available for capabilities
`compute` and `utility`.

It is not yet possible for the user to specify which capability
they want to enable. This should not cause a regression for users
because the hardcoded effective capability set is the one that is
currently specified for all current handlers.

Updates #9452.
Updates #10856.

PiperOrigin-RevId: 697824737
2024-11-18 18:15:21 -08:00
Etienne PerotandgVisor bot 6adc0720b2 runsc: When mounting a new procfs fails, fall back to recursive bind-mount.
As part of sandbox startup, `runsc` needs to set up a chroot environment
with a minimal working `procfs` filesystem mounted within. However, doing
so from within a container (as applications like Dangerzone do) may fail,
because in the container runtime's default configuration, some paths of the
procfs filesystem visible from within the container may be obstructed. This
prevents mounting new unobstructed instances of `procfs`.

This change detects this case and falls back to the previous behavior of
using a recursive bind-mount of `/proc` in such a case. The obstructed
subdirectories of procfs are preserved in this case, which is fine because
we only need a very minimal subset of `procfs` to actually work.

Additionally, `runsc` actually only needs a few kernel parameter files
and `/proc/self` in order to work. So this change sets up a `tmpfs` mount
that contains just those files, with the kernel parameter files being
plainly copied and `/proc/self` being a symlink to the one present in the
mounted view of `procfs` (regardless of which mounting method was used).

The `runtime_in_docker` test will continuously verify that this fallback
mechanism works to avoid similar breakage in the future.

Credits to @avagin for figuring out this solution.

Fixes #10944.

PiperOrigin-RevId: 692310347
2024-11-01 15:39:28 -07:00
Jonathon Belotti f2026c02e3 nvproxy: remove outdated commentary 2024-10-18 20:00:35 +00:00
Koichi Shiraishi 0cf77c02f8 all: remove use io/ioutil deprecated package & fix some deprecated thing
Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
2024-10-10 20:36:24 +09:00
Ayush RanjanandgVisor bot 3ca94ff9eb Pass the NVIDIA_DRIVER_CAPABILITIES env var to nvidia-container-cli.
runsc attempts to emulate nvidia-container-runtime-hook. But it was always
passing "--compute --utility" as driver capability flags to
`nvidia-container-cli configure` command.

Fix runsc to emulate nvidia-container-runtime-hook correctly by parsing
NVIDIA_DRIVER_CAPABILITIES and converting that comma-separated list to flags.

This is in preparation for adding support for non-compute GPU workloads in
nvproxy :)

Updates #9452
Updates #10856

PiperOrigin-RevId: 678064565
2024-09-23 21:36:20 -07:00
Lucas ManningandgVisor bot e29e270730 Reorganize tpuproxy code.
Now there is a main tpuproxy directory and two subdirs for each of the
different proxy implementations.

PiperOrigin-RevId: 667688748
2024-08-26 13:17:41 -07:00
Etienne PerotandgVisor bot 0237df2fda Remove error message about max_user_namespaces.
It has not been the real cause of recent failures.

If it turns out to result in new bug reports that do end up being caused by
`max_user_namespaces` being too low, then IMO the proper fix would be to add
a check for this at `runsc` startup time instead of here at process fork/exec
time.

Updates #5964

PiperOrigin-RevId: 659712753
2024-08-05 16:07:18 -07:00
Etienne PerotandgVisor bot b4ca91450f Standardize timestamps in runsc log filenames.
Prior to this change, the log files each have their own timestamp computed
independently. For example, this means that the coverage log file, the panic
log file, the debug log file, the first Gofer's log file, and the profile
files for the same Sentry may all have different timestamps in their
filenames. Now they are the same.

This change introduces a central `runsc/starttime` package for which the sole
purpose is to hold the start time of the `runsc` process, for easy plumbing
in all places that need it.

PiperOrigin-RevId: 646667986
2024-06-25 17:48:13 -07:00
Fabricio VoznikaandgVisor bot d4e733ac17 Add a few extension points
PiperOrigin-RevId: 644476039
2024-06-18 12:31:58 -07:00
Etienne PerotandgVisor bot 18509eb02f Make NVProxy and TPUProxy annotations public.
PiperOrigin-RevId: 630500333
2024-05-03 14:41:14 -07:00
Ayush RanjanandgVisor bot 797b909368 Allow gVisor-specific mount options for bind mounts to be passed via OCI spec.
We have a few gVisor-specific mount options that can be set "externally" (see
pkg/fsimpl/gofer.SupportedMountOptions). Before this change, the meaning of
"externally" was that it could be set by runsc by appending the option to
spec.Mount.Options. This change expands the meaning of "externally" to the user
defined OCI spec.

It does so by making specutils.validateMountOption() allow "unknown" options.
(By unknown here I mean options not present in optionsMap and propOptionsMap.)
This only impacts gofer mounts. There are 2 places in which the mount options
are consumed, both of which don't break due to bogus options:
1. Some of the mount options are used to create the host bind mount in gofer's
   mount namespace. See runsc/cmd/gofer.go:setupMounts(); it only extracts
   options present in optionsMap and propOptionsMap. It will disregard any
   other user-defined options.
2. The mount options are passed to the fsimpl/gofer sentry-internal mount. See
   runsc/boot/vfs.go:getMountNameAndOptions(). It consumes what it understands
   and ignores the rest (logging a warning that it is doing so).

Fixes #10316

PiperOrigin-RevId: 628341966
2024-04-26 02:38:57 -07:00
dongjinlong ba02461e12 chore: remove repetitive words in comments
Signed-off-by: dongjinlong <dongjinlong@outlook.com>
2024-03-26 19:57:40 +08:00
Jing ChenandgVisor bot eb62843a8d Add VFIO device for VFIO container.
PiperOrigin-RevId: 612606195
2024-03-04 15:28:38 -08:00
Zach KoopmansandgVisor bot 89ccdfe98a Fix nil pointer dereference in nvproxy specutils
PiperOrigin-RevId: 609551204
2024-02-22 17:23:07 -08:00
Ayush RanjanandgVisor bot 6a30f33513 Deprecate --nvproxy-docker flag.
This flag is no longer needed when using nvproxy with Docker or legacy mode of
nvidia-container-runtime. In both these cases, runsc will detect the presence
of the nvidia-container-runtime-hook and perform necessary emulation.

For backward compatibility, this flag still has the effect of injecting the
nvidia-container-runtime-hook into container prestart hooks.

PiperOrigin-RevId: 608875827
2024-02-20 23:40:40 -08:00
Fabricio VoznikaandgVisor bot 35dab382a6 Add container name to unique path keys
This is to allow multi-containers to be saved/restored
without conflicting "unique" IDs.

Updates #1956

PiperOrigin-RevId: 601231193
2024-01-24 14:16:44 -08:00
Ayush RanjanandgVisor bot 1e2be4b4f7 Move TPU device ownership to gofer process.
We still bind mount /sys/devices/pci0000:00/<pci_address>/accel/accel# files
into the sandbox process in read-only mode for all TPU devices on host.

PiperOrigin-RevId: 582021030
2023-11-13 11:04:40 -08:00
Etienne PerotandgVisor bot 62175dea49 seccomp.BuildProgram: Add ProgramOptions struct.
This is just a refactoring, but the intention of this `struct` is to add
other useful options for the program build, such as the list of expected
"hottest" syscalls by frequency.

The interface is a bit awkward, because of the need for two entry points
(one which didn't have any way to set the default actions), and because the
zero value of `linux.BPFAction` is a valid (and common) "default action":
killing the program (`linux.SECCOMP_RET_KILL_THREAD`).
We also can't use `*linux.BPFAction`, as `linux.SECCOMP_RET_*` are constants.
So the struct fields use functions that "resolve" to an action.
This reads fairly well in the call sites (`DefaultAction: Return(action)`),
at the cost of slightly convoluted logic in `seccomp.go`.

PiperOrigin-RevId: 581477348
2023-11-11 00:44:40 -08:00
Ayush RanjanandgVisor bot a5e93550c1 Move GPU device ownership to gofer process.
Tested on a T4 GPU with driver version 525.60.13:
```
$ docker run --runtime=runsc --gpus=all --rm -it nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda11.7.1-ubi8
[Vector addition of 50000 elements]
Copy input data from the host memory to the CUDA device
CUDA kernel launch with 196 blocks of 256 threads
Copy output data from the CUDA device to the host memory
Test PASSED
Done
```

Also tested this on GKE with the same vectoradd workload. Checked that the
device gofer connection is actually being closed when the container is deleted.
Something to note is that the gofer logs for the GPU-container sometimes end
abruptly (the "All lisafs servers exited." line does not print). This is
because runsc/container/container.go:stop() SIGKILLs the gofer before it can
cleanup naturally. The device gofer connection is only closed at the end of
Loader.destroySubcontainer(), which gives little time before the gofer is
SIGKILL-ed.

PiperOrigin-RevId: 581365665
2023-11-10 14:20:31 -08:00
Zach KoopmansandgVisor bot 70783b4ceb Rename nvproxy/tpuproxy annotations as internal annotations.
PiperOrigin-RevId: 576700439
2023-10-25 17:58:30 -07:00