Skip to content

Commit

Permalink
Merge pull request #169 from cgwalters/drop-signed-check
Browse files Browse the repository at this point in the history
mount.composefs: Drop fs-verity signature verification
  • Loading branch information
alexlarsson authored Aug 7, 2023
2 parents fb0295a + 4dc4428 commit 3b0f5f9
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 41 deletions.
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

0 comments on commit 3b0f5f9

Please sign in to comment.