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

overlay.d: s390x: add to ramdisk missing zipl #546

Merged
merged 3 commits into from
Jun 21, 2021

Conversation

nikita-dubrovskii
Copy link
Contributor

This is a fix for https://bugzilla.redhat.com/show_bug.cgi?id=1955621
When starting OCP in fips mode it immediate fails during install:

systemd[1]: Starting Check for FIPS mode...
rhcos-fips[763]: Found /etc/ignition-machine-config-encapsulated.json in Ignition config
rhcos-fips[763]: FIPS mode required; updating BLS entries
rhcos-fips[763]: Appending 'fips=1 boot=LABEL=boot' to /run/rhcos-fips/sysroot/boot/loader/entries/ostree-1-rhcos.conf
rhcos-fips[763]: /usr/sbin/rhcos-fips: line 78: zipl: command not found

Signed-off-by: Nikita Dubrovskii nikita@linux.ibm.com

@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: nikita-dubrovskii
To complete the pull request process, please assign miabbott after the PR has been reviewed.
You can assign the PR to them by writing /assign @miabbott in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

# https://github.com/dracutdevs/dracut/blob/master/modules.d/01fips/fips.sh#L146
# Dracut looks for .vmlinux-xyz.hmac, which in our case is installed not under /boot,
# but under /boot/ostree/rhcos-xxxyyyzz/. To avoid installation failure we have to
# specify BOOT_IMAGE karg.
Copy link
Member

Choose a reason for hiding this comment

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

On GRUB-supported platforms, the BOOT_IMAGE arg is already injected by GRUB into the command-line so this should Just Work. For s390x, we should check how the dracut code is intended to work, since this is something that traditional RHEL would hit as well.

Copy link
Contributor Author

@nikita-dubrovskii nikita-dubrovskii May 5, 2021

Choose a reason for hiding this comment

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

Here comes interesting part - zipl by default sets BOOT_IMAGE=0 (https://github.com/ibm-s390-linux/s390-tools/blob/master/zipl/boot/menu.c#L188). And because we don't use grub, dracut fails.
Also there is some strange issue during cosa build :

dracut: *** Including module: fips ***
mknod: /tmp/dracut/dracut.yRQ17k/initramfs/dev/random: Operation not permitted
dracut: Cannot create /dev/random
dracut: To create an initramfs with fips support, dracut has to run as root

But even with that build issue system could be installed and than booted with fips enabled, but only to rescue shell:

....
Reached target Basic System. 
[    6.818601] systemd[1]: Reached target Subsequent (Not Ignition) boot complete. 
[ [0;32m  OK   [0m] Reached target Subsequent (Not Ignition) boot complete. 
....
[ [0;32m  OK   [0m] Started Update UTMP about System Boot/Shutdown. 
[ [0;32m  OK   [0m] Reached target System Initialization. 
[ [0;32m  OK   [0m] Started Rescue Shell. 
[ [0;32m  OK   [0m] Reached target Rescue Mode. 

bash-4.4# systemctl --failed
systemctl --failed  
0 loaded units listed. Pass --all to see loaded but inactive units, too.  
To show all installed unit files use 'systemctl list-unit-files'.  

bash-4.4# cat /proc/sys/crypto/fips_enabled
cat /proc/sys/crypto/fips_enabled  
1  

bash-4.4# cat /proc/cmdline
cat /proc/cmdline  
title Red Hat Enterprise Linux CoreOS 47.83.202105041333-0 (Ootpa) (ostree:0) version 1 linux /ostree/rhcos-d340df313fd21722c7cce92e
d638a871644cdbddeec1a34dcc3eccb0121e66f6/vmlinuz-4.18.0-240.22.1.el8_3.s390x initrd /ostree/rhcos-d340df313fd21722c7cce92ed638a87164
4cdbddeec1a34dcc3eccb0121e66f6/initramfs-4.18.0-240.22.1.el8_3.s390x.img options random.trust_cpu=on ignition.platform.id=metal $ign
ition_firstboot ostree=/ostree/boot.1/rhcos/d340df313fd21722c7cce92ed638a871644cdbddeec1a34dcc3eccb0121e66f6/0 rd.znet=qeth,0.0.bdf0
,0.0.bdf1,0.0.bdf2,layer2=1,portno=0 zfcp.allow_lun_scan=0 cio_ignore=all,!condev rd.dasd=0.0.6609 fips=1 boot=LABEL=boot BOOT_IMAGE
=/ostree/rhcos-d340df313fd21722c7cce92ed638a871644cdbddeec1a34dcc3eccb0121e66f6/vmlinuz-4.18.0-240.22.1.el8_3.s390x  

bash-4.4# systemd-analyze blame
systemd-analyze blame  
          2.453s dracut-pre-udev.service  
          1.502s lvm2-monitor.service  
          1.276s initrd-switch-root.service  
          1.013s systemd-journald.service  
           920ms systemd-hwdb-update.service  
           699ms dracut-cmdline.service  
           671ms systemd-udev-trigger.service  
           665ms dracut-pre-trigger.service  
           509ms initrd-parse-etc.service  
           497ms systemd-udev-settle.service  
           410ms systemd-tmpfiles-setup-dev.service  
           400ms systemd-sysctl.service  
           372ms systemd-udevd.service  
           361ms systemd-sysusers.service  
           361ms systemd-modules-load.service  
           338ms systemd-tmpfiles-setup.service  
           285ms systemd-journal-flush.service  
           283ms device_cio_free.service  
           281ms systemd-journal-catalog-update.service  
           276ms systemd-fsck@dev-disk-by\x2dlabel-boot.service
           251ms systemd-vconsole-setup.service  
           189ms dracut-pre-pivot.service  
           171ms systemd-update-utmp.service  
           170ms systemd-random-seed.service  
           156ms iscsiuio.service  
           147ms systemd-update-done.service  
           141ms ldconfig.service  
           135ms iscsid.service  
           109ms initrd-cleanup.service  
           107ms initrd-udevadm-cleanup-db.service  
           106ms systemd-update-utmp-runlevel.service
           100ms kmod-static-nodes.service  
            51ms dev-hugepages.mount  
            50ms dev-mqueue.mount  
            49ms dracut-pre-mount.service  
            48ms sys-kernel-debug.mount  
            30ms sys-fs-fuse-connections.mount  
            22ms boot.mount  
            19ms multipathd.service  
            18ms dracut-shutdown.service  
            13ms sys-kernel-config.mount  
             8ms dracut-initqueue.service  
             2ms var.mount  

Don't you know why Ignition hadn't run at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also i wonder why ostreedev/ostree#1962 doesn't work.

[    5.802578] dracut-pre-trigger[719]: Mounting /dev/disk/by-label/boot as /boot 
[    5.841955] SGI XFS with ACLs, security attributes, no debug enabled 
[    5.876049] XFS (dasda2): Mounting V5 Filesystem 
[    5.882649] EXT4-fs (dasda1): mounted filesystem with ordered data mode. Opts: (null) 
[    5.883933] dracut-pre-trigger[719]: Checking integrity of kernel 
[    5.886162] dracut: FATAL: FIPS integrity test failed 
[    5.886166] dracut: Refusing to continue 
[    5.886269] dracut-pre-trigger[719]: Warning: /boot//.vmlinuz-4.18.0-240.22.1.el8_3.s390x.hmac does not exist 
[    5.886280] dracut-pre-trigger[719]: Warning: /boot//.vmlinuz-4.18.0-240.22.1.el8_3.s390x.hmac does not exist 
[    5.917621] XFS (dasda2): Ending clean mount 
[    5.917951] XFS (dasda2): Quotacheck needed: Please wait. 
[    5.982502] systemd[1]: Shutting down. 

Please correct me if i'm wrong - rpm-ostree doesn't create anything during install (because we just copy osmet image) and later during firstboot . Or should it create those *.hmac during cosa build*** ?

Copy link
Member

Choose a reason for hiding this comment

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

Also there is some strange issue during cosa build :

We can ignore those issues, see: coreos/rpm-ostree#1951

Here comes interesting part - zipl by default sets BOOT_IMAGE=0 (https://github.com/ibm-s390-linux/s390-tools/blob/master/zipl/boot/menu.c#L188). And because we don't use grub, dracut fails.
Also i wonder why ostreedev/ostree#1962 doesn't work.

Ahh OK, I think I see what's going on here.

So, on OSTree systems, the kernel, HMAC file, and initramfs are placed under /boot/ostree/$name-$hash/.

On GRUB systems, the BOOT_IMAGE is a path to the kernel image, and the dracut FIPS code uses that to also find the HMAC file.

It looks like on s390x, the BOOT_IMAGE is an integer representing the index of the configuration that was booted into? Does this roughly correspond to the version field of the BLS config?

Anyway, I think what's going on here is that dracut doesn't know how to use this field and so just ignores it and falls back to trying it in the root of /boot. This works fine on traditional systems because the kernel and HMAC files are indeed placed at the root of the boot partition. So this only breaks on OSTree systems.

Hmm, ideally we would teach dracut how to use this index to figure out the kernel path from it (and so the HMAC path). Do you think mapping the index back to the BLS is feasible or is it too error-prone? I suspect there might not actually be any traces of where the configuration came from once it's written out by zipl (or maybe there's some extra metadata we can shove in there?). /cc @martinezjavier

I don't think we should pre-inject BOOT_IMAGE like this patch is doing. Definitely wouldn't want to do this on GRUB platforms, since it contains dynamic information about e.g. which devices was actually used. But even on s390x, it's possible that there are tools which expect an integer there for their purposes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, on OSTree systems, the kernel, HMAC file, and initramfs are placed under /boot/ostree/$name-$hash/.

exactly. and becuase

on s390x, the BOOT_IMAGE is an integer representing the index of the configuration that was booted

i had to modify BOOT_IMAGE + nikita-dubrovskii/s390-tools@70dde0e . I've asked zipl experts about this, maybe it would be possible to mimic grub here.

So with all those patches system runs (rescue shell) with fips, but ignition is skipped.
Could fips affect ignition ? I use my own simple rhcos.ign augmented with https://github.com/coreos/coreos-assembler/blob/master/mantle/kola/tests/fips/fips.go#L25

Copy link
Member

Choose a reason for hiding this comment

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

From my naive reading of https://github.com/ibm-s390-linux/s390-tools/blob/master/zipl/boot/menu.c, I think it represents the index of the menu entry that was selected, so 0 is expected. The question is whether we can go from there and map it back to e.g. the vmlinuz path. Because if so, then we can teach dracut to use it.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh..right...yeah it's always 0. not sure if there is a good way to map it to the kernel/initramfs.let me ask around.

Copy link
Contributor

Choose a reason for hiding this comment

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

so after talking to a few folks looks like there is no good way to map the index back to the BLS entry.

Copy link
Member

Choose a reason for hiding this comment

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

In that case, I think I agree that ibm-s390-linux/s390-tools#78 is the best way to solve this, even if it happens at "boot record writing" time. If we can't change the existing semantics of BOOT_IMAGE=N, then maybe best to have a separate variable for this, e.g. BOOT_IMAGE_PATH.

One hack we could do is to have ostree on s390x symlink all the kernel and HMAC files from the root of the boot partition, but... yuck. (And you get into the question of what to do if somehow two vmlinuz files named the same across deployments somehow don't have the same checksum.)

Copy link
Member

Choose a reason for hiding this comment

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

@cgwalters cgwalters changed the title overlay.d: s390x: add to ramdisk missig zipl overlay.d: s390x: add to ramdisk missing zipl May 17, 2021
@miabbott
Copy link
Member

I spoke with the OCP Multi Arch team and was told that FIPS on s390x has never been supported, so the original BZ has been closed in favor of an RFE - https://issues.redhat.com/browse/MULTIARCH-690

It was suggested that we can stop pursuing this fix and let the Multi Arch team do the necessary enablement of FIPS.

@jlebon
Copy link
Member

jlebon commented Jun 15, 2021

Chatted with @nikita-dubrovskii about this.

To re-iterate, IMO ideally we wouldn't carry any special code for this here but instead patch dracut as necessary. The reason it happens to work in non-OSTree s390x systems today is because kernel images are placed in the root of the boot partition. But any other system like OSTree which strays from that will trip on the same issue.

There's no room to change BOOT_IMAGE to conform the other arches because of backwards compatibility (see ibm-s390-linux/s390-tools#78). One idea was to have libostree (specifically, the zipl bootloader backend) manually inject a BOOT_IMAGE_PATH=/ostree/$osname-.../vmlinuz-... karg when translating the BLS configs and then teach dracut's FIPS module to look for both BOOT_IMAGE and BOOT_IMAGE_PATH. There's some concerns however about using up precious kernel cmdline space (apparently, there's only room for 896 bytes of data).

Maybe instead, we should just roll with it and simply teach dracut how to use the BOOT_IMAGE=N karg. So here's my idea: we change dracut on s390x to first check the root of the boot partition as usual, but otherwise fall back to looking at BLS entry N (the value of BOOT_IMAGE) and extract the kernel path from there in order to find the HMAC file. This isn't fully correct, because it assumes that there are only BLS entries (which is safe to assume for FCOS/RHCOS), but we would've failed anyway so it's an improvement. (And worst case, validation simply fails still.)

time passes

OK, ended up writing a dracut patch for this:

diff --git a/modules.d/01fips/fips.sh b/modules.d/01fips/fips.sh
index 821c26a2..fcaa798e 100755
--- a/modules.d/01fips/fips.sh
+++ b/modules.d/01fips/fips.sh
@@ -124,6 +124,21 @@ do_fips() {
     else
         BOOT_IMAGE="$(getarg BOOT_IMAGE)"
 
+        # On s390x, BOOT_IMAGE isn't a path but an integer representing the
+        # entry number selected. Let's try the root of /boot first, and
+        # otherwise fallback to trying to parse the BLS entries if it's a
+        # BLS-based system.
+        if [[ $(uname -m) == s390x ]]; then
+            if [ -e "/boot/vmlinuz-${KERNEL}" ]; then
+                BOOT_IMAGE="vmlinuz-${KERNEL}"
+            elif [ -d /boot/loader/entries ]; then
+                bls=$(ls -v -r /boot/loader/entries/*.conf | sed -n "$((BOOT_IMAGE + 1))p")
+                if [ -e "${bls}" ]; then
+                    BOOT_IMAGE=$(grep ^linux "${bls}" | cut -d' ' -f2)
+                fi
+            fi
+        fi
+
         # Trim off any leading GRUB boot device (e.g. ($root) )
         BOOT_IMAGE="$(echo "${BOOT_IMAGE}" | sed 's/^(.*)//')"

@nikita-dubrovskii Do you want to try that and hack on top of it if needed?

@madeelibm
Copy link
Contributor

@jlebon @nikita-dubrovskii I have tested the fips.sh changes and it works flawlessly!

@jlebon
Copy link
Member

jlebon commented Jun 17, 2021

@madeelibm Thanks for testing, I opened dracutdevs/dracut#1539 for it.

@jlebon
Copy link
Member

jlebon commented Jun 17, 2021

@nikita-dubrovskii Can you drop the second commit in this PR?

@nikita-dubrovskii
Copy link
Contributor Author

@nikita-dubrovskii Can you drop the second commit in this PR?

i did. today had no time to test it, but i guess we anyhow should keep sed -e "/^options / s/$/ ignition.firstboot /" -i "$tmpfile"
tomorrow will check

@madeelibm
Copy link
Contributor

ignition.firstboot is needed, please see: #565

@nikita-dubrovskii nikita-dubrovskii force-pushed the fips branch 2 times, most recently from 50dc821 to 18247db Compare June 18, 2021 10:42
This is a fix for https://bugzilla.redhat.com/show_bug.cgi?id=1955621
When starting OCP in fips mode it immediate fails during install:
```
systemd[1]: Starting Check for FIPS mode...
rhcos-fips[763]: Found /etc/ignition-machine-config-encapsulated.json in Ignition config
rhcos-fips[763]: FIPS mode required; updating BLS entries
rhcos-fips[763]: Appending 'fips=1 boot=LABEL=boot' to /run/rhcos-fips/sysroot/boot/loader/entries/ostree-1-rhcos.conf
rhcos-fips[763]: /usr/sbin/rhcos-fips: line 78: zipl: command not found
```

Signed-off-by: Nikita Dubrovskii <nikita@linux.ibm.com>
jlebon added a commit to jlebon/dracut that referenced this pull request Jun 18, 2021
On s390x, the `BOOT_IMAGE` karg injected by the bootloader is not a path
to the kernel image, but rather an integer describing the index of the
menu entry selected. Because of the way the s390x bootloader works,
there is no information retained about e.g. the path of the kernel that
was loaded.

This causes issues for the FIPS code which assumes that `BOOT_IMAGE` is
a path to the kernel image to derive the HMAC path. In non-OSTree
systems, this ends up working anyway, because the kernel is located at
the root of the boot partition.  In OSTree systems, this is not the
case. However, OSTree systems use BLS configs, and they are named in
reverse order of precedence (i.e. menu ordering). So from the
`BOOT_IMAGE` integer, we can figure out which BLS entry was selected.

Add some code to do just this on s390x. This isn't completely foolproof,
because it presumes that (1) BLS configs were used to populate the
bootloader (and that they were exactly in the same state they currently
are when `zipl` was run), and (2) there are no other menu entries
originating from outside the BLS configs. However, if these assumptions
are wrong we would simply fail the boot, which is currently what is
happening anyway.

See also:
openshift/os#546
ibm-s390-linux/s390-tools#78

Tested-by: Muhammad Adeel <muhammad.adeel@ibm.com>
madeelibm and others added 2 commits June 21, 2021 08:27
Zipl expects only kernel command line options in the parmfile.
If a whole bls file is provided as a parmfile, the system will
not be able to boot and switch to rescue mode after reboot.
… zipl

We enable FIPS during firstboot and than reboot the machine before ignition runs,
so to allow it do its work on next boot with enabled FIPS, we have to save ignition.firstboot karg

Signed-off-by: Nikita Dubrovskii <nikita@linux.ibm.com>
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jun 21, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 21, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jlebon, nikita-dubrovskii

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit 1a0553a into openshift:master Jun 21, 2021
johannbg pushed a commit to dracutdevs/dracut that referenced this pull request Jun 28, 2021
On s390x, the `BOOT_IMAGE` karg injected by the bootloader is not a path
to the kernel image, but rather an integer describing the index of the
menu entry selected. Because of the way the s390x bootloader works,
there is no information retained about e.g. the path of the kernel that
was loaded.

This causes issues for the FIPS code which assumes that `BOOT_IMAGE` is
a path to the kernel image to derive the HMAC path. In non-OSTree
systems, this ends up working anyway, because the kernel is located at
the root of the boot partition.  In OSTree systems, this is not the
case. However, OSTree systems use BLS configs, and they are named in
reverse order of precedence (i.e. menu ordering). So from the
`BOOT_IMAGE` integer, we can figure out which BLS entry was selected.

Add some code to do just this on s390x. This isn't completely foolproof,
because it presumes that (1) BLS configs were used to populate the
bootloader (and that they were exactly in the same state they currently
are when `zipl` was run), and (2) there are no other menu entries
originating from outside the BLS configs. However, if these assumptions
are wrong we would simply fail the boot, which is currently what is
happening anyway.

See also:
openshift/os#546
ibm-s390-linux/s390-tools#78

Tested-by: Muhammad Adeel <muhammad.adeel@ibm.com>
pvalena pushed a commit to pvalena/dracut-rhel8 that referenced this pull request Jan 19, 2022
On s390x, the `BOOT_IMAGE` karg injected by the bootloader is not a path
to the kernel image, but rather an integer describing the index of the
menu entry selected. Because of the way the s390x bootloader works,
there is no information retained about e.g. the path of the kernel that
was loaded.

This causes issues for the FIPS code which assumes that `BOOT_IMAGE` is
a path to the kernel image to derive the HMAC path. In non-OSTree
systems, this ends up working anyway, because the kernel is located at
the root of the boot partition.  In OSTree systems, this is not the
case. However, OSTree systems use BLS configs, and they are named in
reverse order of precedence (i.e. menu ordering). So from the
`BOOT_IMAGE` integer, we can figure out which BLS entry was selected.

Add some code to do just this on s390x. This isn't completely foolproof,
because it presumes that (1) BLS configs were used to populate the
bootloader (and that they were exactly in the same state they currently
are when `zipl` was run), and (2) there are no other menu entries
originating from outside the BLS configs. However, if these assumptions
are wrong we would simply fail the boot, which is currently what is
happening anyway.

See also:
openshift/os#546
ibm-s390-linux/s390-tools#78

Tested-by: Muhammad Adeel <muhammad.adeel@ibm.com>
pvalena pushed a commit to pvalena/dracut-rhel8 that referenced this pull request Jan 19, 2022
On s390x, the `BOOT_IMAGE` karg injected by the bootloader is not a path
to the kernel image, but rather an integer describing the index of the
menu entry selected. Because of the way the s390x bootloader works,
there is no information retained about e.g. the path of the kernel that
was loaded.

This causes issues for the FIPS code which assumes that `BOOT_IMAGE` is
a path to the kernel image to derive the HMAC path. In non-OSTree
systems, this ends up working anyway, because the kernel is located at
the root of the boot partition.  In OSTree systems, this is not the
case. However, OSTree systems use BLS configs, and they are named in
reverse order of precedence (i.e. menu ordering). So from the
`BOOT_IMAGE` integer, we can figure out which BLS entry was selected.

Add some code to do just this on s390x. This isn't completely foolproof,
because it presumes that (1) BLS configs were used to populate the
bootloader (and that they were exactly in the same state they currently
are when `zipl` was run), and (2) there are no other menu entries
originating from outside the BLS configs. However, if these assumptions
are wrong we would simply fail the boot, which is currently what is
happening anyway.

See also:
openshift/os#546
ibm-s390-linux/s390-tools#78

Tested-by: Muhammad Adeel <muhammad.adeel@ibm.com>

Resolves: rhbz#2007586
pvalena pushed a commit to pvalena/dracut-rhel8 that referenced this pull request Jan 26, 2022
On s390x, the `BOOT_IMAGE` karg injected by the bootloader is not a path
to the kernel image, but rather an integer describing the index of the
menu entry selected. Because of the way the s390x bootloader works,
there is no information retained about e.g. the path of the kernel that
was loaded.

This causes issues for the FIPS code which assumes that `BOOT_IMAGE` is
a path to the kernel image to derive the HMAC path. In non-OSTree
systems, this ends up working anyway, because the kernel is located at
the root of the boot partition.  In OSTree systems, this is not the
case. However, OSTree systems use BLS configs, and they are named in
reverse order of precedence (i.e. menu ordering). So from the
`BOOT_IMAGE` integer, we can figure out which BLS entry was selected.

Add some code to do just this on s390x. This isn't completely foolproof,
because it presumes that (1) BLS configs were used to populate the
bootloader (and that they were exactly in the same state they currently
are when `zipl` was run), and (2) there are no other menu entries
originating from outside the BLS configs. However, if these assumptions
are wrong we would simply fail the boot, which is currently what is
happening anyway.

See also:
openshift/os#546
ibm-s390-linux/s390-tools#78

Tested-by: Muhammad Adeel <muhammad.adeel@ibm.com>

Resolves: rhbz#2007586
lnykryn pushed a commit to redhat-plumbers/dracut-rhel8 that referenced this pull request Jan 26, 2022
On s390x, the `BOOT_IMAGE` karg injected by the bootloader is not a path
to the kernel image, but rather an integer describing the index of the
menu entry selected. Because of the way the s390x bootloader works,
there is no information retained about e.g. the path of the kernel that
was loaded.

This causes issues for the FIPS code which assumes that `BOOT_IMAGE` is
a path to the kernel image to derive the HMAC path. In non-OSTree
systems, this ends up working anyway, because the kernel is located at
the root of the boot partition.  In OSTree systems, this is not the
case. However, OSTree systems use BLS configs, and they are named in
reverse order of precedence (i.e. menu ordering). So from the
`BOOT_IMAGE` integer, we can figure out which BLS entry was selected.

Add some code to do just this on s390x. This isn't completely foolproof,
because it presumes that (1) BLS configs were used to populate the
bootloader (and that they were exactly in the same state they currently
are when `zipl` was run), and (2) there are no other menu entries
originating from outside the BLS configs. However, if these assumptions
are wrong we would simply fail the boot, which is currently what is
happening anyway.

See also:
openshift/os#546
ibm-s390-linux/s390-tools#78

Tested-by: Muhammad Adeel <muhammad.adeel@ibm.com>

Resolves: rhbz#2007586
systemd-rhel-bot pushed a commit to systemd-rhel-bot/dracut-rhel9 that referenced this pull request Feb 9, 2022
On s390x, the `BOOT_IMAGE` karg injected by the bootloader is not a path
to the kernel image, but rather an integer describing the index of the
menu entry selected. Because of the way the s390x bootloader works,
there is no information retained about e.g. the path of the kernel that
was loaded.

This causes issues for the FIPS code which assumes that `BOOT_IMAGE` is
a path to the kernel image to derive the HMAC path. In non-OSTree
systems, this ends up working anyway, because the kernel is located at
the root of the boot partition.  In OSTree systems, this is not the
case. However, OSTree systems use BLS configs, and they are named in
reverse order of precedence (i.e. menu ordering). So from the
`BOOT_IMAGE` integer, we can figure out which BLS entry was selected.

Add some code to do just this on s390x. This isn't completely foolproof,
because it presumes that (1) BLS configs were used to populate the
bootloader (and that they were exactly in the same state they currently
are when `zipl` was run), and (2) there are no other menu entries
originating from outside the BLS configs. However, if these assumptions
are wrong we would simply fail the boot, which is currently what is
happening anyway.

See also:
openshift/os#546
ibm-s390-linux/s390-tools#78

Tested-by: Muhammad Adeel <muhammad.adeel@ibm.com>
(cherry picked from commit 78557f0)

Resolves: #2050567
systemd-rhel-bot pushed a commit to systemd-rhel-bot/dracut-rhel9 that referenced this pull request Feb 14, 2022
On s390x, the `BOOT_IMAGE` karg injected by the bootloader is not a path
to the kernel image, but rather an integer describing the index of the
menu entry selected. Because of the way the s390x bootloader works,
there is no information retained about e.g. the path of the kernel that
was loaded.

This causes issues for the FIPS code which assumes that `BOOT_IMAGE` is
a path to the kernel image to derive the HMAC path. In non-OSTree
systems, this ends up working anyway, because the kernel is located at
the root of the boot partition.  In OSTree systems, this is not the
case. However, OSTree systems use BLS configs, and they are named in
reverse order of precedence (i.e. menu ordering). So from the
`BOOT_IMAGE` integer, we can figure out which BLS entry was selected.

Add some code to do just this on s390x. This isn't completely foolproof,
because it presumes that (1) BLS configs were used to populate the
bootloader (and that they were exactly in the same state they currently
are when `zipl` was run), and (2) there are no other menu entries
originating from outside the BLS configs. However, if these assumptions
are wrong we would simply fail the boot, which is currently what is
happening anyway.

See also:
openshift/os#546
ibm-s390-linux/s390-tools#78

Tested-by: Muhammad Adeel <muhammad.adeel@ibm.com>
(cherry picked from commit 78557f0)

Resolves: #2050567
pvalena pushed a commit to pvalena/dracut-rhel9 that referenced this pull request Feb 15, 2022
On s390x, the `BOOT_IMAGE` karg injected by the bootloader is not a path
to the kernel image, but rather an integer describing the index of the
menu entry selected. Because of the way the s390x bootloader works,
there is no information retained about e.g. the path of the kernel that
was loaded.

This causes issues for the FIPS code which assumes that `BOOT_IMAGE` is
a path to the kernel image to derive the HMAC path. In non-OSTree
systems, this ends up working anyway, because the kernel is located at
the root of the boot partition.  In OSTree systems, this is not the
case. However, OSTree systems use BLS configs, and they are named in
reverse order of precedence (i.e. menu ordering). So from the
`BOOT_IMAGE` integer, we can figure out which BLS entry was selected.

Add some code to do just this on s390x. This isn't completely foolproof,
because it presumes that (1) BLS configs were used to populate the
bootloader (and that they were exactly in the same state they currently
are when `zipl` was run), and (2) there are no other menu entries
originating from outside the BLS configs. However, if these assumptions
are wrong we would simply fail the boot, which is currently what is
happening anyway.

See also:
openshift/os#546
ibm-s390-linux/s390-tools#78

Tested-by: Muhammad Adeel <muhammad.adeel@ibm.com>

Resolves: rhbz#2007586
pvalena pushed a commit to pvalena/dracut-rhel9 that referenced this pull request Feb 15, 2022
On s390x, the `BOOT_IMAGE` karg injected by the bootloader is not a path
to the kernel image, but rather an integer describing the index of the
menu entry selected. Because of the way the s390x bootloader works,
there is no information retained about e.g. the path of the kernel that
was loaded.

This causes issues for the FIPS code which assumes that `BOOT_IMAGE` is
a path to the kernel image to derive the HMAC path. In non-OSTree
systems, this ends up working anyway, because the kernel is located at
the root of the boot partition.  In OSTree systems, this is not the
case. However, OSTree systems use BLS configs, and they are named in
reverse order of precedence (i.e. menu ordering). So from the
`BOOT_IMAGE` integer, we can figure out which BLS entry was selected.

Add some code to do just this on s390x. This isn't completely foolproof,
because it presumes that (1) BLS configs were used to populate the
bootloader (and that they were exactly in the same state they currently
are when `zipl` was run), and (2) there are no other menu entries
originating from outside the BLS configs. However, if these assumptions
are wrong we would simply fail the boot, which is currently what is
happening anyway.

See also:
openshift/os#546
ibm-s390-linux/s390-tools#78

Tested-by: Muhammad Adeel <muhammad.adeel@ibm.com>

Resolves: rhbz#2050567
pvalena pushed a commit to redhat-plumbers/dracut-rhel9 that referenced this pull request Feb 15, 2022
On s390x, the `BOOT_IMAGE` karg injected by the bootloader is not a path
to the kernel image, but rather an integer describing the index of the
menu entry selected. Because of the way the s390x bootloader works,
there is no information retained about e.g. the path of the kernel that
was loaded.

This causes issues for the FIPS code which assumes that `BOOT_IMAGE` is
a path to the kernel image to derive the HMAC path. In non-OSTree
systems, this ends up working anyway, because the kernel is located at
the root of the boot partition.  In OSTree systems, this is not the
case. However, OSTree systems use BLS configs, and they are named in
reverse order of precedence (i.e. menu ordering). So from the
`BOOT_IMAGE` integer, we can figure out which BLS entry was selected.

Add some code to do just this on s390x. This isn't completely foolproof,
because it presumes that (1) BLS configs were used to populate the
bootloader (and that they were exactly in the same state they currently
are when `zipl` was run), and (2) there are no other menu entries
originating from outside the BLS configs. However, if these assumptions
are wrong we would simply fail the boot, which is currently what is
happening anyway.

See also:
openshift/os#546
ibm-s390-linux/s390-tools#78

Tested-by: Muhammad Adeel <muhammad.adeel@ibm.com>

Resolves: rhbz#2050567
pvalena pushed a commit to pvalena/dracut-rhel9 that referenced this pull request Jun 30, 2022
On s390x, the `BOOT_IMAGE` karg injected by the bootloader is not a path
to the kernel image, but rather an integer describing the index of the
menu entry selected. Because of the way the s390x bootloader works,
there is no information retained about e.g. the path of the kernel that
was loaded.

This causes issues for the FIPS code which assumes that `BOOT_IMAGE` is
a path to the kernel image to derive the HMAC path. In non-OSTree
systems, this ends up working anyway, because the kernel is located at
the root of the boot partition.  In OSTree systems, this is not the
case. However, OSTree systems use BLS configs, and they are named in
reverse order of precedence (i.e. menu ordering). So from the
`BOOT_IMAGE` integer, we can figure out which BLS entry was selected.

Add some code to do just this on s390x. This isn't completely foolproof,
because it presumes that (1) BLS configs were used to populate the
bootloader (and that they were exactly in the same state they currently
are when `zipl` was run), and (2) there are no other menu entries
originating from outside the BLS configs. However, if these assumptions
are wrong we would simply fail the boot, which is currently what is
happening anyway.

See also:
openshift/os#546
ibm-s390-linux/s390-tools#78

Tested-by: Muhammad Adeel <muhammad.adeel@ibm.com>

Resolves: rhbz#2050567
pvalena pushed a commit to pvalena/dracut that referenced this pull request Jul 1, 2022
On s390x, the `BOOT_IMAGE` karg injected by the bootloader is not a path
to the kernel image, but rather an integer describing the index of the
menu entry selected. Because of the way the s390x bootloader works,
there is no information retained about e.g. the path of the kernel that
was loaded.

This causes issues for the FIPS code which assumes that `BOOT_IMAGE` is
a path to the kernel image to derive the HMAC path. In non-OSTree
systems, this ends up working anyway, because the kernel is located at
the root of the boot partition.  In OSTree systems, this is not the
case. However, OSTree systems use BLS configs, and they are named in
reverse order of precedence (i.e. menu ordering). So from the
`BOOT_IMAGE` integer, we can figure out which BLS entry was selected.

Add some code to do just this on s390x. This isn't completely foolproof,
because it presumes that (1) BLS configs were used to populate the
bootloader (and that they were exactly in the same state they currently
are when `zipl` was run), and (2) there are no other menu entries
originating from outside the BLS configs. However, if these assumptions
are wrong we would simply fail the boot, which is currently what is
happening anyway.

See also:
openshift/os#546
ibm-s390-linux/s390-tools#78

Tested-by: Muhammad Adeel <muhammad.adeel@ibm.com>

Resolves: rhbz#2050567
pvalena pushed a commit to pvalena/dracut-rhel9 that referenced this pull request Jul 1, 2022
On s390x, the `BOOT_IMAGE` karg injected by the bootloader is not a path
to the kernel image, but rather an integer describing the index of the
menu entry selected. Because of the way the s390x bootloader works,
there is no information retained about e.g. the path of the kernel that
was loaded.

This causes issues for the FIPS code which assumes that `BOOT_IMAGE` is
a path to the kernel image to derive the HMAC path. In non-OSTree
systems, this ends up working anyway, because the kernel is located at
the root of the boot partition.  In OSTree systems, this is not the
case. However, OSTree systems use BLS configs, and they are named in
reverse order of precedence (i.e. menu ordering). So from the
`BOOT_IMAGE` integer, we can figure out which BLS entry was selected.

Add some code to do just this on s390x. This isn't completely foolproof,
because it presumes that (1) BLS configs were used to populate the
bootloader (and that they were exactly in the same state they currently
are when `zipl` was run), and (2) there are no other menu entries
originating from outside the BLS configs. However, if these assumptions
are wrong we would simply fail the boot, which is currently what is
happening anyway.

See also:
openshift/os#546
ibm-s390-linux/s390-tools#78

Tested-by: Muhammad Adeel <muhammad.adeel@ibm.com>

Resolves: rhbz#2050567
pvalena pushed a commit to pvalena/dracut-rhel9 that referenced this pull request Jul 8, 2022
On s390x, the `BOOT_IMAGE` karg injected by the bootloader is not a path
to the kernel image, but rather an integer describing the index of the
menu entry selected. Because of the way the s390x bootloader works,
there is no information retained about e.g. the path of the kernel that
was loaded.

This causes issues for the FIPS code which assumes that `BOOT_IMAGE` is
a path to the kernel image to derive the HMAC path. In non-OSTree
systems, this ends up working anyway, because the kernel is located at
the root of the boot partition.  In OSTree systems, this is not the
case. However, OSTree systems use BLS configs, and they are named in
reverse order of precedence (i.e. menu ordering). So from the
`BOOT_IMAGE` integer, we can figure out which BLS entry was selected.

Add some code to do just this on s390x. This isn't completely foolproof,
because it presumes that (1) BLS configs were used to populate the
bootloader (and that they were exactly in the same state they currently
are when `zipl` was run), and (2) there are no other menu entries
originating from outside the BLS configs. However, if these assumptions
are wrong we would simply fail the boot, which is currently what is
happening anyway.

See also:
openshift/os#546
ibm-s390-linux/s390-tools#78

Tested-by: Muhammad Adeel <muhammad.adeel@ibm.com>

Resolves: rhbz#2050567
pvalena added a commit to pvalena/dracut-rhel9 that referenced this pull request Jul 12, 2022
On s390x, the `BOOT_IMAGE` karg injected by the bootloader is not a path
to the kernel image, but rather an integer describing the index of the
menu entry selected. Because of the way the s390x bootloader works,
there is no information retained about e.g. the path of the kernel that
was loaded.

This causes issues for the FIPS code which assumes that `BOOT_IMAGE` is
a path to the kernel image to derive the HMAC path. In non-OSTree
systems, this ends up working anyway, because the kernel is located at
the root of the boot partition.  In OSTree systems, this is not the
case. However, OSTree systems use BLS configs, and they are named in
reverse order of precedence (i.e. menu ordering). So from the
`BOOT_IMAGE` integer, we can figure out which BLS entry was selected.

Add some code to do just this on s390x. This isn't completely foolproof,
because it presumes that (1) BLS configs were used to populate the
bootloader (and that they were exactly in the same state they currently
are when `zipl` was run), and (2) there are no other menu entries
originating from outside the BLS configs. However, if these assumptions
are wrong we would simply fail the boot, which is currently what is
happening anyway.

Refactored to enhance readability.

See also:
openshift/os#546
ibm-s390-linux/s390-tools#78

Tested-by: Muhammad Adeel <muhammad.adeel@ibm.com>

Resolves: rhbz#2050567
lnykryn pushed a commit to redhat-plumbers/dracut-rhel9 that referenced this pull request Aug 17, 2022
On s390x, the `BOOT_IMAGE` karg injected by the bootloader is not a path
to the kernel image, but rather an integer describing the index of the
menu entry selected. Because of the way the s390x bootloader works,
there is no information retained about e.g. the path of the kernel that
was loaded.

This causes issues for the FIPS code which assumes that `BOOT_IMAGE` is
a path to the kernel image to derive the HMAC path. In non-OSTree
systems, this ends up working anyway, because the kernel is located at
the root of the boot partition.  In OSTree systems, this is not the
case. However, OSTree systems use BLS configs, and they are named in
reverse order of precedence (i.e. menu ordering). So from the
`BOOT_IMAGE` integer, we can figure out which BLS entry was selected.

Add some code to do just this on s390x. This isn't completely foolproof,
because it presumes that (1) BLS configs were used to populate the
bootloader (and that they were exactly in the same state they currently
are when `zipl` was run), and (2) there are no other menu entries
originating from outside the BLS configs. However, if these assumptions
are wrong we would simply fail the boot, which is currently what is
happening anyway.

See also:
openshift/os#546
ibm-s390-linux/s390-tools#78

Tested-by: Muhammad Adeel <muhammad.adeel@ibm.com>

Resolves: rhbz#2050567
jschintag added a commit to jschintag/os that referenced this pull request Mar 14, 2023
fips.enable* is working on newest s390x. Remove the test from denylist.
For more details see openshift#546

coreos.ignition.mount.* is fixed with gdisk-1.0.3-9.el8. Remove the test from
denylist.

Signed-off-by: Jan Schintag <jan.schintag@de.ibm.com>
jschintag added a commit to jschintag/os that referenced this pull request Mar 14, 2023
fips.enable* is working on newest s390x. Remove the test from denylist.
For more details see openshift#546

coreos.ignition.mount.* is fixed with gdisk-1.0.3-9.el8. Remove the test from
denylist.

ext.config.shared.ignition.stable-boot is fixed in RHEL 9. Only disable for
RHEL 8 builds.

Signed-off-by: Jan Schintag <jan.schintag@de.ibm.com>
travier pushed a commit to travier/os that referenced this pull request Mar 14, 2023
fips.enable* is working on newest s390x. Remove the test from denylist.
For more details see openshift#546

coreos.ignition.mount.* is fixed with gdisk-1.0.3-9.el8. Remove the test from
denylist.

ext.config.shared.ignition.stable-boot is fixed in RHEL 9. Only disable for
RHEL 8 builds.

Signed-off-by: Jan Schintag <jan.schintag@de.ibm.com>
(cherry picked from commit 36729d1)
travier pushed a commit to travier/os that referenced this pull request Mar 15, 2023
fips.enable* is working on newest s390x. Remove the test from denylist.
For more details see openshift#546

coreos.ignition.mount.* is fixed with gdisk-1.0.3-9.el8. Remove the test from
denylist.

ext.config.shared.ignition.stable-boot is fixed in RHEL 9. Only disable for
RHEL 8 builds.

Signed-off-by: Jan Schintag <jan.schintag@de.ibm.com>
(cherry picked from commit 36729d1)
@cgwalters cgwalters mentioned this pull request Mar 21, 2023
jason-rodri pushed a commit to ciq-rocky-fips/dracut that referenced this pull request Mar 28, 2024
On s390x, the `BOOT_IMAGE` karg injected by the bootloader is not a path
to the kernel image, but rather an integer describing the index of the
menu entry selected. Because of the way the s390x bootloader works,
there is no information retained about e.g. the path of the kernel that
was loaded.

This causes issues for the FIPS code which assumes that `BOOT_IMAGE` is
a path to the kernel image to derive the HMAC path. In non-OSTree
systems, this ends up working anyway, because the kernel is located at
the root of the boot partition.  In OSTree systems, this is not the
case. However, OSTree systems use BLS configs, and they are named in
reverse order of precedence (i.e. menu ordering). So from the
`BOOT_IMAGE` integer, we can figure out which BLS entry was selected.

Add some code to do just this on s390x. This isn't completely foolproof,
because it presumes that (1) BLS configs were used to populate the
bootloader (and that they were exactly in the same state they currently
are when `zipl` was run), and (2) there are no other menu entries
originating from outside the BLS configs. However, if these assumptions
are wrong we would simply fail the boot, which is currently what is
happening anyway.

See also:
openshift/os#546
ibm-s390-linux/s390-tools#78

Tested-by: Muhammad Adeel <muhammad.adeel@ibm.com>

Resolves: rhbz#2007586
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants