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

Add full reader verification #1457

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

Kern--
Copy link
Contributor

@Kern-- Kern-- commented Jan 21, 2025

WIP: needs test

Issue #, if available:

Description of changes:
Before this change, the SOCI snapshotter would verify files on read. After this change, SOCI will verify all files after the background fetcher is done, whether their read or not.

Testing performed:
make

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Before this change, the SOCI snapshotter would verify files on read.
After this change, SOCI will verify all files after the background
fetcher is done, whether their read or not.

Signed-off-by: Kern Walster <walster@amazon.com>
Copy link
Contributor

@sondavidb sondavidb left a comment

Choose a reason for hiding this comment

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

Just wanted to leave some comments for now, overall seems good but I need to look a little closer at the verifier tomorrow.

@@ -246,10 +247,19 @@ func NewFilesystem(ctx context.Context, root string, cfg config.FSConfig, opts .
}
go bgFetcher.Run(context.Background())
Copy link
Contributor

Choose a reason for hiding this comment

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

Haven't looked too closely and unrelated, but any chance we might want to pass ctx into here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we probably should.

}

var readerVerifier *reader.Verifier
if !cfg.DisableVerification {
Copy link
Contributor

Choose a reason for hiding this comment

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

So currently this is using the TOML config variable for disabling tar header verification. I think there's a world where one might want tar header integrity per file read (a somewhat hefty but not super resource-intensive process, particularly for lighter workloads) but not want to verify the entire image (a pretty resource-intensive process).

TL;DR I think this should be its own config variable.

m, _ := binary.Uvarint(b.Get(bucketKeyMode))
if !os.FileMode(uint32(m)).IsRegular() {
return fmt.Errorf("%q is not a regular file", id)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did this chunk of code get removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This prevented calling metadataReader.OpenFile on a non-regular file. That's probably not the right thing to do because a metadata.File is the information about a file's uncompressed offset/size and tar header offset/size within the uncompressed layer. That applied to all files, not just regular files.

In a practical sense, the big issue is that reader.Verify can't verify directories without this change.

fs/span-manager/span_manager.go Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants