16832 Commits

Author SHA1 Message Date
stevenhorsman
c2b0650491 release: Bump version to 3.21.0
Bump VERSION and helm-chart versions

Signed-off-by: stevenhorsman <steven@uk.ibm.com>
3.21.0
2025-09-23 20:59:00 +02:00
Fabiano Fidêncio
bfc54d904a agent: Fix format issues
In the previous commit we've added some code that broke `cargo fmt --
--check` without even noticing, as the code didn't go through the CI
process (due to it being a security advisory).

Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
2025-09-23 16:47:39 +02:00
Steve Horsman
3e67f92e34 Merge commit from fork
Fix malicious host can circumvent initdata verification on TDX
2025-09-23 13:31:29 +01:00
Alex Lyn
a9ec8ef21f kata-types: remove trailing slash from DEFAULT_KATA_GUEST_SANDBOX_DIR
Trailing slash in DEFAULT_KATA_GUEST_SANDBOX_DIR caused double slashes
in mount_point (e.g. "/run/kata-containers/sandbox//shm"), which failed
OPA strict equality checks against policy mount_point. Removing it aligns
generated paths with policy and fixes CreateSandboxRequest denial.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2025-09-23 14:01:22 +02:00
Steve Horsman
bcd0c0085c Merge pull request #11821 from mythi/coco-guest-update
Confidential containers version updates
2025-09-23 12:45:38 +01:00
Mikko Ylinen
5cb1332348 build: enable nvidia-attester for coco-guest-components
coco-guest-components tarball is used as is for both vanilla coco
rootfs and the nvidia enabled rootfs. nvidia-attester can be built
without nvml so make it globally enabled for coco-guest-components.

Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
2025-09-23 12:38:32 +03:00
Mikko Ylinen
e878d4a90a versions: bump guest-components and trustee for CoCo v0.16.0
Pick the latest CoCo components targeted for the next release.

Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
2025-09-23 12:38:32 +03:00
Fupan Li
a27009012c Merge pull request #11834 from Apokleos/fix-initdata-whitespace
CI: Keep base64 output of initdata annotation is a single line
2025-09-23 15:16:35 +08:00
Alex Lyn
4e793d635e Merge pull request #11736 from kata-containers/enhance-copyfile
runtime-rs: Enhance copyfile when sharedfs is disabled
2025-09-23 14:15:44 +08:00
Alex Lyn
f254eeb0e9 CI: Keep base64 output is a single line
This commit addresses an issue where base64 output, when used with a
default configuration, would introduce newlines, causing decoding to
fail on the runtime.

The fix ensures base64 output is a single, continuous line using the -w0
flag. This guarantees the encoded string is a valid Base64 sequence,
preventing potential runtime errors caused by invalid characters.

Note that: When you use the base64 command without any parameters, it
typically automatically adds newlines to the output, usually every 76 chars.

In contrast, base64 -w0 explicitly tells the command not to add any
newlines (-w for wrap, and 0 for a width of zero), which results in a
continuous string with no whitespace.

This is a critical distinction because if you pass a Base64 string with
newlines to a runtime, it may be treated as an invalid string, causing
the decoding process to fail.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2025-09-23 11:58:53 +08:00
Fupan Li
72a0f5daec Merge pull request #11794 from Sumynwa/sumsharma/clh_netdev_hotplug_pciinfo
runtime: clh: Add pci path for hotplugged network endpoints
2025-09-23 09:57:57 +08:00
Dan Mihai
02ace265d9 Merge pull request #11827 from microsoft/danmihai1/exec-retries
tests: k8s: retry kubectl exec
2025-09-22 17:14:50 -07:00
Hyounggyu Choi
16c2dd7c96 Merge pull request #11769 from Apokleos/enhance-blockdev
Enhance block device AIO mode
2025-09-22 14:01:38 +02:00
Alex Lyn
5dd36c6c0f runtime-rs: Correctly set permission and mode for dir when copy files
Correctly set dir's permissions and mode. This update ensures:

The dir_mode field of CopyFileRequest is set to DIR_MODE_PERMS
(equivalent to Go's 0o750 | os.ModeDir), which is primarily used for the
top-level directory creation permissions.
The file_mode field now directly uses metadata.mode() (equivalent to
Go's st.Mode) for the target entry.

This change aims to resolve potential permission issues or inconsistencies
during directory and file creation within the guest environment by precisely
matching the expected mode propagation of the Kata agent.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2025-09-22 17:59:57 +08:00
Greg Kurz
0f5511962c Merge pull request #11638 from ldoktor/ocp-peer-pods
ci.ocp: More debug output and tweaks
2025-09-22 11:57:46 +02:00
Alex Lyn
429133cedb runtime-rs: Introduce shared FS volume management in VolumeResource
The core purpose of introducing volume_manager to VolumeResource is to
centralize the management of shared file system volumes. By creating a
single VolumeManager instance within VolumeResource, all shared file
volumes are managed by one central entity. This single volume_manager
can accurately track the references of all ShareFsVolume instances to
the shared volumes, ensuring correct reference counting, proper volume
lifecycle management, and preventing issues like volumes being
overwritten.

This new design ensures that all shared volumes are managed by a central
entity, which:
(1) Guarantees correct reference counting.
(2) Manages the volume lifecycle correctly, avoiding issues like volumes
being overwritten.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2025-09-22 15:03:41 +08:00
Alex Lyn
90c99541da runtime-rs: Integrate VolumeManager into ShareFsVolume lifecycle
This commit integrates the new `VolumeManager` into the `ShareFsVolume`
lifecycle. Instead of directly copying files, `ShareFsVolume::new` now
uses the `VolumeManager` to get a guest path and determine if the volume
needs to be copied. It also updates the `cleanup` function to release
the volume's reference count, allowing the `VolumeManager` to manage its
state and clean up resources when no longer in use.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2025-09-22 15:03:27 +08:00
Alex Lyn
e73daa2f14 runtime-rs: Add sandbox level volume manager within non-sharedfs
This commit introduces a new `VolumeManager` to track the state of shared
volumes, including their reference count and its corresponding container
ids.
The manager's goal is to handle the lifecycle of shared filesystem volumes,
including:
(1) Volume State Tracking: Tracks the mapping from host source paths to guest
destination paths.
(2) Reference Counting: Manages reference counts for each volume, preventing
premature cleanup when multiple containers share the same source.
(3) Deterministic guest paths: Generates unique guest paths using random string
to avoid naming conflicts.
(4) Improved Management: Provides a centralized way to handle volume creation,
copying, and release, including aborting file watchers when volumes are no longer
in use.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2025-09-22 14:45:16 +08:00
Mikko Ylinen
28ab972b3f agent-ctl: bump image-rs
pull image-rs from CoCo guest-components that is targeted for
CoCo v0.16.0.

Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
2025-09-22 08:31:58 +03:00
Alex Lyn
313c7313f0 runtime-rs: Refactor code to improve copyfile logic and readability
This commit refactors the `CopyFile` related code to streamline the
logic for creating guest directories and make the code structure
clearer.

Its main goal is to improve the overall maintainability and facilitate
future feature extensions.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2025-09-22 11:30:47 +08:00
Alex Lyn
f36377070a runtime-rs: Enhance Copyfile to ensure existing contents synchronized
This commit is designed to perform a full sync before starting monitoring
to ensure that files which exist before monitoring starts are also synced.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2025-09-22 11:30:35 +08:00
Alex Lyn
2f5319675a runtime-rs: Set native aio more for initdata block device
This commit updates the configuration for the initdata block
device to use the BlockDeviceAio::Native mode.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2025-09-22 10:13:44 +08:00
Alex Lyn
5ca403b5d9 runtime-rs: Allow per-device AIO mode configuration for block devices
This commit enhances control over block device AIO modes via hotplug.

Previously, hotplugging block devices was set with default AIO mode (io_uring).
Even if users reset the AIO mode in the configuration file, the changes would
not be correctly applied to individual block devices.

With this update, users can now explicitly configure the AIO mode for hot-plugging
block devices via the configuration, and those settings will be correctly applied.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2025-09-22 10:13:44 +08:00
Alex Lyn
425e93a9b8 runtime-rs: Get more block device info within Device Manager
We need more information about block device, just relapce the original
method get_block_driver with get_block_device_info and return its
BlockDeviceInfo.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2025-09-22 10:13:44 +08:00
Xuewei Niu
50ffa0fbfd Merge pull request #11495 from Caspian443/temp-selinux
runtime-rs: align SELinux feature with runtime-go (#9866)
2025-09-21 17:12:37 +08:00
Caspian443
2221b76b67 runtime-rs: Add selinux support for hypervisor
- read selinux_label from OCI spec in sandbox
- set selinux_label in preparevm and startvm in hypervisor

Fixes: [#9866](https://github.com/Caspian443/kata-containers/issues/9866)

Signed-off-by: Caspian443 <scrisis843@gmail.com>
2025-09-21 13:59:17 +08:00
Caspian443
a658db8746 runtime-rs: hypervisor: add SELinux support functions
- Add disable_selinux and selinux_label fields to hypervisor for SELinux support.
- Implement related SELinux support functions.

Fixes: #9866

Signed-off-by: Caspian443 <scrisis843@gmail.com>
2025-09-21 13:59:17 +08:00
Xuewei Niu
04948c616e Merge pull request #11830 from zvonkok/gpu-lts
gpu: Add correct latest driver per default
2025-09-21 13:58:34 +08:00
Zvonko Kaiser
e6f12d8f86 gpu: Add latest driver per default
Lets make sure that we use latest driver for CI and release.
There was a sort step missing.

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2025-09-20 23:50:35 +00:00
Fabiano Fidêncio
54e8081222 qemu: Fix submodules location change
The submodule change led to a breakage on our build of QEMU.

Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
2025-09-20 22:12:27 +02:00
Lukáš Doktor
346ebd0ff9 ci.ocp: Allow to set CAA_IMAGE
we might want to provide different CAA_IMAGE (repo) to reproduce issues.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
2025-09-20 06:57:54 +02:00
Lukáš Doktor
bf90ccaf75 ci.ocp: Allow to set/provide PP_IMAGE_ID
to be able to test with older or custom peer-pod image.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
2025-09-20 06:57:54 +02:00
Lukáš Doktor
b7143488d9 ci.ocp: Allow to set CAA TAG
to allow re-running with older CAA tag for bisection/reproduction.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
2025-09-20 06:57:54 +02:00
Lukáš Doktor
12c5e0f33f ci.ocp: Log more details on failure
recently we got ErrImagePull, having more details should help analyzing
issues.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
2025-09-20 06:57:54 +02:00
Lukáš Doktor
7565c881e6 ci.ocp: Log variables in bash-friendly format
this should simplify copy&paste of the values from logs.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
2025-09-20 06:57:54 +02:00
Lukáš Doktor
a300b6b9a9 ci.ocp: Allow to set operator/caa commits
this can help reproducing or bisecting issues related to operator/caa
versions.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
2025-09-20 06:57:53 +02:00
Dan Mihai
524bf66cbc tests: k8s-credentials-secrets: retry on exec error
Retry after "kubectl exec" failure, instead of aborting the test
immediately.

Example of recent error:

https://github.com/kata-containers/kata-containers/actions/runs/17828061309/job/50693999052?pr=11822

not ok 1 Credentials using secrets
 (in test file k8s-credentials-secrets.bats, line 59)
  `kubectl exec $pod_name -- "${pod_exec_command[@]}" | grep -w "username"' failed

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-09-19 17:45:05 +00:00
Dan Mihai
01c7949bfd tests: k8s-number-cpus: retry on kubectl exec error
Retry after "kubectl exec" failure, instead of aborting the test
immediately.

Example of recent error:

https://github.com/kata-containers/kata-containers/actions/runs/17813996758/job/50644372056

not ok 1 Check number of cpus
...
error: Internal error occurred: error sending request: Post
"https://10.224.0.4:10250/exec/kata-containers-k8s-tests/cpu-test/c1?command=sh&command=-c&command=
cat+%!F(MISSING)proc%!F(MISSING)cpuinfo+%!C(MISSING)grep+processor%!C(MISSING)wc+-l&error=1&output=1": EOF

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-09-19 17:44:55 +00:00
Dan Mihai
91c3804959 tests: k8s: add container_exec_with_retries()
Add container_exec_with_retries(), useful for retrying if needed
commands similar to:

kubectl exec <pod_name> -c <container_name> -- <command>

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-09-19 17:42:59 +00:00
Dan Mihai
eec6c8b0c4 tests: k8s: retry after kubectl exec error
Some of the k8s tests were already retrying if `kubectl exec` succeeded
but produced empty output. Perform the same retries on `kubectl exec`
error exit code too, instead of aborting the test immediately.

Example of recent exec error:

https://github.com/kata-containers/kata-containers/actions/runs/17813996758/job/50644372056

not ok 1 Check number of cpus
...
error: Internal error occurred: error sending request: Post
"https://10.224.0.4:10250/exec/kata-containers-k8s-tests/cpu-test/c1?command=sh&command=-c&command=
cat+%!F(MISSING)proc%!F(MISSING)cpuinfo+%!C(MISSING)grep+processor%!C(MISSING)wc+-l&error=1&output=1": EOF

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-09-19 15:43:39 +00:00
Hyounggyu Choi
0fb40eda12 Merge pull request #11822 from BbolroC/runtime-no-hotplug-ibm-sel-s390x
runtime: Set maxmem to initialmem on s390x when memory hotplug is disabled
2025-09-18 17:31:01 +02:00
Hyounggyu Choi
d90e785901 runtime: Set maxmem to initialmem on s390x when memory hotplug is disabled
On s390x, QEMU fails if maxmem is set to 0:

```
invalid value of maxmem: maximum memory size (0x0) must be at least the initial memory size
```

This commit sets maxmem to the initial memory size for s390x when hotplug is disabled,
resolving the error while still ensuring that memory hotplug remains off.

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
2025-09-18 14:05:33 +02:00
Mikko Ylinen
49fbd6e7af runtime: qemu: disable memory hotplug for ConfidentialGuests
The setting '-m xM,slots=y,maxmem=zM' where maxmem is from
the host's memory capacity is failing with confidential VMs
on hosts having 1T+ of RAM.

slots/maxmem are necessary for setups where the container
memory is hotplugged to the VM during container creation based
on createContainer info.

This is not the case with CoCo since StaticResourceManagement
is enabled and memory hotplug flows have not been checked.

To avoid unexpeted errors with maxmem, disable slots/maxmem
in case ConfidentialGuest is requested.

Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
2025-09-17 23:43:36 +02:00
Dan Mihai
ca244c7265 Merge pull request #11753 from Apokleos/fix-anno
runtime-rs: Fix annotations within runtime-rs to pass the agent policy check
2025-09-16 16:42:26 -07:00
Dan Mihai
e2992b51ad tests: k8s-job debug information
Log the output of "kubectl logs", to hopefully help understand test
failures similar to:

https://github.com/kata-containers/kata-containers/actions/runs/17709473340/job/50326984605?pr=11753

not ok 1 Run a job to completion
 (in test file k8s-job.bats, line 37)
   `kubectl logs "$pod_name" | grep "$pi_number"' failed

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-09-16 22:36:31 +02:00
Dan Mihai
8854e69e28 tests: k8s-empty-dirs debug information
Log the output of "kubectl logs", to hopefully help understand test
failures similar to:

https://github.com/kata-containers/kata-containers/actions/runs/17709473340/job/50326984613?pr=11753

not ok 2 Empty dir volume when FSGroup is specified with non-root container
 (from function `assert_equal' in file k8s-empty-dirs.bats, line 16,
 in test file k8s-empty-dirs.bats, line 65)
 `assert_equal "1001" "$uid"' failed

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-09-16 22:36:31 +02:00
Fabiano Fidêncio
96108006f2 agent: Panic on errors accessing the attestation agent binary
Let's make sure that whenever we try to access the attestation agent
binariy, we only proceed the startup in case:
* the binary is found (CoCo case)
* the binary is not present (non-CoCo case)

In case any error that's not `NotFound`, we should simply abort as that
could mean a potential tampering with the binary (which would be
reported as an EIO).

Signed-off-by: Fabiano Fidêncio <fidencio@northflank.com>
2025-09-16 21:35:00 +02:00
Fabiano Fidêncio
d056fb20fe initramfs: Enforce --panic-on-corruption for veritysetup
Let's enforce an error on veritysetup in case there's any tampering with
the rootfs.

Signed-off-by: Fabiano Fidêncio <fidencio@northflank.com>
2025-09-16 21:35:00 +02:00
Alex Lyn
bc1170ba0c runtime-rs: Add bundle_path annotation within oci spec
Add the annotation of OCI bundle path to store its path.
As it'll be checked within agent policy, we need add them
to pass agent policy validations.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2025-09-16 21:31:02 +02:00
Alex Lyn
71ddbac56d runtime-rs: Correctly set CONTAINER_TYPE_KEY within OCI Spec annotation
With the help of `update_ocispec_annotations`, we'll add the contaienr
type key with "io.katacontainers.pkg.oci.container_type" and its
corresponding type "pod_sandbox" when it's pause container and
"pod_container" when it's an other containers.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2025-09-16 21:31:02 +02:00