Message ID | 20250214123930.701998-1-Quirin.Gylstorff@siemens.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [isar-cip-core] crypt: do not assume that all system clocks are broken | expand |
On 14.02.25 13:33, Quirin Gylstorff wrote: > From: Quirin Gylstorff <quirin.gylstorff@siemens.com> > > If a system has the following characteristics: > - An unbuffered system clock which starts in the > past (e.g. 01-01-2024) > - The last disk write/mount is after that date(e.g. > 01-01-2025) > - The option broken_system_clock is set for e2fsck > > A subsequent call of `resize2fs` will always fail > as resize2fs will check if the date of the last check > is after the date of the last mount. > > The e2fsck option `-p`(prune) fixes most of these time issues and the > broken_system_clock option is not necessary on most systems. Ok, but now you are contradicting yourself from 045abe8527d6. Please sort out what we really want under which boundary conditions. > > Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com> > --- > The alternative is to delete the setting of e2fsck option or use > `resizefs --force`. The latter fix has the issue that the force option will > also disable the disk size checks > > .../initramfs-crypt-hook/files/encrypt_partition.env.tmpl | 1 + > .../initramfs-crypt-hook/files/local-top-complete | 6 ++++-- > ...tramfs-crypt-hook_0.6.bb => initramfs-crypt-hook_0.7.bb} | 3 +++ > 3 files changed, 8 insertions(+), 2 deletions(-) > rename recipes-initramfs/initramfs-crypt-hook/{initramfs-crypt-hook_0.6.bb => initramfs-crypt-hook_0.7.bb} (97%) > > diff --git a/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.env.tmpl b/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.env.tmpl > index bb93361..3c5c4c7 100644 > --- a/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.env.tmpl > +++ b/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.env.tmpl > @@ -5,3 +5,4 @@ WATCHDOG_DEV="${INITRAMFS_WATCHDOG_DEVICE}" > HASH_TYPE="${CRYPT_HASH_TYPE}" > KEY_ALGORITHM="${CRYPT_KEY_ALGORITHM}" > ENCRYPTION_IS_OPTIONAL="${CRYPT_ENCRYPTION_OPTIONAL}" > +CRYPT_BROKEN_SYSTEM_CLOCK="${CRYPT_BROKEN_SYSTEM_CLOCK}" > diff --git a/recipes-initramfs/initramfs-crypt-hook/files/local-top-complete b/recipes-initramfs/initramfs-crypt-hook/files/local-top-complete > index 54b8a6e..bb720c7 100644 > --- a/recipes-initramfs/initramfs-crypt-hook/files/local-top-complete > +++ b/recipes-initramfs/initramfs-crypt-hook/files/local-top-complete > @@ -75,11 +75,13 @@ reencrypt_existing_partition() { > case $partition_fstype in > ext*) > # reduce the filesystem and partition by 32M to fit the LUKS header > - export E2FSCK_CONFIG=/tmp/e2fsck.conf > - cat > "$E2FSCK_CONFIG" << EOF > + if [ "$CRYPT_BROKEN_SYSTEM_CLOCK" != "0" ]; then > + export E2FSCK_CONFIG=/tmp/e2fsck.conf > + cat > "$E2FSCK_CONFIG" << EOF > [options] > broken_system_clock=true > EOF > + fi > e2fsck -p -f "$1" > if ! resize2fs "$1" "${reduced_size_in_kb}"; then > panic "reencryption of partition $1 cannot continue - resizing of the partition failed!" > diff --git a/recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.6.bb b/recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.7.bb > similarity index 97% > rename from recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.6.bb > rename to recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.7.bb > index df335c9..ec2d6bc 100644 > --- a/recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.6.bb > +++ b/recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.7.bb > @@ -85,6 +85,9 @@ CRYPT_ENCRYPTION_OPTIONAL ??= "false" > # add support for btrfs encryption > CRYPT_BTRFS_SUPPORT ??= "0" > > +## do assume the system clock is broken for partition check "whether to assume..." > +CRYPT_BROKEN_SYSTEM_CLOCK ??= "0" > + > TEMPLATE_VARS += "CRYPT_PARTITIONS CRYPT_CREATE_FILE_SYSTEM_CMD \ > CRYPT_SETUP_TIMEOUT INITRAMFS_WATCHDOG_DEVICE CRYPT_HASH_TYPE \ > CRYPT_KEY_ALGORITHM CRYPT_ENCRYPTION_OPTIONAL" Jan
On 2/18/25 09:56, Jan Kiszka wrote: > On 14.02.25 13:33, Quirin Gylstorff wrote: >> From: Quirin Gylstorff <quirin.gylstorff@siemens.com> >> >> If a system has the following characteristics: >> - An unbuffered system clock which starts in the >> past (e.g. 01-01-2024) >> - The last disk write/mount is after that date(e.g. >> 01-01-2025) >> - The option broken_system_clock is set for e2fsck >> >> A subsequent call of `resize2fs` will always fail >> as resize2fs will check if the date of the last check >> is after the date of the last mount. >> >> The e2fsck option `-p`(prune) fixes most of these time issues and the >> broken_system_clock option is not necessary on most systems. > > Ok, but now you are contradicting yourself from 045abe8527d6. Please > sort out what we really want under which boundary conditions. I re-analysed it and the issue occurs if we have a running system where disk encryption is activated afterwards and the mount occurs in the system when the clock is synchronized, e.g. with the recipe `home-fs`. The original solution works as during first boot the partition was never mounted and all subsequent mounts are done with the old time. From my testing we should drop the setting the option `system_clock_broken`. Quirin > >> >> Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com> >> --- >> The alternative is to delete the setting of e2fsck option or use >> `resizefs --force`. The latter fix has the issue that the force option will >> also disable the disk size checks >> >> .../initramfs-crypt-hook/files/encrypt_partition.env.tmpl | 1 + >> .../initramfs-crypt-hook/files/local-top-complete | 6 ++++-- >> ...tramfs-crypt-hook_0.6.bb => initramfs-crypt-hook_0.7.bb} | 3 +++ >> 3 files changed, 8 insertions(+), 2 deletions(-) >> rename recipes-initramfs/initramfs-crypt-hook/{initramfs-crypt-hook_0.6.bb => initramfs-crypt-hook_0.7.bb} (97%) >> >> diff --git a/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.env.tmpl b/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.env.tmpl >> index bb93361..3c5c4c7 100644 >> --- a/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.env.tmpl >> +++ b/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.env.tmpl >> @@ -5,3 +5,4 @@ WATCHDOG_DEV="${INITRAMFS_WATCHDOG_DEVICE}" >> HASH_TYPE="${CRYPT_HASH_TYPE}" >> KEY_ALGORITHM="${CRYPT_KEY_ALGORITHM}" >> ENCRYPTION_IS_OPTIONAL="${CRYPT_ENCRYPTION_OPTIONAL}" >> +CRYPT_BROKEN_SYSTEM_CLOCK="${CRYPT_BROKEN_SYSTEM_CLOCK}" >> diff --git a/recipes-initramfs/initramfs-crypt-hook/files/local-top-complete b/recipes-initramfs/initramfs-crypt-hook/files/local-top-complete >> index 54b8a6e..bb720c7 100644 >> --- a/recipes-initramfs/initramfs-crypt-hook/files/local-top-complete >> +++ b/recipes-initramfs/initramfs-crypt-hook/files/local-top-complete >> @@ -75,11 +75,13 @@ reencrypt_existing_partition() { >> case $partition_fstype in >> ext*) >> # reduce the filesystem and partition by 32M to fit the LUKS header >> - export E2FSCK_CONFIG=/tmp/e2fsck.conf >> - cat > "$E2FSCK_CONFIG" << EOF >> + if [ "$CRYPT_BROKEN_SYSTEM_CLOCK" != "0" ]; then >> + export E2FSCK_CONFIG=/tmp/e2fsck.conf >> + cat > "$E2FSCK_CONFIG" << EOF >> [options] >> broken_system_clock=true >> EOF >> + fi >> e2fsck -p -f "$1" >> if ! resize2fs "$1" "${reduced_size_in_kb}"; then >> panic "reencryption of partition $1 cannot continue - resizing of the partition failed!" >> diff --git a/recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.6.bb b/recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.7.bb >> similarity index 97% >> rename from recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.6.bb >> rename to recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.7.bb >> index df335c9..ec2d6bc 100644 >> --- a/recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.6.bb >> +++ b/recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.7.bb >> @@ -85,6 +85,9 @@ CRYPT_ENCRYPTION_OPTIONAL ??= "false" >> # add support for btrfs encryption >> CRYPT_BTRFS_SUPPORT ??= "0" >> >> +## do assume the system clock is broken for partition check > > "whether to assume..." > >> +CRYPT_BROKEN_SYSTEM_CLOCK ??= "0" >> + >> TEMPLATE_VARS += "CRYPT_PARTITIONS CRYPT_CREATE_FILE_SYSTEM_CMD \ >> CRYPT_SETUP_TIMEOUT INITRAMFS_WATCHDOG_DEVICE CRYPT_HASH_TYPE \ >> CRYPT_KEY_ALGORITHM CRYPT_ENCRYPTION_OPTIONAL" > > Jan >
diff --git a/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.env.tmpl b/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.env.tmpl index bb93361..3c5c4c7 100644 --- a/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.env.tmpl +++ b/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.env.tmpl @@ -5,3 +5,4 @@ WATCHDOG_DEV="${INITRAMFS_WATCHDOG_DEVICE}" HASH_TYPE="${CRYPT_HASH_TYPE}" KEY_ALGORITHM="${CRYPT_KEY_ALGORITHM}" ENCRYPTION_IS_OPTIONAL="${CRYPT_ENCRYPTION_OPTIONAL}" +CRYPT_BROKEN_SYSTEM_CLOCK="${CRYPT_BROKEN_SYSTEM_CLOCK}" diff --git a/recipes-initramfs/initramfs-crypt-hook/files/local-top-complete b/recipes-initramfs/initramfs-crypt-hook/files/local-top-complete index 54b8a6e..bb720c7 100644 --- a/recipes-initramfs/initramfs-crypt-hook/files/local-top-complete +++ b/recipes-initramfs/initramfs-crypt-hook/files/local-top-complete @@ -75,11 +75,13 @@ reencrypt_existing_partition() { case $partition_fstype in ext*) # reduce the filesystem and partition by 32M to fit the LUKS header - export E2FSCK_CONFIG=/tmp/e2fsck.conf - cat > "$E2FSCK_CONFIG" << EOF + if [ "$CRYPT_BROKEN_SYSTEM_CLOCK" != "0" ]; then + export E2FSCK_CONFIG=/tmp/e2fsck.conf + cat > "$E2FSCK_CONFIG" << EOF [options] broken_system_clock=true EOF + fi e2fsck -p -f "$1" if ! resize2fs "$1" "${reduced_size_in_kb}"; then panic "reencryption of partition $1 cannot continue - resizing of the partition failed!" diff --git a/recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.6.bb b/recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.7.bb similarity index 97% rename from recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.6.bb rename to recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.7.bb index df335c9..ec2d6bc 100644 --- a/recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.6.bb +++ b/recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.7.bb @@ -85,6 +85,9 @@ CRYPT_ENCRYPTION_OPTIONAL ??= "false" # add support for btrfs encryption CRYPT_BTRFS_SUPPORT ??= "0" +## do assume the system clock is broken for partition check +CRYPT_BROKEN_SYSTEM_CLOCK ??= "0" + TEMPLATE_VARS += "CRYPT_PARTITIONS CRYPT_CREATE_FILE_SYSTEM_CMD \ CRYPT_SETUP_TIMEOUT INITRAMFS_WATCHDOG_DEVICE CRYPT_HASH_TYPE \ CRYPT_KEY_ALGORITHM CRYPT_ENCRYPTION_OPTIONAL"