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

overlay, composefs: use mkcomposefs to generate composefs #1727

Merged
merged 5 commits into from
Oct 17, 2023

Conversation

giuseppe
Copy link
Member

use mkcomposefs to generate composefs, instead of using the custom composefs-from-json.

As part of the integration, retrieve the verity fs measurement after the files are written so that they can be embedded in the composefs image and their payload is validated each time the files are accessed.

@giuseppe
Copy link
Member Author

@alexlarsson PTAL

@giuseppe
Copy link
Member Author

marked as a draft for now, I'll try to move the fsverity logic into the chunked package so we don't need to carry the digests around

@giuseppe
Copy link
Member Author

marked as a draft for now, I'll try to move the fsverity logic into the chunked package so we don't need to carry the digests around

looked into it, we will still need to propagate the digests anyway since composefs lives in the overlay driver.

Moving the fsverity measurement in the chunked package can be done later.

@giuseppe giuseppe marked this pull request as ready for review October 13, 2023 07:21
ESCAPE_STANDARD
)

func escaped(val string, length int, escape int) string {

This comment was marked as resolved.

length = len(val)
}

if escapeLoneDash && length == 1 && val[0] == '-' {

This comment was marked as resolved.

NOESCAPE_SPACE = 1 << iota
ESCAPE_EQUAL
ESCAPE_LONE_DASH
ESCAPE_STANDARD

This comment was marked as resolved.

path = "/" + path
}

if _, err := fmt.Fprint(out, escaped(path, len(path), ESCAPE_STANDARD)); err != nil {

This comment was marked as resolved.

This comment was marked as resolved.

@@ -71,24 +87,42 @@ func enableVerityRecursive(path string) error {
if err := enableVerity(path, int(f.Fd())); err != nil {
return err
}

verity, err := measureVerity(path, int(f.Fd()))

This comment was marked as resolved.

This comment was marked as resolved.

@@ -109,10 +143,10 @@ func generateComposeFsBlob(toc []byte, composefsDir string) error {
// a scope to close outFd before setting fsverity on the read-only fd.
defer outFd.Close()

cmd := exec.Command(writerJson, "--format=erofs", "--out=/proc/self/fd/3", "/proc/self/fd/0")
cmd := exec.Command(writerJson, "--from-file", "/proc/self/fd/0", "/proc/self/fd/3")

This comment was marked as resolved.

@alexlarsson
Copy link
Contributor

I just released composefs 1.0.1 with the required dependencies for this. @smooge is packaging it up for fedora.

@giuseppe
Copy link
Member Author

thanks for the review. I've addressed the comments and pushed a new version

@giuseppe giuseppe force-pushed the mkcomposefs-dump branch 2 times, most recently from 536aa21 to 195c208 Compare October 15, 2023 19:28
if the file doesn't have a digest but its size is 0, we can hard code
the known sha256 digest.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
so the differ can export arbitrary data that is not written as a big
file.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
so that the users of the function can get access to the already
unmarshalled TOC instead of having to unmarshal it again.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
@giuseppe
Copy link
Member Author

giuseppe commented Oct 16, 2023

@alexlarsson I've encountered a small issue (still investigating):

something like the following doesn't seem to preserve the st_nlink:

/bin/busybox-hardlink 847 100755 1 0 0 0 1690477944.0 89/f85a8b92bdb5ada51bd8ee0d9d687da1a759a0d80f8d012e7f8cbb3933a3a0 - d4ced2c28e68aa87530507099801f1ab575ee18054847d301bad5a27a4984855
/bin/busybox-hardlink2 0 @100755 1 0 0 0 1690477944.0 /bin/busybox-hardlink - -
/bin/busybox-hardlink3 0 @100755 1 0 0 0 1690477944.0 /bin/busybox-hardlink - -
/bin/busybox-hardlink4 0 @100755 1 0 0 0 1690477944.0 /bin/busybox-hardlink - -
# bin/podman run --rm quay.io/giuseppe/zstd-chunked:hard-link sh -c 'stat -c "%n -> %h" /bin/busybox-hardlink*' 
/bin/busybox-hardlink -> 1
/bin/busybox-hardlink2 -> 1
/bin/busybox-hardlink3 -> 1
/bin/busybox-hardlink4 -> 1

anything obviously wrong?

EDIT: overseen the nlink is part of the dump itself, going to fix it.

@giuseppe giuseppe marked this pull request as draft October 16, 2023 11:45
@giuseppe
Copy link
Member Author

addressed the new comments and pushed a new version

provide a way to format the TOC in the same format that is generated
by composefs-info, this is a preparation patch for the next commit.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
use mkcomposefs to generate composefs, instead of using the custom
composefs-from-json.

As part of the integration, retrieve the verity fs measurement after
the files are written so that they can be embedded in the composefs
image and their payload is validated each time the files are
accessed.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Copy link
Contributor

@alexlarsson alexlarsson left a comment

Choose a reason for hiding this comment

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

lgtm

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 16, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alexlarsson, giuseppe

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@rhatdan
Copy link
Member

rhatdan commented Oct 16, 2023

@nalind @mtrmac PTAL

@giuseppe
Copy link
Member Author

@flouthoc PTAL

@rhatdan
Copy link
Member

rhatdan commented Oct 17, 2023

LGTM

@rhatdan rhatdan merged commit 2cc7b10 into containers:main Oct 17, 2023
18 of 19 checks passed
@nalind
Copy link
Member

nalind commented Oct 18, 2023

Please let the bot handle merges.

@cgwalters cgwalters added the area/composefs composefs related changes label Dec 4, 2023
@cgwalters
Copy link
Contributor

I know this question isn't related to this PR, just reusing it as a handy discussion forum...it looks like right now enabling this logic requires a build tag. And once the build tag is set, we unconditionally use composefs?

Is there any reason not to switch to having this be an option in storage.conf instead, and have the code always be enabled?

@giuseppe
Copy link
Member Author

giuseppe commented Dec 5, 2023

I agree, it is better to drop the build tag. I've used it when it was just a PoC and that required some custom binary to be present, but now there is no need to hide the feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved area/composefs composefs related changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants