-
Notifications
You must be signed in to change notification settings - Fork 297
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
Possible regression: 2021.08.12 shim boots whereas 2023.01.18 freezes in a chain-loaded Secure Boot context #558
Comments
Further investigation has allowed me to conclude that this is a duplicate of the issue reported in #547, and especially the problem is that our NTFS driver is not specs compliant when it comes to
As we were able to confirm, the root of the issue is that, when reading the Obviously, we will fix the NTFS driver for compliance, to avoid the issue altogether, but it's nice to see that Shim has also taken steps to try to alleviate it. |
Following the discovery of more problematic firmwares and drivers affected by the issue c28b9855d0befbd07f46ced5c06c6d799c9d9d00 is designed to address (e.g. rhboot#558), this patch further improves the code so that, instead of simply bailing out, we progressively increase the buffer sizes, until either success or a maximum size limit is reached. In most cases, this workaround should be enough to ensure completion of the directory read and thus provide full shim functionality (while still warning the user about the non-compliance of their environment).
Following the discovery of more problematic firmwares and drivers affected by the issue c28b9855d0befbd07f46ced5c06c6d799c9d9d00 is designed to address (e.g. rhboot#558), this patch further improves the code so that, instead of simply bailing out, we progressively increase the buffer sizes, until either success or a maximum size limit is reached. In most cases, this workaround should be enough to ensure completion of the directory read and thus provide full shim functionality (while still warning the user about the non-compliance of their environment). Signed-off-by: Pete Batard <pete@akeo.ie>
Following the discovery of more problematic firmwares and drivers affected by the issue f23883c is designed to address (e.g. rhboot#558), this patch further improves the code so that, instead of simply bailing out, we progressively increase the buffer sizes, until either success or a maximum size limit is reached. In most cases, this workaround should be enough to ensure completion of the directory read and thus provide full shim functionality (while still warning the user about the non-compliance of their environment). Signed-off-by: Pete Batard <pete@akeo.ie>
I have now confirmed that the latest shim (with the f23883c / #547 patch applied) does bail out when using the problematic driver instead of entering an infinite loop. However, since I believe that the code from f23883c can be improved to progressively increase the buffer size in order to successfully complete the directory read, I have now submitted PR #560 that does just this. |
Following the discovery of more problematic firmwares and drivers affected by the issue f23883c is designed to address (e.g. #558), this patch further improves the code so that, instead of simply bailing out, we progressively increase the buffer sizes, until either success or a maximum size limit is reached. In most cases, this workaround should be enough to ensure completion of the directory read and thus provide full shim functionality (while still warning the user about the non-compliance of their environment). Signed-off-by: Pete Batard <pete@akeo.ie>
Can I close this? |
I will close this now, yes. The issue was fixed in the NTFS driver and with the commit that was integrated in Shim, there is no reason to have this issue opened. Thanks again! |
Following the discovery of more problematic firmwares and drivers affected by the issue f23883c is designed to address (e.g. rhboot#558), this patch further improves the code so that, instead of simply bailing out, we progressively increase the buffer sizes, until either success or a maximum size limit is reached. In most cases, this workaround should be enough to ensure completion of the directory read and thus provide full shim functionality (while still warning the user about the non-compliance of their environment). Signed-off-by: Pete Batard <pete@akeo.ie>
Issue description
It appears that, when running in a Secure Boot environment, the current shim introduced a regression, that is currently manifesting itself and affecting users trying to create NTFS-based boot media from Ubuntu Studio 22.04.2 LTS (this was tested with
ubuntustudio-22.04.2-dvd-amd64.iso
) when using the NTFS chain loader from the Rufus boot media creation utility.Basically, because the Ubuntu ISO contains a file that is larger than 4 GB, Rufus extracts the ISO content onto an NTFS partition rather than a FAT32 partition (since FAT cannot accommodate files larger than 4 GB) and then, for UEFI systems that do not have a native NTFS driver, chains load the Red Hat Shim from a small additional FAT partition that contains a UEFI boot loader that can load a UEFI NTFS driver and then hands of boot to the NTFS-residing bootloaders.
This chain loader, called UEFI:NTFS is itself Secure Boot signed, along with its read-only NTFS driver that is derived from ntfs-3g. Note that this driver was restricted to read-only as a means to improve its resilience against potential vulnerabilities and therefore facilitate the Secure Boot validation process.
However, we have recently found out that, when Secure Boot is active (the issue does not manifest itself when Secure Boot is Disabled or in Setup mode), the process above appears to freeze during shim execution when using the 2023.01.18 Secure Boot signed version. Yet, when replacing the shim with a 2021.08.12 Secure Boot signed version, everything works as expected.
Thus, it would appear that a regression was introduced between 2021.07 and 2023.01.18 that causes a freezout when shim is chain loaded from a read-only NTFS partition.
Steps to replicate
The attached
shim.zip
contains a 8 MB uncompressed VHD disk image, which, for all intents and purposes will work the same as add
disk image (since uncompressed VHD = regular disk image + 512 bytes footer), that you should be able to use with any USB disk media to recreate a test disk that includes:/efi/boot/bootx64.efi
, and therefore the one that will execute by default, and the 2021 version labelled as/efi/boot/bootx64.old
, and provided for testing purposes).Thus, if you
dd
write that image, you will end up with a GPT partitioned bootable drive can be used to replicate the issue.From there, you should to test this drive on a UEFI based system that meets the following two conditions:
On such a system, and provided that your UEFI firmware isn't pedantic about the fact that the backup GPT of the drive you just created will be invalid (which most firmwares will happily ignore), you should end up with a screen similar to the one below, indicating, after providing some info about your system, first, that the NTFS driver was successfully loaded, then that the shim was successfully located on the NTFS partition and finally that the UEFI boot process has successfully been handed over to it:
Then, provided that you can mount the NTFS partition from the drive you created, if you rename
/efi/boot/bootx64.old
to/efi/boot/bootx64.efi
, you will find that the process does go past the screen above up to the stage where shim reports, as expected if the execution is working, that it could not locategrubx64.efi
, which tend to support the idea that we are, in effect, dealing with a shim regression.Note that the shim bootloaders used in this test image come from
ubuntustudio-22.04.2-dvd-amd64.iso
andubuntu-22.10-desktop-amd64.iso
, with the older one actually being from 22.10.Investigation notes
LoadImage()
/StartImage()
(since Secure Boot validation is handled byLoadImage()
) and likewise, the code to load the driver and locate the bootloader on the NTFS target partition is relatively straightforward. In short, while we have questions above the NTFS driver code, we don't currently believe that the issue has to do with the UEFI:NTFS bootloader itself.The text was updated successfully, but these errors were encountered: