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

mount.composefs: Drop fs-verity signature verification #169

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions libcomposefs/lcfs-mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,41 +250,6 @@ static int lcfs_validate_verity_fd(struct lcfs_mount_state_s *state)
char buf[MAX_DIGEST_SIZE];
} buf;
int res;
bool require_signature;
char sig_data[1];
struct fsverity_read_metadata_arg read_metadata = { 0 };

require_signature = (state->options->flags &
LCFS_MOUNT_FLAGS_REQUIRE_FSVERITY_SIGNATURE) != 0;
if (require_signature) {
/* First ensure fs-verity is enabled for the image,
* the actual digest doesn't matter at this point. */
buf.fsv.digest_size = MAX_DIGEST_SIZE;
res = ioctl(state->fd, FS_IOC_MEASURE_VERITY, &buf.fsv);
if (res == -1) {
if (errno == ENODATA || errno == EOPNOTSUPP || errno == ENOTTY)
return -ENOVERITY;
return -errno;
}

/* If the file has verity enabled, has a signature and
* we were able to open it, then the kernel will have
* verified it against the kernel keyring, making it
* valid. So, we read just one byte of the signature,
* to validate that a signature exist in the file */

read_metadata.metadata_type = FS_VERITY_METADATA_TYPE_SIGNATURE;
read_metadata.offset = 0;
read_metadata.length = sizeof(sig_data);
read_metadata.buf_ptr = (size_t)&sig_data;

res = ioctl(state->fd, FS_IOC_READ_VERITY_METADATA, &read_metadata);
if (res == -1) {
if (errno == ENODATA)
return -ENOSIGNATURE;
return -errno;
}
}

if (state->expected_digest_len != 0) {
buf.fsv.digest_size = MAX_DIGEST_SIZE;
Expand Down
1 change: 0 additions & 1 deletion libcomposefs/lcfs-mount.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ enum lcfs_mount_flags_t {
LCFS_MOUNT_FLAGS_NONE = 0,
LCFS_MOUNT_FLAGS_REQUIRE_VERITY = (1 << 0),
LCFS_MOUNT_FLAGS_READONLY = (1 << 1),
LCFS_MOUNT_FLAGS_REQUIRE_FSVERITY_SIGNATURE = (1 << 2),
LCFS_MOUNT_FLAGS_IDMAP = (1 << 3),
LCFS_MOUNT_FLAGS_DISABLE_VERITY = (1 << 4),

Expand Down
5 changes: 0 additions & 5 deletions tools/mountcomposefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ int main(int argc, char **argv)
const char *opt_workdir = NULL;
bool opt_verity = false;
bool opt_noverity = false;
bool opt_signed = false;
bool opt_ro = false;
int opt, fd, res, userns_fd;

Expand Down Expand Up @@ -172,8 +171,6 @@ int main(int argc, char **argv)
opt_verity = true;
} else if (strcmp("noverity", key) == 0) {
opt_noverity = true;
} else if (strcmp("signed", key) == 0) {
opt_signed = true;
} else if (strcmp("upperdir", key) == 0) {
if (value == NULL)
printexit("No value specified for upperdir option\n");
Expand Down Expand Up @@ -239,8 +236,6 @@ int main(int argc, char **argv)
options.flags |= LCFS_MOUNT_FLAGS_REQUIRE_VERITY;
if (opt_noverity)
options.flags |= LCFS_MOUNT_FLAGS_DISABLE_VERITY;
if (opt_signed)
options.flags |= LCFS_MOUNT_FLAGS_REQUIRE_FSVERITY_SIGNATURE;
if (opt_ro)
options.flags |= LCFS_MOUNT_FLAGS_READONLY;

Expand Down