Commit Graph

16128 Commits

Author SHA1 Message Date
Ruoqing He
702ba4033e kata-ctl: Bump ttrpc-codegen related dependencies
Bump `ttrpc-codegen` related dependencies in response to `ttrpc-codegen`
bump in `libs/protocol`.

Relates: #11376

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2025-06-11 13:50:10 +00:00
Ruoqing He
f70c17660a runtime-rs: Fix clippy unnecessary_map_or
Fix `unnecessary_map_or` clippy warning as suggested by rust 1.85.1.

error: this `map_or` can be simplified
    --> crates/hypervisor/src/ch/inner_hypervisor.rs:1054:24
     |
1054 |           let have_tdx = fs::read(TDX_KVM_PARAMETER_PATH)
     |  ________________________^
1055 | |             .map_or(false, |content| !content.is_empty() && content[0] == b'Y');
     | |_______________________________________________________________________________^ help: use is_ok_and instead: `fs::read(TDX_KVM_PARAMETER_PATH).is_ok_and(|content| !content.is_empty() && content[0] == b'Y')`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or
     = note: `-D clippy::unnecessary-map-or` implied by `-D warnings`
     = help: to override `-D warnings` add `#[allow(clippy::unnecessary_map_or)]`

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2025-06-11 13:50:10 +00:00
Ruoqing He
d7dfab92be runtime-rs: Fix clippy manual_inspect
Manually fix `manual_inspect` clippy warning reported by rust 1.85.1.

```console
error: using `map` over `inspect`
  --> crates/resource/src/cdi_devices/container_device.rs:50:10
   |
50 |         .map(|device| {
   |          ^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_inspect
   = note: `-D clippy::manual-inspect` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(clippy::manual_inspect)]`
help: try
   |
50 ~         .inspect(|device| {
51 |             // push every device's Device to agent_devices
52 ~             devices_agent.push(device.device.clone());
   |
```

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2025-06-11 13:50:10 +00:00
Ruoqing He
4c467f57de runtime-rs: Fix clippy needless_return
Fix `needless_return` clippy warning as suggested by rust 1.85.1.

```console
error: unneeded `return` statement
   --> crates/resource/src/rootfs/nydus_rootfs.rs:199:5
    |
199 |     return Some(prefetch_list_path.display().to_string());
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
    = note: `-D clippy::needless-return` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::needless_return)]`
help: remove `return`
    |
199 -     return Some(prefetch_list_path.display().to_string());
199 +     Some(prefetch_list_path.display().to_string())
    |
```

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2025-06-11 13:50:10 +00:00
Ruoqing He
23365fc7e2 runtime-rs: Bump ttrpc-codegen related dependencies
Bump `ttrpc-codegen` related dependencies in response to `ttrpc-codegen`
bump in `libs/protocol`.

Relates: #11376

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2025-06-11 13:50:10 +00:00
Ruoqing He
bd4d9cf67c agent: Fix clippy empty_line_after_doc_comments
Manually fix `empty_line_after_doc_comments` clippy warning reported by
rust 1.85.1.

```console
error: empty line after doc comment
  --> src/linux_abi.rs:8:1
   |
8  | / /// Linux ABI related constants.
9  | |
   | |_^
10 |   #[cfg(target_arch = "aarch64")]
11 |   use std::fs;
   |       ------- the comment documents this import
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_doc_comments
   = note: `-D clippy::empty-line-after-doc-comments` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(clippy::empty_line_after_doc_comments)]`
   = help: if the empty line is unintentional remove it
```

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2025-06-11 13:50:10 +00:00
Ruoqing He
2ccb306c0b agent: Fix clippy precedence
Fix `precedence` clippy warning as suggested by rust 1.85.1.

```console
warning: operator precedence can trip the unwary
  --> src/pci.rs:54:19
   |
54 |         Ok(SlotFn(ss8 << FUNCTION_BITS | f8))
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider parenthesizing your expression: `(ss8 << FUNCTION_BITS) | f8`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#precedence
```

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2025-06-11 07:18:09 +00:00
Ruoqing He
048178bc5e agent: Fix clippy unnecessary_get_then_check
Manually fix `unnecessary_get_then_check` clippy warning as suggested by
rust 1.85.1.

```console
warning: unnecessary use of `get(&shared_mount.src_ctr).is_none()`
   --> src/sandbox.rs:431:25
    |
431 |             if src_ctrs.get(&shared_mount.src_ctr).is_none() {
    |                ---------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |                |
    |                help: replace it with: `!src_ctrs.contains_key(&shared_mount.src_ctr)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check
```

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2025-06-11 07:18:09 +00:00
Ruoqing He
54ec432178 agent: Fix clippy partialeq_to_none
Fix `partialeq_to_none` clippy warning as suggested by rust 1.85.1.

```console
warning: binary comparison to literal `Option::None`
   --> src/sandbox.rs:431:16
    |
431 |             if src_ctrs.get(&shared_mount.src_ctr) == None {
    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `Option::is_none()` instead: `src_ctrs.get(&shared_mount.src_ctr).is_none()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#partialeq_to_none
```

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2025-06-11 07:18:09 +00:00
Ruoqing He
95dca31ecc agent: Fix clippy question_mark
Fix `question_mark` clippy warning as suggested by rust 1.85.1.

```console
warning: this `match` expression can be replaced with `?`
    --> rustjail/src/cgroups/fs/mod.rs:1327:20
     |
1327 |       let dev_type = match DeviceType::from_char(d.typ().as_str().chars().next()) {
     |  ____________________^
1328 | |         Some(t) => t,
1329 | |         None => return None,
1330 | |     };
     | |_____^ help: try instead: `DeviceType::from_char(d.typ().as_str().chars().next())?`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#question_mark
```

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2025-06-11 07:18:09 +00:00
Ruoqing He
5a95a65604 agent: Fix clippy unnecessary_map_or
Fix `unnecessary_map_or` clippy warning as suggested by rust 1.85.1.

```console

warning: this `map_or` can be simplified
    --> rustjail/src/container.rs:1424:20
     |
1424 |                   if namespace
     |  ____________________^
1425 | |                     .path()
1426 | |                     .as_ref()
1427 | |                     .map_or(true, |p| p.as_os_str().is_empty())
     | |_______________________________________________________________^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or
help: use is_none_or instead
     |
1424 ~                 if namespace
1425 +                     .path()
1426 +                     .as_ref().is_none_or(|p| p.as_os_str().is_empty())
     |
```

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2025-06-11 07:18:09 +00:00
Ruoqing He
f9c76edd23 agent: Fix clippy manual_inspect
Manually fix `manual_inspect` clippy warning reported by rust 1.85.1.

```console
warning: using `map_err` over `inspect_err`
   --> rustjail/src/mount.rs:881:6
    |
881 |     .map_err(|e| {
    |      ^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_inspect
help: try
    |
881 ~     .inspect_err(|&e| {
882 ~         log_child!(cfd_log, "mount error: {:?}", e);
    |
```

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2025-06-11 07:18:09 +00:00
Ruoqing He
7ff34f00c2 agent: Fix clippy single_match
Fix `single_match` clippy warning as suggested by rust 1.85.1.

```console
warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
   --> src/image.rs:241:9
    |
241 | /         match oci.annotations() {
242 | |             Some(a) => {
243 | |                 if ImageService::is_sandbox(a) {
244 | |                     return ImageService::get_pause_image_process();
...   |
247 | |             None => {}
248 | |         }
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
help: try
    |
241 ~         if let Some(a) = oci.annotations() {
242 +             if ImageService::is_sandbox(a) {
243 +                 return ImageService::get_pause_image_process();
244 +             }
245 +         }
    |
```

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2025-06-11 07:18:09 +00:00
Alex Lyn
e99070afb4
Merge pull request #11343 from Apokleos/cc-blk-sharefs
Enables block device and disable virtio-fs
2025-06-11 11:52:52 +08:00
Alex Lyn
2d570db08b
Merge pull request #11179 from Apokleos/tdx-qemu-rs
runtime-rs: Add TDX Support to runtime-rs for Confidential Containers (CoCo)
2025-06-11 10:27:36 +08:00
alex.lyn
2e9d27c500 runtime-rs: Enables block device and disable virtio-fs via capabilities
Kata runtime employs a CapabilityBits mechanism for VMM capability
governance. Fundamentally, this mechanism utilizes predefined feature
flags to manage the VMM's operational boundaries.

To meet demands for storage performance and security, it's necessary
to explicitly enable capability flags such as `BlockDeviceSupport`
(basic block device support) and `BlockDeviceHotplugSupport` (block
device hotplug) which ensures the VMM provides the expected caps.

In CoCo scenarios, due to the potential risks of sensitive data leaks
or side-channel attacks introduced by virtio-fs through shared file
systems, the `FsSharingSupport` flag must be forcibly disabled. This
disables the virtio-fs feature at the capability set level, blocking
insecure data channels.

Fixes #11341

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-06-11 10:19:13 +08:00
alex.lyn
23340b6b5f runtime-rs: Support cold plug of block devices via virtio-blk for Qemu
Two key important scenarios:
(1) Support `virtio-blk-pci` cold plug capability for confidential guests
instead of nvdimm device in CVM due to security constraints in CoCo cases.
(2) Push initdata payload into compressed raw block device and insert it
in CVM through `virtio-blk-pci` cold plug mechanism.

Fixes #11341

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-06-11 10:19:13 +08:00
RuoqingHe
7916db9613
Merge pull request #11345 from Apokleos/fix-noise
protocols: Fix the noise caused by non-formatted codes in protocols
2025-06-11 09:50:02 +08:00
Aurélien Bombo
66ae9473cb
Merge pull request #11397 from kata-containers/sprt/validate-ok-to-test
ci: gha: Remove ok-to-test label on every push
2025-06-10 16:42:54 -05:00
Aurélien Bombo
31288ea7fc
Merge pull request #11398 from kata-containers/sprt/undo-mariner-hotfix
Revert "ci: Fix Mariner rootfs build failure"
2025-06-10 16:09:08 -05:00
Aurélien Bombo
f34010cc94
Merge pull request #11388 from kata-containers/sprt/azure-oidc
ci: Use OIDC to log into Azure
2025-06-10 13:08:44 -05:00
Steve Horsman
6424055eeb
Merge pull request #11393 from stevenhorsman/bump-chrono-0.4.41
libs: Bump chrono package
2025-06-10 16:47:18 +01:00
RuoqingHe
5b8f7b2e3c
Merge pull request #11391 from RuoqingHe/disable-runtime-rs-test-on-riscv
runtime-rs: Skip test on RISC-V architecture
2025-06-10 17:28:12 +08:00
Xuewei Niu
ac6779428f
Merge pull request #11377 from justxuewei/hvsock-logging 2025-06-10 16:45:59 +08:00
alex.lyn
c8433c6b70 kata-sys-util: Update TDX platform detection for newer TDX platforms
On newer TDX platforms, checking `/sys/firmware/tdx` for `major_version` and
`minor_version` is no longer necessary. Instead, we only need to verify that
`/sys/module/kvm_intel/parameters/tdx` is set to `'Y'`.

This commit addresses the following:
(1) Removes the outdated check and corrects related code, primarily impacting
`cloud-hypervisor`.
(2) Refines the TDX platform detection logic within `arch_guest_protection`.

Fixes #11177

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-06-10 11:31:25 +08:00
alex.lyn
8652aa7417 kata-types: Enable QGS port via configuration
Currently, the TDX Quote Generation Service (QGS) connection in
QEMU with default vsock port 4050 for TD attestation. To make it
flexible for users to modify the QGS port. Based on the introduced
qgs_port, This commit supports the QGS port to be configured via
configuration

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-06-10 11:31:25 +08:00
alex.lyn
f8d1ee8b1c kata-types: Introduce QGS port for TD attestation in Hypervisor config
Currently, the TDX Quote Generation Service (QGS) connection in QEMU is
hardcoded to vsock port 4050, which limits flexibility for TD attestation.
While the users will be able to modify the QGS port. To address this
inflexibility, this commit introduces a new qgs_port field within security
info and make it default with 4050.

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-06-10 11:31:25 +08:00
alex.lyn
49ced4d43c runtime-rs: Prepare Tdx protection device in start sandbox
During the prepare for `start sandbox` phase, this commit
ensures the correct `ProtectionDeviceConfig` is prepared
based on the `GuestProtection` type in a TEE platform.

Specifically, for the TDX platform, this commit sets the
essential parameters within the ProtectionDeviceConfig,
including the TDX ID, firmware path, and the default QGS
port (4050).

This information is then passed to the underlying VMM for
further processing using the existing ResourceManager and
DeviceManager infrastructure.

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-06-10 11:31:25 +08:00
alex.lyn
bab77e2d65 runtime-rs: Introduce Tdx Protection Device and add it into cmdline
This patch introduces TdxConfig with key fields, firmare,
qgs_port, mrconfigid, and other useful things. With this config,
a new ProtectionDeviceConfig type `Tdx(TdxConfig)` is added.

With this new type supported, we finally add tdx protection device
into the cmdline to launch a TDX-based CVM.

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-06-10 11:31:25 +08:00
alex.lyn
09fddac2c4 runtime-rs: Introduce 'tdx-guest' object and its builder for TDX CVMs
This commit introduces the `tdx-guest` designed to facilitate
the launch of CVMs leveraging Intel's TDX.

Launching a TDX-based CVM requires various properties, including
`quote-generation-socket`, and `mrconfigid`,`sept-ve-disable` .etc.
(1) The `quote-generation-socket` property is added to the
`tdx-guest` object, which is of type `SocketAddress`, specifies the
address of the Quote Generation Service (QGS).
(2) The `mrconfigid` property, representing the SHA384 hash
for non-owner-defined configurations of the guest TD, is introduced as a
runtime or OS configuration parameter.
(3) And the `sept-ve-disable` property allows control over whether
EPT violation conversions to #VE exceptions are disabled when the guest
TD accesses PENDING pages.

With the introduction of the `tdx-guest` object and its associated
properties, launching TDX-based CVMs is now supported. For example, a
TDX guest can be configured via the command line as follows:

```shell
-object {"qom-type":"tdx-guest", "id":"tdx", "sept-ve-disable":true,\
"mrconfigid":"vHswGkzG4B3Kikg96sLQ5vPCYx4AtuB4Ubfzz9UOXvZtCGat8b8ok7Ubz4AxDDHh",\
"quote-generation-socket":{"type":"vsock","cid":"2","port":"4050"} \
-machine q35,accel=kvm,confidential-guest-support=tdx
```

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-06-10 11:31:25 +08:00
alex.lyn
1d4ffe6af3 runtime-rs: Implement serializable SocketAddress with Serde
This enables consistent JSON representation of socket addresses
across system components:
(1) Add serde serialization/deserialization with standardized
field naming convention.
(2) Enforce string-based port/cid and unix/path representation
for protocol compatibility.

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-06-10 11:31:25 +08:00
alex.lyn
65931fb75f protocols: Fix the noise caused by non-formatted codes in protocols
```
-            decoded.strip_prefix("CAP_").unwrap_or(decoded)
+            decoded
+                .strip_prefix("CAP_")
+                .unwrap_or(decoded)
                 .parse::<oci::Capability>()
                 .unwrap_or_else(|_| panic!("Failed to parse {:?} to
Enum Capability", cap))
         })
@@ -1318,8 +1320,6 @@ mod tests {
     #[test]
     #[should_panic]
     fn test_cap_vec2hashset_bad() {
-        cap_vec2hashset(vec![
-            "CAP_DOES_NOT_EXIST".to_string(),
-        ]);
+        cap_vec2hashset(vec!["CAP_DOES_NOT_EXIST".to_string()]);
```

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-06-10 11:30:33 +08:00
stevenhorsman
ac9d3eb7be libs: Bump chrono package
Bump chrono package to 0.4.41 and thereby
remove the time 0.1.43 dependency and remediate
CVE-2020-26235

Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2025-06-09 21:01:27 +01:00
Aurélien Bombo
004c1a4595 Revert "ci: Fix Mariner rootfs build failure"
This reverts commit dfa25a42ff.

The original issue was fixed:

https://github.com/microsoft/azurelinux/issues/13971#issuecomment-2956384627
2025-06-09 14:06:07 -05:00
Aurélien Bombo
2ee3470627 ci: gha: Remove ok-to-test label on every push
This removes the ok-to-test label on every push, except if the PR author
has write access to the repo (ie. permission to modify labels).

This protects against attackers who would initially open a genuine PR,
then push malicious code after the initial review.

Signed-off-by: Aurélien Bombo <abombo@microsoft.com>
2025-06-09 12:37:06 -05:00
Aurélien Bombo
9488ce822d
Merge pull request #11396 from kata-containers/sprt/fix-mariner-image
ci: Fix Mariner rootfs build failure
2025-06-09 12:32:14 -05:00
Aurélien Bombo
dfa25a42ff ci: Fix Mariner rootfs build failure
This implements a workaround for microsoft/azurelinux#13971 to unblock
the CI.

Signed-off-by: Aurélien Bombo <abombo@microsoft.com>
2025-06-09 10:56:10 -05:00
Alex Lyn
2979312f7b
Merge pull request #11381 from RuoqingHe/log-instead-of-format
runtime-rs: Log error instead of format
2025-06-09 11:54:13 +08:00
Ruoqing He
e290587f9c runtime-rs: Skip test on RISC-V architecture
Full set test on RISC-V architecture is not yet supported, skip it for
now.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2025-06-09 01:49:47 +00:00
Ruoqing He
781510202a runtime-rs: Log error instead of format
Log on error condition when `umount` operation fail instead of `format!`
error message.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2025-06-08 08:28:22 +00:00
Xuewei Niu
17b2daf0a7
Merge pull request #11357 from justxuewei/nxw/remove-dcode
dragonball: Remove a useless dead_code attribute
2025-06-08 16:07:03 +08:00
Dan Mihai
e067a1be64
Merge pull request #11358 from burgerdev/gid-warning
genpolicy: improvements to /etc/passwd checks
2025-06-06 17:04:27 -07:00
Aurélien Bombo
9dd3807467 ci: Use OIDC to log into Azure
This completely eliminates the Azure secret from the repo, following the below
guidance:

https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/configuring-openid-connect-in-azure

The federated identity is scoped to the `ci` environment, meaning:

 * I had to specify this environment in some YAMLs. I don't believe there's any
   downside to this.
 * As previously, the CI works seamlessly both from PRs and in the manual
   workflow.

I also deleted the tools/packaging/kata-deploy/action folder as it doesn't seem
to be used anymore, and it contains a reference to the secret.

Signed-off-by: Aurélien Bombo <abombo@microsoft.com>
2025-06-06 15:26:10 -05:00
Steve Horsman
31a8944da1
Merge pull request #11334 from kata-containers/remove-inherit-secrets
workflows: Replace secrets: inherit
2025-06-06 16:41:13 +01:00
Steve Horsman
9555f2ce08
Merge pull request #11387 from burgerdev/riscv-artifact-name
ci: fix artifact name of RISC-V tarball
2025-06-06 15:50:21 +01:00
stevenhorsman
66ef1c1198 workflows: Replace secrets: inherit
Having secrets unconditionally being inherited is
bad practice, so update the workflows to only pass
through the minimal secrets that are needed

Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2025-06-06 09:56:46 +01:00
stevenhorsman
89d038d2b4 workflows: Switch QUAY_DEPLOYER_USERNAME to var
QUAY_DEPLOYER_USERNAME isn't sensitive, so update the secret for a var to simplify the workflows

Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2025-06-06 09:49:14 +01:00
stevenhorsman
2eda21180a workflows: Switch AUTHENTICATED_IMAGE_USER to var
AUTHENTICATED_IMAGE_USER isn't sensitive, so
update the secret for a var to simplify the workflows

Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2025-06-06 09:49:14 +01:00
Markus Rudy
9ffed463a1 ci: fix artifact name of RISC-V tarball
The artifact name accidentally referred to ARM64, which caused a clash
in CI runs.

Signed-off-by: Markus Rudy <mr@edgeless.systems>
2025-06-06 08:29:48 +02:00
RuoqingHe
567296119d
Merge pull request #11317 from kimullaa/remove-obsolete-parameters
runtime: remove hotplug_vfio_on_root_bus from config.toml
2025-06-06 04:03:03 +02:00