Skip to content

Commit b88f8ea

Browse files
committed
more wip
1 parent 2be8540 commit b88f8ea

9 files changed

Lines changed: 82 additions & 81 deletions

File tree

docker/guest_components.dockerfile

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
1-
FROM ghcr.io/sc2-sys/base:0.10.0
1+
FROM ghcr.io/sc2-sys/base:0.12.0
22

33
# ---------------------------
44
# Guest Components source set-up
55
# ---------------------------
66

77
# Install APT dependencies
88
RUN apt install -y \
9-
cmake \
109
musl-tools \
1110
pkg-config \
1211
protobuf-compiler \
1312
tss2
1413

1514
# Fetch code and build the runtime and the agent
16-
ARG CODE_DIR=/usr/src/guest-components
17-
RUN mkdir -p ${CODE_DIR} \
18-
&& git clone\
19-
-b sc2-main \
20-
https://github.com/sc2-sys/guest-components \
21-
${CODE_DIR} \
22-
&& git config --global --add safe.directory ${CODE_DIR} \
23-
&& cd ${CODE_DIR}/image-rs \
24-
&& cargo build --release --features "nydus"
2515

2616
WORKDIR ${CODE_DIR}

docker/kata.dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,25 @@ RUN mkdir -p ${CODE_DIR} \
8383
# to modify both in the same work-on container
8484
# ------------------------------------------------------------------------------
8585

86+
ARG CODE_DIR_GC=/git/sc2-sys/guest-components
87+
ARG RUST_VERSION_GC=1.81
88+
RUN mkdir -p ${CODE_DIR_GC} \
89+
&& git clone\
90+
-b sc2-main \
91+
https://github.com/sc2-sys/guest-components \
92+
${CODE_DIR_GC} \
93+
&& git config --global --add safe.directory ${CODE_DIR_GC} \
94+
&& cd ${CODE_DIR_GC}/image-rs \
95+
&& rustup override set ${RUST_VERSION_GC} \
96+
&& cargo build --release --features "nydus"
97+
98+
# ------------------------------------------------------------------------------
99+
# Build Guest Components
100+
#
101+
# The agent is very tightly-coupled with guest-components, so it makes sense
102+
# to modify both in the same work-on container
103+
# ------------------------------------------------------------------------------
104+
86105
ARG CODE_DIR_GC=/git/sc2-sys/guest-components
87106
ARG RUST_VERSION_GC=1.81
88107
RUN mkdir -p ${CODE_DIR_GC} \

docs/attestation.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,41 @@
1-
# Attestation for Knative on CoCo
1+
# Attestation in SC2
2+
3+
Attestation is the process of appraising the provisioned TEE and the software
4+
loaded therein. In the TEEs used in SC2, AMD SEV-SNP, and Intel TDX, the
5+
attestation flow is relatively similar: __after__ starting the cVM, the trusted
6+
software in the guest will retrieve an attestation report from the hardware
7+
root-of-trust and will validate it with a [Trustee](
8+
https://github.com/confidential-containers/trustee) deployment that acts as a
9+
relying-party.
10+
11+
The attestation report contains the launch measurement of the cVM, including
12+
the initial software components like OVMF, the initrd, and the guest kernel,
13+
signed to a hardware root-of-trust.
14+
15+
## Trustee
16+
17+
Configuring Trustee to check the launch measurement is not as straightforward
18+
as one may think. At a very high level, Trustee releases secrets/resources
19+
in response to requests iff the request passes an associated _resource policy_
20+
and _attestation policy_.
21+
22+
# TODO: this paragraph may not be true?
23+
This policy may (or may not) demand that the request presents a valid launch
24+
measurement, matching a user-provided one. As a consequence: no secret/resource
25+
means no policy checking.
26+
27+
To provision secrets and resources to Trustee, we can use a client tool called
28+
the KBC. To make matters worse, however, the attestation code in guest-components
29+
(which also uses the KBC) will _only_ request a very specific resource. We
30+
explain next how to configure Trustee to achieve three different goals:
31+
32+
### Launch Measurement Verification
33+
34+
### Image Signature
35+
36+
### Image Encryption
37+
38+
## SEV-SNP Attestation
239

340
## SEV(-ES) Attestation
441

tasks/docker.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from invoke import task
22
from os.path import join
3+
from tasks.gc import build_gc_image
34
from tasks.svsm import build_svsm_image, build_svsm_kernel_image, build_svsm_qemu_image
45
from tasks.trustee import build_trustee_image
56
from tasks.util.containerd import build_containerd_image
@@ -51,6 +52,10 @@ def build_all(ctx, nocache=False, push=False):
5152
build_containerd_image(nocache, push, debug=False)
5253
print("Success!")
5354

55+
print_dotted_line("Building guest-components image")
56+
build_gc_image(nocache, push, debug=False)
57+
print("Success!")
58+
5459
print_dotted_line(f"Building kata image (v{KATA_VERSION})")
5560
build_kata_image(nocache, push, debug=False)
5661
print("Success!")

tasks/gc.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
11
from invoke import task
22
from os.path import join
33
from subprocess import run
4-
from tasks.util.docker import is_ctr_running
4+
from tasks.util.docker import build_image, is_ctr_running
55
from tasks.util.env import GHCR_URL, GITHUB_ORG, PROJ_ROOT
66
from tasks.util.versions import COCO_VERSION
77

88
GC_CTR_NAME = "guest-components-workon"
99
GC_IMAGE_TAG = join(GHCR_URL, GITHUB_ORG, "guest-components") + f":{COCO_VERSION}"
1010

1111

12+
def build_gc_image(nocache, push):
13+
build_image(
14+
GC_IMAGE_TAG,
15+
join(PROJ_ROOT, "docker", "guest_components.dockerfile"),
16+
nocache=nocache,
17+
push=push
18+
)
19+
20+
1221
@task
13-
def build(ctx):
22+
def build(ctx, nocache=False, push=False):
1423
"""
1524
Build the guest-components work-on image
1625
"""
17-
docker_cmd = "docker build -t {} -f {} .".format(
18-
GC_IMAGE_TAG, join(PROJ_ROOT, "docker", "guest_components.dockerfile")
19-
)
20-
run(docker_cmd, shell=True, check=True, cwd=PROJ_ROOT)
26+
build_gc_image(nocache, push)
2127

2228

2329
@task
@@ -31,7 +37,7 @@ def cli(ctx, mount_path=join(PROJ_ROOT, "..", "guest-components")):
3137
"-d -it",
3238
# The container path comes from the dockerfile in:
3339
# ./docker/guest_components.dockerfile
34-
f"-v {mount_path}:/usr/src/guest-components",
40+
f"-v {mount_path}:/git/sc2-sys/guest-components",
3541
"--name {}".format(GC_CTR_NAME),
3642
GC_IMAGE_TAG,
3743
"bash",

tasks/util/docker.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,13 @@ def build_image(
4747
docker_cmd = "docker build {} {} -t {} -f {} .".format(
4848
"--no-cache" if nocache else "", build_args_cmd, image_tag, dockerfile
4949
)
50+
run(docker_cmd, shell=True, check=True, cwd=cwd)
51+
"""
5052
result = run(docker_cmd, shell=True, capture_output=True, cwd=cwd)
5153
assert result.returncode == 0, print(result.stderr.decode("utf-8").strip())
5254
if debug:
5355
print(result.stdout.decode("utf-8").strip())
56+
"""
5457

5558
if push:
5659
result = run(f"docker push {image_tag}", shell=True, capture_output=True)

tasks/util/guest_components.py

Lines changed: 0 additions & 52 deletions
This file was deleted.

tasks/util/kata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def prepare_rootfs(tmp_rootfs_base_dir, debug=False, sc2=False, hot_replace=Fals
255255
KATA_AGENT_SOURCE_DIR if sc2 else KATA_BASELINE_AGENT_SOURCE_DIR,
256256
"target",
257257
"x86_64-unknown-linux-musl",
258-
"release",
258+
"debug", # "release",
259259
"kata-agent",
260260
)
261261
copy_from_kata_workon_ctr(

tasks/util/skopeo.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
from subprocess import run
66
from tasks.util.cosign import sign_container_image
77
from tasks.util.env import CONF_FILES_DIR, K8S_CONFIG_DIR
8-
from tasks.util.guest_components import (
9-
start_coco_keyprovider,
10-
stop_coco_keyprovider,
11-
)
128

139
# from tasks.util.trustee import create_kbs_secret
1410
from tasks.util.versions import SKOPEO_VERSION
@@ -58,7 +54,8 @@ def encrypt_container_image(image_tag, sign=False):
5854
# to encrypt the OCI image. To that extent, we need to mount the encryption
5955
# key somewhere that the attestation agent (in the keyprovider) can find
6056
# it
61-
start_coco_keyprovider(SKOPEO_ENCRYPTION_KEY, AA_CTR_ENCRYPTION_KEY)
57+
# TODO: this is part of trustee cluster now
58+
# start_coco_keyprovider(SKOPEO_ENCRYPTION_KEY, AA_CTR_ENCRYPTION_KEY)
6259

6360
encrypted_image_tag = image_tag.split(":")[0] + ":encrypted"
6461
skopeo_cmd = [
@@ -76,9 +73,6 @@ def encrypt_container_image(image_tag, sign=False):
7673
skopeo_cmd = " ".join(skopeo_cmd)
7774
run_skopeo_cmd(skopeo_cmd)
7875

79-
# Stop the keyprovider when we are done encrypting layers
80-
stop_coco_keyprovider()
81-
8276
# Sanity check that the image is actually encrypted
8377
inspect_jsonstr = run_skopeo_cmd(
8478
"inspect --cert-dir /certs --authfile /config.json docker://{}".format(
@@ -93,7 +87,6 @@ def encrypt_container_image(image_tag, sign=False):
9387
]
9488
if not all(layers):
9589
print("Some layers in image {} are not encrypted!".format(encrypted_image_tag))
96-
stop_coco_keyprovider()
9790
raise RuntimeError("Image encryption failed!")
9891

9992
# Create a secret in KBS with the encryption key. Skopeo needs it as raw

0 commit comments

Comments
 (0)