443 Commits
Author SHA1 Message Date
Nayana BidariandgVisor bot e6b6f2aa11 Allow IPv6 addresses to be enabled/disabled in runsc based on the sysctl.
By default in runsc, we have both IPv4 and IPv6 addresses enabled on all the
interfaces. However, in runc this is based on the sysctl
net.ipv6.conf.all.disable_ipv6. This CL will make runsc behave similar to runc.
- If net.ipv6.conf.all.disable_ipv6 is > 0, then only IPv4 addresses will be
enabled on the interfaces including loopback when network mode is "sandbox".

PiperOrigin-RevId: 737656607
2025-03-17 10:10:46 -07:00
Ayush RanjanandgVisor bot 06f2254962 Deflake TestExecProcList.
There is a race in the test where the goroutine running Container.executeSync()
calls WaitPID() => IsSandboxRunning() which accesses Container.Sandbox.

This can race with the defer Container.Destroy which sets Sandbox = nil.

This race was introduced in 0968254ce7 ("Speed up container_test") which got
rid of the read on channel `ch`.

Fix the race by exec-ing asynchronously. This maintains the old behavior of not
checking if the exit status of sleep.

Fixes 0968254ce7 ("Speed up container_test")

PiperOrigin-RevId: 736572600
2025-03-13 11:18:16 -07:00
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
Fabricio VoznikaandgVisor bot 0c17600995 Fix restore with pending exec session
Exec'd processes cannot be stitched back to the original caller
and are killed after restore. So ignore failures
to restore host FDs (generally stdio) that belong
to them.

Fixes #11439

PiperOrigin-RevId: 732972054
2025-03-03 10:30:25 -08:00
Nayana BidariandgVisor bot d05a277ca3 Add checkpoint restore metrics.
- SandboxCheckpointedMetric and SandboxRestoredMetric are added for sandbox
metadata metric which indicate whether sandbox is checkpointed or restored.
- NumCheckpointedSandboxesMetric and NumRestoredSandboxesMetric are added at
the process level which will get the count of number of sandboxes being
checkpointed and restored.

PiperOrigin-RevId: 726797010
2025-02-14 00:00:09 -08:00
Stepan Koltsov f0ac6d5c9f [runsc] Print file name when cannot load state file 2025-02-10 17:52:55 +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
Fabricio VoznikaandgVisor bot fb730ff784 Remove checkpoint_count from runsc wait --checkpoint
This is done because external callers are not able to know
the snapshot generation number from the outside.

PiperOrigin-RevId: 707979556
2024-12-19 11:48:10 -08:00
Ayush RanjanandgVisor bot 6cf66fa154 Create gofer filestores in gofer's mount namespace.
Before this change, the gofer filestore FDs were opened in the host's mount
namespace. This prevented containerd from unmounting a subcontainer's rootfs
in case (due to a ref leak or bug) the container's rootfs was not destroyed in
gVisor's VFS layer. In such a scenario, the sentry would leak the rootfs
filestore FD and containerd's umount attempts will fail with EBUSY.

This change ensures that all gofer filestores are created in the gofer's mount
namespace, so any unmount attempt from the host mount namespace is not blocked.

This change makes the following 2 logical changes:
1. It introduces a new gofer process synchronization flag --sync-chroot-fd. The
   gofer waits on this FD and then proceeds to set up container filesystem and
   pivot_root(2) + chroot(2) the gofer mount namespace. This is useful if an
   external process wants to take action in gofer's mount namespace while
   having access to the host filesystem. As a result, the existing
   --sync-nvproxy-fd became redundant because it has the same use case. IOW,
   it was just renamed to "sync-chroot-fd" and its meaning became broader.
2. Container.createGoferFilestores() earlier was doing two things: creating
   gofer mount configs and creating all filestores. But the intent of this
   change is to only create filestore FDs after gofer starts in gofer mountns.
   However, the gofer mount configs are needed before that. So this function
   was split into Container.initGoferConfs().

We open FDs from the gofer mount namespace using a neat trick suggested by
Andrei, we prefix the absolute paths with /proc/<gofer-pid>/root. See
proc_pid_root(5) for more details about this.

There are no other intended changes in behavior.

Fixes #9834
Suggested-by: Andrei Vagin <avagin@google.com>
PiperOrigin-RevId: 706880500
2024-12-16 17:03:39 -08:00
Nayana BidariandgVisor bot 2fb49b8880 Remove TODO.
PiperOrigin-RevId: 706854080
2024-12-16 15:32:43 -08:00
Nayana BidariandgVisor bot 0f8216cd30 Do not validate resources during restore.
PiperOrigin-RevId: 706820039
2024-12-16 13:37:39 -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
Nayana BidariandgVisor bot cbba387571 Fix mount source validation.
PiperOrigin-RevId: 694560314
2024-11-08 10:50:39 -08:00
Andrei VaginandgVisor bot 3c4b2ad07c gofer: open volumes from the initial userns
The gofer process can encounter permission issues accessing volumes when custom
user/group mappings are defined within its user namespace. To address this, the
gofer now attempts to open volumes from the initial userns as a fallback
mechanism.

Fixes #11040

PiperOrigin-RevId: 694341928
2024-11-07 20:27:02 -08:00
Nayana BidariandgVisor bot 7a039fc8c5 Do not validate network namespace path across C/R.
PiperOrigin-RevId: 693958084
2024-11-06 20:20:15 -08:00
Nayana BidariandgVisor bot 93bc05def6 Validate resources during restore.
PiperOrigin-RevId: 693421018
2024-11-05 11:33:37 -08:00
Nayana BidariandgVisor bot dbb7cce39a Validate capabilities during restore.
PiperOrigin-RevId: 693383280
2024-11-05 09:52:54 -08:00
Nayana BidariandgVisor bot 7b3216a2ef Validate gvisor annotations during restore.
PiperOrigin-RevId: 690823681
2024-10-28 18:48:46 -07:00
Nayana BidariandgVisor bot 6bae0a7b38 Add validation for spec fields.
Adds validation for OCI spec fields across checkpoint restore. Tests are added
to verify the behavior.

PiperOrigin-RevId: 690710163
2024-10-28 12:34:10 -07:00
Jonathon Belotti f2026c02e3 nvproxy: remove outdated commentary 2024-10-18 20:00:35 +00:00
Jing Chen a093ad0450 Simplify and format gVisor codebase.
The changes are just output of `gofmt -s -w .`.
2024-10-13 00:50:32 -07: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
Nicolas LacasseandgVisor bot d5a9d523bb Implement /dev/tty for donated host TTYs
Fixes #10925

PiperOrigin-RevId: 681684673
2024-10-02 19:40:43 -07:00