-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
repart: support creating CopyFile= filesystems with fs-verity files #35352
Comments
Completely on board with this, might just take me some time before I find the time to implement it |
PR on the way. |
When populating a filesytem with CopyFiles=, we first copy the files to a temporary directory. Make sure we use the (new) COPY_FS_VERITY flag when doing that copy so that the `mkfs` that we invoke can see the files with fs-verity enabled. Closes systemd#35352 Signed-off-by: Allison Karlitskaya <allison.karlitskaya@redhat.com>
@DaanDeMeyer #35401 covers the "CopyFiles=" part of this issue but this part is outstanding:
Do you have any suggestions there? I see a few options:
I'd be happy to do a patch for that one as well if you can give guidance about your preferred approach. |
When populating a filesytem with CopyFiles=, we first copy the files to a temporary directory. Make sure we use the (new) COPY_FS_VERITY flag when doing that copy so that the `mkfs` that we invoke can see the files with fs-verity enabled. Closes systemd#35352 Signed-off-by: Allison Karlitskaya <allison.karlitskaya@redhat.com>
When populating a filesytem with CopyFiles=, we first copy the files to a temporary directory. Make sure we use the (new) COPY_FS_VERITY flag when doing that copy so that the `mkfs` that we invoke can see the files with fs-verity enabled. Closes systemd#35352 Signed-off-by: Allison Karlitskaya <allison.karlitskaya@redhat.com>
When populating a filesytem with CopyFiles=, we first copy the files to a temporary directory. Make sure we use the (new) COPY_FS_VERITY flag when doing that copy so that the `mkfs` that we invoke can see the files with fs-verity enabled. Closes systemd#35352 Signed-off-by: Allison Karlitskaya <allison.karlitskaya@redhat.com>
As mentioned in the PR I think there should FsVerity= anyway, controlling whether to do verity for copied files. i figure this should then also result in "-O verity" if set to any other value than "no". |
First take: this would be difficult to implement: we'd have to perform the merkle tree calculation ourselves, in userspace. But: it's not true. We could actually benefit from our copying the files to a temporary directory. We can ask the kernel to enable fs-verity on the files in that directory, run the |
So: three modes, then?
In the final two cases we'd have verity enabled on the filesystem level. |
We currently pass the CopyFlags that we use to populate the temporary directory in the form of a constant at each of the copy_tree_at() call sites. De-duplicate that and move it into the `CopyFilesLine` struct, initializing it from the parser. Add our first non-constant flag: `fsverity=`. This can be set to `off` (the default) or `copy`, in which case we copy the fs-verity state from the source files. This arrangement is amenable to the introduction of more flags to `CopyFiles=` lines, if we want to add them in the future. Update the `repart.d(5)` manpage. Closes systemd#35352 Signed-off-by: Allison Karlitskaya <allison.karlitskaya@redhat.com>
We currently pass the CopyFlags that we use to populate the temporary directory in the form of a constant at each of the copy_tree_at() call sites. De-duplicate that and move it into the `CopyFilesLine` struct, initializing it from the parser. Add our first non-constant flag: `fsverity=`. This can be set to `off` (the default) or `copy`, in which case we copy the fs-verity state from the source files. This arrangement is amenable to the introduction of more flags to `CopyFiles=` lines, if we want to add them in the future. Update the `repart.d(5)` manpage. Closes systemd#35352 Signed-off-by: Allison Karlitskaya <allison.karlitskaya@redhat.com>
Component
systemd-repart
Is your feature request related to a problem? Please describe
I'm creating operating system images containing fs-verity-enabled files. With tytso/e2fsprogs#203 I've verified that I can create an ext4 filesystem with fs-verity-enabled files created inside of it from the start, using
mkfs.ext4 -O verity -d /path/to/files
. Unfortunately that doesn't work withsystemd-repart
andCopyFiles=
because the files are first copied to a temporary directory (like/var/tmp/.#repart7fca5bc0ddc4f765
). It takes care to copy the file data, the xattrs, the permissions, and the access times, but doesn't check for fs-verity on the source and doesn't attempt to enable it on the destination.Describe the solution you'd like
There are two options that would make me happy:
mkfs
program.FS_IOC_GETFLAGS
and enabling fs-verity with the default options;r orBonus points: currently I have to say `SYSTEMD_REPART_MKFS_OPTIONS_EXT4='-O verity'. It would be cool if there was a config option for that, instead.
Describe alternatives you've considered
I've tried manually creating the filesystem image and using CopyBlocks= to copy it into the disk image, but this is pretty inconvenient. Aside from the obvious pain of the extra step, this argument (unlike
CopyFiles
) is not resolved relative to--root
and demands to be given an absolute pathname. That makes it difficult to integrate into a build system that might be checked out in different places, without resorting to dynamically creating therepart.d/
files.The systemd version you checked that didn't have the feature you are asking for
Fedora 41, systemd 256 (256.7-1.fc41) +PAM +AUDIT +SELINUX -APPARMOR +IMA +SMACK +SECCOMP -GCRYPT +GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN -IPTC +KMOD +LIBCRYPTSETUP +LIBCRYPTSETUP_PLUGINS +LIBFDISK +PCRE2 +PWQUALITY +P11KIT +QRENCODE +TPM2 +BZIP2 +LZ4 +XZ +ZLIB +ZSTD +BPF_FRAMEWORK +XKBCOMMON +UTMP +SYSVINIT +LIBARCHIVE
The text was updated successfully, but these errors were encountered: