Skip to content

Commit 0af9ace

Browse files
committed
cdh: store ephemeral LUKS headers in tmpfs
When creating ephemeral storages, place the LUKS headers in guest memory rather than onto the storage device itself. For this, create LUKS header files in the CDH storage directory, and call into CryptInit::init_with_data_device instead of into CryptInit::init. The code path in which existing, encrypted storages are utilized remains untouched. Signed-off-by: Manuel Huber <manuelh@nvidia.com>
1 parent 1eb735c commit 0af9ace

14 files changed

Lines changed: 286 additions & 73 deletions

File tree

confidential-data-hub/docs/kms-providers/alibaba.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ More details about accessing via EcsRamRole can be seen at [Access KMS from an E
7878
The client `AliyunKmsClient` supports `Encrypter`, `Decrypter`, and `Getter` api. When at the
7979
user side, the credential files can be directly given by the user.
8080

81-
When in Tee, the credential files is supposed to be placed under `/run/confidential-containers/cdh/kms-credential/aliyun` directory.
81+
When in Tee, the credential files is supposed to be placed under `/run/confidential-containers/cdh/kbs/kms-credential/aliyun` directory.
8282

8383
## Sealed Secrets
8484

confidential-data-hub/docs/kms-providers/ehsm-kms.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ For more details please see the [`Enroll` operation of ehsm](https://github.com/
3939
The client `EhsmKmsClient` supports `Encrypter` and `Decrypter` api. When at the
4040
user side, the credential files can be directly given by the user.
4141

42-
When in Tee, the credential files is supposed to be placed under `/run/confidential-containers/cdh/kms-credential/ehsm` directory.
42+
When in Tee, the credential files is supposed to be placed under `/run/confidential-containers/cdh/kbs/kms-credential/ehsm` directory.
4343

4444
## Sealed Secrets
4545

confidential-data-hub/example.config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
},
88
"credentials": [
99
{
10-
"path": "/run/confidential-containers/cdh/kms-credential/aliyun/ecsRamRole.json",
10+
"path": "/run/confidential-containers/cdh/kbs/kms-credential/aliyun/ecsRamRole.json",
1111
"resource_uri": "kbs:///default/aliyun/ecs_ram_role"
1212
},
1313
{
14-
"path": "/run/confidential-containers/cdh/test/file",
14+
"path": "/run/confidential-containers/cdh/kbs/test/file",
1515
"resource_uri": "kbs:///default/test/file"
1616
}
1717
],

confidential-data-hub/example.config.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ oLSG2dLCK9mjjraPjau34Q==
5353
# credentials are items that will be retrieved from KBS when CDH
5454
# is launched. `resource_uri` refers to the KBS resource uri and
5555
# `path` is where to place the file.
56-
# `path` must be with prefix `/run/confidential-containers/cdh`,
56+
# `path` must be with prefix `/run/confidential-containers/cdh/kbs`,
5757
# or it will be blocked by CDH.
5858
[[credentials]]
59-
path = "/run/confidential-containers/cdh/kms-credential/aliyun/ecsRamRole.json"
59+
path = "/run/confidential-containers/cdh/kbs/kms-credential/aliyun/ecsRamRole.json"
6060
resource_uri = "kbs:///default/aliyun/ecs_ram_role"
6161

6262
[[credentials]]
63-
path = "/run/confidential-containers/cdh/test/file"
63+
path = "/run/confidential-containers/cdh/kbs/test/file"
6464
resource_uri = "kbs:///default/test/file"
6565

6666
[image]

confidential-data-hub/hub/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ base64.workspace = true
4040
cfg-if.workspace = true
4141
clap = { workspace = true, features = ["derive"], optional = true }
4242
config = { workspace = true }
43+
const_format.workspace = true
4344
crypto.path = "../../attestation-agent/deps/crypto"
4445
env_logger = { workspace = true, optional = true }
4546
image-rs = { path = "../../image-rs", default-features = false, features = [

confidential-data-hub/hub/src/auth/kbs.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@
88
99
use std::path::PathBuf;
1010

11+
use const_format::concatcp;
1112
use kms::{plugins::kbs::KbcClient, Annotations, Getter};
1213
use log::debug;
1314
use tokio::fs;
1415

15-
use crate::{hub::Hub, Error, Result};
16+
use crate::{hub::Hub, hub::CDH_BASE_DIR, Error, Result};
1617

17-
/// This directory is used to store all the kbs resources get by CDH's init
18-
/// function, s.t. `[[Credential]]` sections in the config.toml file.
19-
pub const KBS_RESOURCE_STORAGE_DIR: &str = "/run/confidential-containers/cdh";
18+
/// Directory for KBS resources (credentials, etc.) fetched at init, see the `[[credentials]]`
19+
/// sections in CDH's `config.toml` file, for an example, see `example.config.toml`.
20+
const KBS_RESOURCE_STORAGE_DIR: &str = concatcp!(CDH_BASE_DIR, "/kbs");
2021

2122
impl Hub {
2223
pub(crate) async fn init_kbs_resources(&self) -> Result<()> {
@@ -86,11 +87,11 @@ fn is_path_valid(path: &str) -> bool {
8687
mod tests {
8788
use rstest::rstest;
8889

89-
use crate::auth::kbs::{is_path_valid, KBS_RESOURCE_STORAGE_DIR};
90+
use super::{is_path_valid, KBS_RESOURCE_STORAGE_DIR};
9091

9192
#[rstest]
9293
#[case("/etc/config.toml".into(), false)]
93-
#[case(format!("{KBS_RESOURCE_STORAGE_DIR}/../../config.toml"), false)]
94+
#[case(format!("{KBS_RESOURCE_STORAGE_DIR}/../../config.toml",), false)]
9495
#[case(format!("{KBS_RESOURCE_STORAGE_DIR}/kms-credential/../../../config.toml"), false)]
9596
#[case(format!("{KBS_RESOURCE_STORAGE_DIR}/kms-credential/./config.toml"), false)]
9697
#[case(format!("{KBS_RESOURCE_STORAGE_DIR}/kms-credential/aliyun/config.toml"), true)]

confidential-data-hub/hub/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl CdhConfig {
142142
/// ```
143143
///
144144
/// It is supposed that all the `target path` should be with prefix
145-
/// `/run/confidential-containers/cdh` or it will be treated as dangerous
145+
/// `/run/confidential-containers/cdh/kbs` or it will be treated as dangerous
146146
/// path.
147147
///
148148
/// TODO: delete this way after initdata mechanism could cover CDH's launch config.

confidential-data-hub/hub/src/hub.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
use std::{collections::HashMap, path::Path};
77

8+
/// Base directory for CDH runtime data.
9+
pub(crate) const CDH_BASE_DIR: &str = "/run/confidential-containers/cdh";
10+
811
use async_trait::async_trait;
912
use image_rs::{builder::ClientBuilder, config::ImageConfig, image::ImageClient};
1013
use kms::{Annotations, ProviderSettings};

confidential-data-hub/hub/src/secret/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pub mod error;
77
pub mod layout;
88

99
use base64::{engine::general_purpose::URL_SAFE_NO_PAD as b64, Engine};
10+
use const_format::concatcp;
1011
use jose_jwa::Signing;
1112
use jose_jwk::{EcCurves, Jwk};
1213
use jose_jws::{Flattened, Protected, Unprotected};
@@ -19,9 +20,12 @@ use self::layout::{envelope::EnvelopeSecret, vault::VaultSecret};
1920

2021
use kms::{Annotations, ProviderSettings};
2122

23+
use crate::hub::CDH_BASE_DIR;
24+
2225
pub use error::{Result, SecretError};
2326

24-
pub const SIGNING_CREDENTIALS_PATH: &str = "/run/confidential-containers/cdh/sealed-secret";
27+
/// Path to the directory containing sealed-secret signing credentials.
28+
pub const SIGNING_CREDENTIALS_PATH: &str = concatcp!(CDH_BASE_DIR, "/sealed-secret");
2529

2630
#[derive(Serialize, Deserialize, PartialEq, Debug)]
2731
#[serde(tag = "type", rename_all = "lowercase")]

0 commit comments

Comments
 (0)