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

Fsverity content validation #3

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open

Fsverity content validation #3

wants to merge 41 commits into from

Conversation

Jenkins-J
Copy link
Owner

Implement the necessary calls to fsverity for enabling fsverity on a
file, measuring an fsverity file, and checking if fsverity is enabled
on a file.

Signed-off-by: James Jenkins <[email protected]>
Set fsverity block size equal to the system page size when possible.

Signed-off-by: James Jenkins <[email protected]>
Modify enable function return values and clean up calls to open the
target file.
Integrate fsverity with the local content ingester and provider.
Ingester enables fsverity on content blobs when blobs are written to
disk and the provider checks the verity digest when the blobs are read.
Fix errors in variable names that were left unchanged when copying logic
from another file.
fsverity block size should be set to the minimum of the system page size
and the file system block size.
Store fsverity digest values in integrity files on the file system with
the blob data.
Get a file descriptor to read integrity file and fix variable
assignments.
Begin adding local function to improve logic readability and flow.
Refactor ReaderAt to improve readability of fsverity validation logic.
Refactor content writer to make fsverity verification logic more
readable.
Move measure function so that it is only initialized when it is needed
(on linux systems only).
Fsverity measure function returns an error on its
own if fsverity is not enabled on a file, no need
for a redundant check.
Separate logic of storing the integrity value of a
blob into its own function. Makes code easier to
read.
Separate integrity validation logic into a new
function. Makes the code easier to read.
Remove old logs for debugging fsverity. Cannot
call the log function any more because logging
depends on having the context. The error returned
by the integrity store and integrity measure
functions are logged instead.
Check if fsverity is able to be executed on a file
instead of assuming that all linux systems have
fsverity capabilities.

Change names of store integrity and validate
integrity functions to be accurate.
Enabling fsverity fails because test file is open
and in use. Close the file before calling fsverity
operations.
Modify the definition of IsSupported fsverity
function for non-linux platforms to match the
definition of the linux IsSupported function.
Modify IsSupported function to determine support
based on the Linux kernel version.
Use sync Once to check the kernel verision a
single time, avoiding redundant work.
Change field names from snake case to camel case.
Use fsverity enable function to check if fsverity
is active on the filesystem where the content
blobs are stored.
Use fsverity enable function to check if fsverity
is active on the filesystem where the content
blobs are stored.
Jenkins-J pushed a commit that referenced this pull request Jul 1, 2024
Update the dependency and the indirect golang.org/x/net version to align
with containerd itself, and to prevent a vulnerability being detected.

We should keep the versions <= versions used by containerd 1.7 to prevent
forcing users of containerd 1.7 in combination with the latest version
of the API module from having to update all their dependencies, but
this update should likely be fine (and aligns with 1.7).

Before this:

    Scanning your code and 254 packages across 15 dependent modules for known vulnerabilities...

    === Symbol Results ===

    Vulnerability #1: GO-2024-2687
        HTTP/2 CONTINUATION flood in net/http
      More info: https://pkg.go.dev/vuln/GO-2024-2687
      Module: golang.org/x/net
        Found in: golang.org/x/[email protected]
        Fixed in: golang.org/x/[email protected]
        Example traces found:
          #1: events/task_fieldpath.pb.go:85:20: events.TaskIO.Field calls fmt.Sprint, which eventually calls http2.ConnectionError.Error
          #2: events/task_fieldpath.pb.go:85:20: events.TaskIO.Field calls fmt.Sprint, which eventually calls http2.ErrCode.String
          #3: events/task_fieldpath.pb.go:85:20: events.TaskIO.Field calls fmt.Sprint, which eventually calls http2.FrameHeader.String
          containerd#4: events/task_fieldpath.pb.go:85:20: events.TaskIO.Field calls fmt.Sprint, which eventually calls http2.FrameType.String
          containerd#5: events/task_fieldpath.pb.go:85:20: events.TaskIO.Field calls fmt.Sprint, which eventually calls http2.Setting.String
          containerd#6: events/task_fieldpath.pb.go:85:20: events.TaskIO.Field calls fmt.Sprint, which eventually calls http2.SettingID.String
          containerd#7: events/task_fieldpath.pb.go:85:20: events.TaskIO.Field calls fmt.Sprint, which eventually calls http2.StreamError.Error
          containerd#8: services/content/v1/content_ttrpc.pb.go:272:35: content.ttrpccontentClient.Write calls ttrpc.Client.NewStream, which eventually calls http2.chunkWriter.Write
          containerd#9: events/task_fieldpath.pb.go:85:20: events.TaskIO.Field calls fmt.Sprint, which eventually calls http2.connError.Error
          containerd#10: events/task_fieldpath.pb.go:85:20: events.TaskIO.Field calls fmt.Sprint, which eventually calls http2.duplicatePseudoHeaderError.Error
          containerd#11: events/task_fieldpath.pb.go:85:20: events.TaskIO.Field calls fmt.Sprint, which eventually calls http2.headerFieldNameError.Error
          containerd#12: events/task_fieldpath.pb.go:85:20: events.TaskIO.Field calls fmt.Sprint, which eventually calls http2.headerFieldValueError.Error
          containerd#13: events/task_fieldpath.pb.go:85:20: events.TaskIO.Field calls fmt.Sprint, which eventually calls http2.pseudoHeaderError.Error
          containerd#14: events/task_fieldpath.pb.go:85:20: events.TaskIO.Field calls fmt.Sprint, which eventually calls http2.writeData.String

    Your code is affected by 1 vulnerability from 1 module.
    This scan also found 0 vulnerabilities in packages you import and 3
    vulnerabilities in modules you require, but your code doesn't appear to call
    these vulnerabilities.
    Use '-show verbose' for more details.

After this:

    govulncheck ./...
    Scanning your code and 251 packages across 13 dependent modules for known vulnerabilities...

    === Symbol Results ===

    No vulnerabilities found.

    Your code is affected by 0 vulnerabilities.
    This scan also found 0 vulnerabilities in packages you import and 3
    vulnerabilities in modules you require, but your code doesn't appear to call
    these vulnerabilities.
    Use '-show verbose' for more details.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
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.

1 participant