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: introduce EnableVerifyError::FilesystemNotSupported error #68

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

Conversation

mvo5
Copy link
Collaborator

@mvo5 mvo5 commented Feb 14, 2025

This commit improves the UX of the error reporting when enabling fs-verity fails because the underlying filesystem does not support this. Here we currently just error with:

Inappropriate ioctl for device"

with the new code we error with:

Filesystem not supported by fs-verity

Note that the test relies on the fact that /dev/shm is not supported by fs-verity.

Closes: #59

Copy link
Collaborator

@allisonkarlitskaya allisonkarlitskaya left a comment

Choose a reason for hiding this comment

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

Thanks for this!

Can you also add some .context() at the spot where we enable fs-verity from Repository? Maybe mentioning the repository path (or even complete path to the object file) would be helpful as well, at that point.

/// Enabling fsverity failed.
#[derive(Error, Debug, PartialEq)]
pub enum EnableVerifyError {
#[error("Filesystem not supported by fs-verity")]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd describe the situation with slightly different language: the filesystem doesn't support fs-verity. The enablement code is in the filesystem, not in fs-verity.

@@ -35,12 +44,16 @@ pub struct FsVerityEnableArg {
// #define FS_IOC_ENABLE_VERITY _IOW('f', 133, struct fsverity_enable_arg)
type FsIocEnableVerity = ioctl::WriteOpcode<b'f', 133, FsVerityEnableArg>;

// ENOTTY 25 Inappropriate ioctl for device
// XXX: should we use an errno crate instead?
static ENOTTY: i32 = 25;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

@mvo5 mvo5 Feb 14, 2025

Choose a reason for hiding this comment

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

Yeah, makes sense, I removed this, I did missed this :/

@@ -53,7 +66,13 @@ pub fn fs_ioc_enable_verity<F: AsFd, H: FsVerityHashValue>(fd: F) -> std::io::Re
sig_ptr: 0,
__reserved2: [0; 11],
}),
)?;
) {
Err(e) if e.raw_os_error() == ENOTTY => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It should be possible to match directly on Err(rustix::io::Errno::ENOTTY) here, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed, silly me! Thanks and I simplified this now as suggested.

@@ -17,6 +17,15 @@ pub enum MeasureVerityError {
InvalidDigestSize { expected: u16 },
}

/// Enabling fsverity failed.
#[derive(Error, Debug, PartialEq)]
pub enum EnableVerifyError {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if this might be a bit short-sighted. Currently this is no problem because it gets smoothed out by anyhow, but in the future if we want to start reporting errors from high-level operations on the repository, maybe we want some unified error type for that?

On the other hand, we already have MeasureVerityError and we can chain those things via #from in the unified error type, I suppose.

Also: we never said we won't break API, anyway!

@mvo5 mvo5 force-pushed the fs-verity-no-fs branch 2 times, most recently from ede9fb9 to 5d04f74 Compare February 17, 2025 10:15
This commit improves the UX of the error reporting when enabling
fs-verity fails because the underlying filesystem does not support
this. Here we currently just error with:
```
Inappropriate ioctl for device"
```
with the new code we error with:
```
Filesystem not supported by fs-verity
```

Note that the test relies on the fact that /dev/shm is not supported
by fs-verity.

Closes: containers#59
Signed-off-by: Michael Vogt <[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.

Add better error reporting for common cases
2 participants