Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random Key #266

Closed
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
60a8a55
Added mounting and using a randomly generated key by image-rs to be u…
piotrpalcz Oct 30, 2023
5404013
shim: pass seal data prepared by enclave-agent to runtime-boot
mythi Oct 19, 2023
60d9b8f
Fixing missplaced use statements and missing Cargo crates
piotrpalcz Nov 20, 2023
b41b675
Runtime-boot container using stored key in enclave by image-rs
piotrpalcz Dec 19, 2023
d960dee
Merging conflicts
piotrpalcz Dec 19, 2023
9f66e67
build(deps): bump github.com/containerd/continuity in /src/shim
dependabot[bot] Aug 28, 2023
f15261c
enclave-agent: update image-rs dependency
mythi Aug 31, 2023
6b2066c
build(deps): bump golang.org/x/sys from 0.11.0 to 0.12.0 in /src/shim
dependabot[bot] Sep 4, 2023
1e751b6
build(deps): bump actions/checkout from 3 to 4
dependabot[bot] Sep 5, 2023
8363ed7
build(deps): bump google.golang.org/grpc in /src/shim
dependabot[bot] Sep 7, 2023
a069ee6
dependabot: check enclave-agent dependencies
mythi Sep 7, 2023
b01ecf7
build(deps): bump smallvec from 1.10.0 to 1.11.0 in /src/enclave-agent
dependabot[bot] Sep 8, 2023
21818b8
build(deps): bump schannel from 0.1.21 to 0.1.22 in /src/enclave-agent
dependabot[bot] Sep 11, 2023
c9b7847
build(deps): bump docker/login-action from 2 to 3
dependabot[bot] Sep 13, 2023
49e6713
build: move to pkgs.k8s.io APT repo
mythi Sep 13, 2023
86d29aa
build(deps): bump form_urlencoded in /src/enclave-agent
dependabot[bot] Sep 14, 2023
1ace522
dependencies: Update image-rs to 914251a
surajssd Sep 13, 2023
9726eb6
build(deps): bump google.golang.org/grpc in /src/shim
dependabot[bot] Sep 15, 2023
6605708
build(deps): bump iana-time-zone in /src/enclave-agent
dependabot[bot] Sep 15, 2023
ac0070c
build(deps): bump io-lifetimes in /src/enclave-agent
dependabot[bot] Sep 18, 2023
0e54dc7
Update cilium ebpf for upstream license fix
dcmiddle Sep 15, 2023
7486724
build(deps): bump tempfile from 3.4.0 to 3.8.0 in /src/enclave-agent
dependabot[bot] Sep 20, 2023
6e0933a
build(deps): bump xsalsa20poly1305 in /src/enclave-agent
dependabot[bot] Sep 21, 2023
4ae0591
build(deps): bump google.golang.org/grpc in /src/shim
dependabot[bot] Sep 22, 2023
959c95b
build(deps): bump ttrpc-codegen in /src/enclave-agent
dependabot[bot] Sep 22, 2023
fb255c6
dependencies: Update image-rs to f4f89da
surajssd Sep 22, 2023
03266ee
build(deps): bump log from 0.4.17 to 0.4.20 in /src/enclave-agent
dependabot[bot] Sep 25, 2023
8927595
build(deps): bump once_cell from 1.17.1 to 1.18.0 in /src/enclave-agent
dependabot[bot] Sep 26, 2023
e784fac
build(deps): bump async-trait in /src/enclave-agent
dependabot[bot] Sep 28, 2023
b99318d
build(deps): bump md-5 from 0.10.5 to 0.10.6 in /src/enclave-agent
dependabot[bot] Sep 29, 2023
1d75380
build(deps): bump crossbeam-channel in /src/enclave-agent
dependabot[bot] Oct 2, 2023
f6f2402
build(deps): bump which from 4.4.0 to 4.4.2 in /src/enclave-agent
dependabot[bot] Oct 4, 2023
c7c195a
build(deps): bump ipnet from 2.7.1 to 2.8.0 in /src/enclave-agent
dependabot[bot] Oct 5, 2023
333fed8
build(deps): bump serde_json in /src/enclave-agent
dependabot[bot] Oct 6, 2023
2f31eef
build(deps): bump golang.org/x/sys from 0.12.0 to 0.13.0 in /src/shim
dependabot[bot] Oct 6, 2023
ae7e706
build(deps): bump async-compression in /src/enclave-agent
dependabot[bot] Oct 9, 2023
fecd906
build(deps): bump itoa from 1.0.6 to 1.0.9 in /src/enclave-agent
dependabot[bot] Oct 10, 2023
8aec76f
build(deps): bump google.golang.org/grpc in /src/shim
dependabot[bot] Oct 11, 2023
a7841df
build(deps): bump js-sys from 0.3.61 to 0.3.64 in /src/enclave-agent
dependabot[bot] Oct 11, 2023
f03cf63
build(deps): bump termcolor from 1.2.0 to 1.3.0 in /src/enclave-agent
dependabot[bot] Oct 12, 2023
6d63fd1
build(deps): bump parking_lot_core in /src/enclave-agent
dependabot[bot] Oct 16, 2023
e2b4f27
build(deps): bump picky-asn1-der in /src/enclave-agent
dependabot[bot] Oct 17, 2023
96d4ebb
enclave-agent: move to clap v3 Derive API
mythi Oct 13, 2023
3e77863
build(deps): bump google.golang.org/grpc in /src/shim
dependabot[bot] Oct 18, 2023
784467f
build(deps): bump openssl-sys in /src/enclave-agent
dependabot[bot] Oct 19, 2023
6b3a0b7
build(deps): bump github.com/containerd/continuity in /src/shim
dependabot[bot] Oct 19, 2023
a62ff0f
build(deps): bump link-cplusplus in /src/enclave-agent
dependabot[bot] Oct 20, 2023
ae48efb
build(deps): bump mio from 0.8.6 to 0.8.8 in /src/enclave-agent
dependabot[bot] Oct 24, 2023
1e856ab
build(deps): bump toml_edit from 0.20.0 to 0.20.2 in /src/enclave-agent
dependabot[bot] Oct 26, 2023
1a759ac
build(deps): bump core-foundation-sys in /src/enclave-agent
dependabot[bot] Oct 27, 2023
8c5c9ad
Update image-rs to v0.8.0 candidate
fitzthum Oct 27, 2023
f6168c5
bump: update image-rs to v0.8.0 candidate
Xynnn007 Oct 31, 2023
b200f28
build(deps): bump dyn-clone from 1.0.11 to 1.0.14 in /src/enclave-agent
dependabot[bot] Nov 1, 2023
655615b
bump: Use v0.8.0 tag for image-rs
portersrc Nov 1, 2023
611f790
build(deps): bump chrono from 0.4.24 to 0.4.31 in /src/enclave-agent
dependabot[bot] Nov 6, 2023
4d757c3
build(deps): bump regex from 1.7.1 to 1.10.2 in /src/enclave-agent
dependabot[bot] Nov 7, 2023
e8ee133
build: update to Occlum 0.30.0
mythi Nov 7, 2023
32a0177
build(deps): bump h2 from 0.3.16 to 0.3.21 in /src/enclave-agent
dependabot[bot] Nov 8, 2023
7815052
build(deps): bump rustix from 0.36.9 to 0.36.17 in /src/enclave-agent
dependabot[bot] Nov 9, 2023
102ba80
build: move to Go 1.21.x
mythi Nov 1, 2023
90beca9
shim: fix linter errors
mythi Nov 1, 2023
267b145
build(deps): bump zeroize_derive in /src/enclave-agent
dependabot[bot] Nov 13, 2023
1395505
build(deps): bump iana-time-zone-haiku in /src/enclave-agent
dependabot[bot] Nov 16, 2023
91abad0
build(deps): bump wasm-bindgen in /src/enclave-agent
dependabot[bot] Nov 20, 2023
b339099
build(deps): bump tokio-util from 0.7.7 to 0.7.10 in /src/enclave-agent
dependabot[bot] Nov 21, 2023
c778d80
build(deps): bump regex-syntax in /src/enclave-agent
dependabot[bot] Nov 22, 2023
3da0463
build(deps): bump tracing from 0.1.37 to 0.1.40 in /src/enclave-agent
dependabot[bot] Nov 23, 2023
dffb872
build(deps): bump openssl-src in /src/enclave-agent
dependabot[bot] Nov 27, 2023
452f3a3
build(deps): bump libc from 0.2.147 to 0.2.150 in /src/enclave-agent
dependabot[bot] Nov 28, 2023
0b3d568
build(deps): bump golang.org/x/sys from 0.13.0 to 0.15.0 in /src/shim
dependabot[bot] Nov 28, 2023
72de360
build(deps): bump ipnet from 2.8.0 to 2.9.0 in /src/enclave-agent
dependabot[bot] Nov 29, 2023
4b3e12a
build(deps): bump gimli from 0.28.0 to 0.28.1 in /src/enclave-agent
dependabot[bot] Nov 30, 2023
5da3d05
build(deps): bump crossbeam-utils in /src/enclave-agent
dependabot[bot] Dec 1, 2023
71fdfbc
build(deps): bump actions/setup-go from 4 to 5
dependabot[bot] Dec 7, 2023
ca04399
build(deps): bump filetime from 0.2.20 to 0.2.23 in /src/enclave-agent
dependabot[bot] Dec 6, 2023
47cfc7e
build(deps): bump openssl-sys in /src/enclave-agent
dependabot[bot] Dec 8, 2023
8718e4d
build(deps): bump google.golang.org/grpc in /src/shim
dependabot[bot] Dec 12, 2023
73ab1ec
build(deps): bump anstyle-wincon in /src/enclave-agent
dependabot[bot] Dec 15, 2023
2c314d5
build: create unified libOS bundle
mythi Nov 3, 2023
40a66ce
Post rebase cleanup
piotrpalcz Dec 19, 2023
5425d62
Merge branch 'random_key_3' of github.com:piotrpalcz/enclave-cc into …
piotrpalcz Dec 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/enclave-agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ clap = "2.33.3"
# logger module
env_logger = "0.10.0"

image-rs = { git = "https://github.com/confidential-containers/guest-components.git", default-features = false, rev = "fe8fb1a" }
image-rs = { git = "https://github.com/piotrpalcz/image-rs.git", default-features = false, branch = "random_key_2" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note for later reference that we want to update this after confidential-containers/guest-components#385 is merged

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to reflect that, I moved this PR to Draft.

kata-sys-util = { git = "https://github.com/kata-containers/kata-containers", rev = "4b57c04c3379d6adc7f440d156f0e4c42ac157df" }
log = "0.4.11"
protocols = { path = "../libs/protocols" }
Expand Down
2 changes: 2 additions & 0 deletions src/runtime-boot/init/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ edition = "2018"
libc = "0.2.147"
serde = { version = "1.0.183", features = ["derive"] }
serde_json = "1.0.104"
nix = { version = "0.26" }
anyhow = { version = "1.0", default-features = false }
36 changes: 25 additions & 11 deletions src/runtime-boot/init/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,44 @@ extern crate serde_json;

use libc::syscall;

use anyhow::Result;
use nix::mount::MsFlags;
use std::error::Error;
use std::ffi::CString;
use std::fs;
use std::fs::File;
use std::io::prelude::*;
use std::io::{ErrorKind, Read};

use std::ffi::CString;
use std::mem::size_of;
use std::path::Path;

fn main() -> Result<(), Box<dyn Error>> {
// TODO: Get the rootfs key and other parameters through RA/LA or PAL
let rootfs_key = b"c7-32-b3-ed-44-df-ec-7b-25-2d-9a-32-38-8d-58-61";
let rootfs_upper_layer = "/sefs/upper";
let rootfs_lower_layer = "/sefs/lower";
let rootfs_entry = "/";

// Get the key of FS image if needed
// Create and mount directory for fs key from agent enclave
fs::create_dir("/mnt");
let fs_type = String::from("hostfs");
let source = Path::new("/host");
let mount_path = Path::new("/mnt");
let flags = MsFlags::empty();
let source_c = CString::new(source.to_str().unwrap()).unwrap();
let mountpoint_c = CString::new(mount_path.to_str().unwrap()).unwrap();
nix::mount::mount(
Some(fs_type.as_str()),
mountpoint_c.as_c_str(),
Some(fs_type.as_str()),
flags,
Some("dir=/keys"),
)
.unwrap_or_else(|e| panic!("mount failed: {e}"));

let KEY_FILE: &str = "/mnt/key.txt";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double check this path matches the path in confidential-containers/guest-components#385

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To boot/app enclave to run this need to match so if the e2e flow is working that means that the path is corresponding

// Get the key of FS image
let key = {
const IMAGE_KEY_FILE: &str = "/etc/image_key";
// TODO: Get the key through RA or LA
let mut file = File::create(IMAGE_KEY_FILE)?;
// Writes key.
file.write_all(rootfs_key)?;

let key_str = load_key(IMAGE_KEY_FILE)?;
let key_str = load_key(KEY_FILE)?;
let mut key: sgx_key_128bit_t = Default::default();
parse_str_to_bytes(&key_str, &mut key)?;
Some(key)
Expand Down
12 changes: 10 additions & 2 deletions src/shim/runtime/v2/rune/v2/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path/filepath"
"strings"

"github.com/confidential-containers/enclave-cc/src/shim/runtime/v2/rune/config"
"github.com/confidential-containers/enclave-cc/src/shim/runtime/v2/rune/oci"
Expand Down Expand Up @@ -108,7 +109,14 @@ func handlePodContainer(ctx context.Context, s *service, r *taskAPI.CreateTaskRe
}
}
// sefsDir store the unionfs images (based on sefs)
sefsDir := filepath.Join(agentContainerRootDir, s.agentID, "merged/rootfs/images", cid)
lowerdirs := []string{
filepath.Join(agentContainerRootDir, s.agentID, "merged/rootfs/images", cid),
filepath.Join(bootContainerPath, "rootfs"),
}
sealDataDir := filepath.Join(agentContainerRootDir, s.agentID, "merged/rootfs/keys", cid)
if _, err := os.Stat(sealDataDir); !os.IsNotExist(err) {
lowerdirs = append(lowerdirs, sealDataDir)
}

var options []string
// Set index=off when mount overlayfs
Expand All @@ -117,7 +125,7 @@ func handlePodContainer(ctx context.Context, s *service, r *taskAPI.CreateTaskRe
fmt.Sprintf("workdir=%s", filepath.Join(workDir)),
fmt.Sprintf("upperdir=%s", filepath.Join(upperDir)),
)
options = append(options, fmt.Sprintf("lowerdir=%s:%s", sefsDir, filepath.Join(bootContainerPath, "rootfs")))
options = append(options, fmt.Sprintf("lowerdir=%s", strings.Join(lowerdirs, ":")))
r.Rootfs = append(r.Rootfs, &types.Mount{
Type: "overlay",
Source: "overlay",
Expand Down
3 changes: 2 additions & 1 deletion tools/packaging/build/agent-enclave-bundle/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ RUN export PATH="$PATH:/opt/occlum/build/bin" && \
# TODO: add new build stage and copy occlum_instance.tar.gz to it
WORKDIR /run/rune
RUN tar xzf /run/enclave-agent/occlum_instance/occlum_instance.tar.gz && \
rm -rf /run/enclave-agent
rm -rf /run/enclave-agent && \
mkdir /keys

RUN rm -rf $HOME/.cargo $HOME/.rustup /enclave-cc && sed -e '/cargo/d' -i /root/.profile && sed -e '/cargo/d' -i /root/.bashrc
RUN apt-get purge -y wget gnupg tzdata jq occlum occlum-pal occlum-toolchains-glibc make binutils libfuse2 libfuse3-3 ca-certificates rsync build-essential cmake git && apt-get autoremove -y
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
includes:
- base.yaml
targets:
- target: /
mkdirs:
- keys
- target: /bin
copy:
- files:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
includes:
- base.yaml
targets:
- target: /
mkdirs:
- keys
- target: /bin
copy:
- files:
Expand Down
4 changes: 4 additions & 0 deletions tools/packaging/build/agent-enclave-bundle/jq.filter
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,9 @@
"target": "/etc/",
"type": "hostfs",
"source": "/configs"
},{
"target": "/keys/",
"type": "hostfs",
"source": "/keys"
}] |
if $ENV.SGX_MODE == "SIM" then .metadata.debuggable = true else .metadata.debuggable = false end