-
Notifications
You must be signed in to change notification settings - Fork 97
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
Proper Secure Boot support #69
Comments
In case you haven't seen how we do it on the Pi, this is relatively easy to add during the EDK2 build process. Basically you want to first get all the needed Secure Boot certificates and dbx, most of which can be downloaded directly: Note that, because we sure don't want any third party (including ourselves) to have control over somebody else's machine when it comes to Secure Boot, we always generate a new PK as part of the build process and then discard the private key altogether. Then, at EDK2 build time, you just need to feed the And with this, you should have a UEFI firmware that both Windows and Linux are happy with when it comes to Secure Boot. |
Thanks for input, Pete! I've actually put this on hold because we don't have a secure var store, and there are more steps involved to ensure a trusted boot chain that I'm not sure many would bother with. But yeah, some formal support in EDK2 to make Windows happy and satisfy one of the requirements is better than nothing. |
Oh yeah, you're never going to get to a proper trusted boot chain on SoC systems without a lot of extra work, and we are well aware that, at least for the Pi, the Secure Boot feature we provide is more a showcase than anything that will actually help "secure" the system. It was indeed mostly added so that people could get |
Added initial support in: 8b6b3a6 Will keep this open to track further progress. One obvious thing that needs to be fixed is disabling the recently added FDT override support when SecureBoot is on, since those files aren't signed. But it may be desirable to leave it this way until work on mainline Linux and DT settles, so folks won't have to rely on overrides as much. |
@pbatard Does the above method work without code modifications just passing the extra arguments? how can I sign a linux image I want to securely boot? |
The above method is for adding the Secure Boot certificates to a UEFI firmware that you build yourself. It has nothing to do with signing a linux image to work with an existing UEFI firmware that you did not build. If you do build your own UEFI firmware from scratch you should however be able to install your own certificate by adding an extra OR, and I assume this is really what you actually want to accomplish, if you are not building a UEFI firmware from scratch, but just want to have something you sign work with an existing UEFI firmware, you should follow this extensive guide to add your own certs using the existing UEFI interfaces. |
Makes sense, thanks for the link. That clears up signing downstream. But for upstream, I am interested to use the builtin eFuse on Rockchip to make sure that only my custom signed bootloader can be used. I've seen this done successfully with U-Boot and the rockchip signing tools (they sign the idbloader.img file). In our case, is the idblock.bin an equivalent of that? |
I'm afraid you're going to have to ask somebody else about this, as I know nothing about |
@hongkongkiwi you want this I guess: https://github.com/DualTachyon/rk3588-secure-boot |
Very helpful! Thanks @DualTachyon |
@pbatard I just noticed there are two arm64 dbx files: the one listed on uefi.org is https://uefi.org/sites/default/files/resources/arm64_DBXUpdate.bin while the RPi4 script is fetching https://uefi.org/sites/default/files/resources/dbxupdate_arm64.bin - and they're different (though I haven't looked into how/why). Also, I'm seeing an error trying to add the dbxDefault variable: the code expects it to be in a X509 format, not the raw data suitable for adding directly via SetVariable:
|
@bexcran, the file to use is always the one linked on https://uefi.org/revocationlistfile, therefore, currently that would be https://uefi.org/sites/default/files/resources/arm64_DBXUpdate.bin. At the time when we added the files for Pi 4, that link pointed to https://uefi.org/sites/default/files/resources/dbxupdate_arm64.bin (and we expected that the UEFI forum would not change URLs when they updated the DBXs, but it appears that they do), hence the discrepancy. AFAIK, the DBX links have always been in the format needed for adding with |
@pbatard RPi4 is also using SecureBootDefaultKeysDxe and SecureBootVariableProvisionLib so it's going to have the same problem I ran into: keys/arm64_dbx.bin is in a format for SetVariable while the other certificates are in DER format. SecureBootDefaultKeysEntryPoint tries to initialize PKDefault, KEKDefault, dbDefault, dbtDefault and dbxDefault. SecureBootInitKEKDefault, SecureBootInitDbDefault and SecureBootInitDbxDefault all have the same pattern of code:
SecureBootFetchData does the same thing in all cases:
So, since the DBX is in a different format than the KEK and DB it's going to cause a problem. I only noticed because I created a RELEASE build with DEBUG_ERROR and DEBUG_WARN levels enabled so any errors being logged were easy to notice. |
There's no DER format for DBX. DBX is a proprietary format for a list of revoked hashes or certificates. You seem to be equating DBX to a certificate, which it is not. It's a list of things, and it may not include any certificate at all. Please see the UEFI specs. There's simply no way for DBX to be anything else than a custom list of element. It's always going to have to be in a different format than KEK or DB (well, as far as we're talking about adding individual certs to KEK and DB) because by nature we're dealing with completely different entities. |
Then the code in EDK2 is wrong. It's assuming it's a list of certificates. |
In that case you need to work with the EDK2 to fix that code. Please bear in mind that Secure Boot support for Pi was provided as a courtesy to avoid the Windows 11 annoyance of requiring Secure Boot, because the Pi platform cannot actually deliver proper Secure Boot, and our expectation is that if you pass a blob to the EDK2 as DBX, and EDK2 doesn't say "This blob is not in the right format" then the EDK2 thinks that the blob is in a format it can handle and will use it as expected. We have no tested DBX revocation or anything outside of Windows not complaining that it wants to see Secure Boot, and, since I am no longer directly involved with the Pi EDK2 platform, I am not planning to invest any time on this. So, if you think you have identified EDK2 code that does not perform what it's advertising, and not producing the error it should produce, then I will expect you to work with the EDK2 to fix it (and then that fix will naturally find its way for Pi and other platforms that use unmodified EDK2 code). |
No description provided.
The text was updated successfully, but these errors were encountered: