FS#53864 - [archiso] Support Secure Boot
Attached to Project:
Release Engineering
Opened by mirh (mirh) - Friday, 28 April 2017, 10:58 GMT
Last edited by David Runge (dvzrv) - Friday, 31 July 2020, 08:37 GMT
Opened by mirh (mirh) - Friday, 28 April 2017, 10:58 GMT
Last edited by David Runge (dvzrv) - Friday, 31 July 2020, 08:37 GMT
|
Details
Bug report instead of feature request because it used to
work until
https://git.archlinux.org/svntogit/packages.git/commit/?h=packages/prebootloader&id=88bac02c2d44724a4684b06aa38e0add11161cd7
Ideally, if somebody could get to ping Jejb for updated signed binaries it would be best. Another alternative (as mentioned on Arch Wiki) is Fedora shim, but I haven't tested this directly and I wouldn't know whether it offers a worse or better OOTB experience. This issue is getting more and more severe with time, since (putting aside 99% of computers are sold with SB enabled by default), W10 certification requirements dropped the "can be disabled" criteria and most OEMs are getting quite lazy. |
This task depends upon
Thing is, besides nevertheless the little annoyance of "figuring out what's the matter" and tinkering with bios, as I was saying many newer computers cannot even disable it.
Then, I'm not sure how's Arch's financial situation, but the neatest solution would be to acquire a certificate, and use it to sign officially built binaries (which together with avoiding package duplication, would also finally bring-in a 4 years newer preloader)
https://mjg59.dreamwidth.org/47438.html
Since the commit I mentioned above.
It eventually was even for the good, since that old version of the tools was creating problems on pre-secure-boot-specification UEFI systems.
Unless jejb puts out a newer signed version, I regret they don't look like a viable solution.
Shim on the other hand, yes, it's grub based.. *but* AFAIU there should be no problems to just use it to install arch's key (if not already rolled out), else just chainload whatever else you want afterwards.
And since at least v234 I'm kinda on the sure side systemd-boot should be totally fine with it.
https://github.com/systemd/systemd/pull/5702
0) move shim-signed from AUR to [extra]
1) install shim.efi in ${work_dir}/{iso,efiboot}/EFI/boot/bootx64.efi
2) install MokManager.efi in ${work_dir}/{iso,efiboot}/EFI/boot/MokManager.efi
3) install fallback.efi in ${work_dir}/{iso,efiboot}/EFI/boot/fallback.efi
4) install systemd-bootx64.efi in ${work_dir}/{iso,efiboot}/EFI/boot/grubx64.efi
correct? Or I am missing something
(and I guess like arch userbase won't mind to manually press a couple of buttons, instead of getting the thing to work automatically - albeit just know that still leave room for improving)
You'll have to also add Arch's key to the boot media though. Otherwise mokmanager is kinda on the useless side.
And behind the scenes you'll have to use it to sign bootloader/kernel/modules.
I remember these steps working with older prebootloader (signed by M$).
The thing is, that it becomes very tiresome to have to enroll a newer one, every time kernel or bootloader gets updated.
Also, you'd have not only to modify boot iso, but also add a newer dependency/step to final installed images boot chain (to account for this last occurance)
If you want to test Secure Boot, I think latest VMWare 14 should support it (I'm not sure if microsoft public key is automatically added or not though)
Also, just for the records of your seemingly spite, shim (let alone anything microsoft-related) isn't needed at all to "take control" of one's own platform or add/modify keystore.
You wouldn't respect UEFI specification else (maybe you could spend some time reading Matthew Garrett blog if interested about details)
Just everybody use to rely on shim now, because vendor interfaces to do so are such various, random and sometimes lackluster that it's way better to better this last step onto something "common" whose code you even have at hand.
Sbsigntools and aur's sbupdate-git may help with that btw.
But it's starting to become a bit of a shame to see *even* Debian getting there before of us
https://wiki.debian.org/SecureBoot
I personally have no interest in working on this. It seems like you do, though, and as such you're in a great position to scope out the work and propose changes. I await your patches.
I would also find reasonable every step of your plan.
The only thing I believe you have missed, is that shim would *always* allow keys enrolling, in addition to hashes.
It's just that if you haven't your very own (something that every big enough distro should have, still, imo) that cannot be unattended.
(that is, if you don't want users to re-enroll hashes on every update)
I'm not sure what kind of "injection" you are thinking.
We're not set up for that and I suspect the reproducible-builds people will object to allowing such.
Ideally, you'd have the interested PKGBUILDs check if the keys file/folder exists (I believe people that don't care about SB would be pissed if it wasn't optional), and if yes use it as a parameter for the signing commands/hook.
If that's not set up yet on build servers.. Well, it shouldn't still stop any of the work getting discussed here
If you don't want SB, nothing will change. Otherwise you'll either make your own key, or enroll hashes.
And AFAIU reproducible builds should still be a possibility then.
Note that this is only necessary at all if we want to go the whole way and sign boot loader and kernel, as mirh pointed out: if you only distribute a signed shim (which would be the first step to support Secure Boot), there are no secret keys involved in the build: you need to create a signing key and store it somewhere safe, but the build of shim only requires the public key, which can be distributed alongside the PKGBUILD. Once the shim binary is signed by Microsoft, you can then detach the Microsoft signature, distribute it in the repositories, and reassemble it in the PKGBUILD to recreate the signed binary as described above. This allows to independently verify that Microsoft hasn't tampered with shim, because the signature will not be valid for the binary compiled by the original PKGBUILD.
It's also probably the only viable one if Arch's build servers are "around the world" too https://lwn.net/Articles/703001/
(so, signed packages would depend on whoever-the-guy to keep updated the signature in source files, but they could still be built "independently official")
..makepkg/secrecy limitations I had failed to consider above notwithstanding though, I'd still hope eventually self-signed PKGBUILDs could be an easy feat to pull off for any interested normal user.
I resorted to a shim and GRUB binaries "borrowed" from Ubuntu 14.04 installation disc IIRC. The good part of this old shim/GRUB combination is that the GRUB does not mind whether the kernel itself is signed or not. Only downside is that it seems to be impossible to load GRUB modules (ntfs module for example), which is not signed. But I can successfully boot unsigned kernels on a UEFI SB, since only the shim/GRUB binaries need to be signed.
Hope this helps :) And if this project needs further help, I am willing to help here.
But as far I know Ubuntu and Debian have hardcoded the EFI entry title/folder to be able to sign the EFI bootloader for SB support. The result is you cannot e.g. change the boot entry title (and name of the EFI bootloader folder), which again result in you cannot have e.g. two Ubuntu installation on the same box! How crazy is this?
You can also very easily screw up you boot if you install a second hard disk which happen to have another Debian/Ubuntu installation because EFI bootloaders have the same name and cannot be changed.
I actually use Archlinux to solve this issue because Arch's GRUB package it's NOT signed (I guess). I boot Arch from USB and overwrite Ubuntu/Debian's GRUB with Arch's and now I again have full control of my GRUB.
Please don't make the same mistake with Arch in the eager to enable SB.
I am aware Arch's default bootloader is systemd-boot.
But bottom line is you cannot use option "--bootloader-id=xxx" of grub-install when the EFI loader is signed and that is a big issue in my view.
Some (e.g. you) might be able to install multiple instances of the same OS because of extended knowledge of GRUB and the boot process, but many don't, myself included.
Don't make GRUB even more difficult to configure/setup than it already is.
Regarding the adding HDDs issue: I can just say you easily run into a non-bootable system. I was not able myself to fix it even after hours Google'ing. No reason to make the boot-process even more vulnerable. Again, it might be an easy issue for you to fix, but I will claim, it's not for many user, might even for the majority (just Google).
I understand and vote myself for SB support, just make it optional! Don't force it and screw it up for some other users ;-)
Apparently Ubuntu and Debian didn't seem to make it optional, so when I ran into this thread I got really nervous.
And OS support for it definitively isn't going to affect either way firmware settings (whatever the relationship with the new HDD could be).
Anyway back on earth, while I was discussing of similar matters in the M-word distro forums, I fully realized what debian's solution entailed in practice https://debamax.com/blog/2019/04/19/an-overview-of-secure-boot-in-debian/
Put aside the crazy "having to enroll your hashes every time you update the kernel" options, so you:
* confusingly duplicate code with normal and signed versions of every interested package, OR
* build them on the single secret location, then in turn push the whole thing worldwide (sounds especially inelegant for kernels), OR
* let everyone build on their own, with the only "centralized bit" coming from the signature
And.. Assuming Arch will also choose this last way, I feel like some very impressive makepkg-fu will be needed (as also partially hinted in Jonas' last mail).
Eventually I think this is the biggest conundrum. Keeping the most of simplicity with the most of transparency. And the servers in sync.
But maybe I'm putting my nose too much into the maintainers job...
Have 2 version of grub available in the package repos: grub and grub-signed. (also why not signed and unsigned versions of systemd-boot..?)
- The signed version would include the Microsoft-signed shim bundled with a grub binary signed with Arch's certificate (and the signed shim would verify this).
- The unsigned version would have only non-modified grub without shim. This would target non-SB machines.
Since the Secure Boot auth chain can end to the feature-rich bootloader (here grub), both of these setups could use the same, unsigned, kernel. This is how it is done in Ubuntu for example, because I'm able to "borrow" their shim+grub to build an SB-compatible archiso with Arch kernel and initramfs.
However, for generating a fresh archiso, this would need a change in the pipeline so that the pipeline generates 2 different iso images - one unsigned one just as it is right now, and one signed iso image with this sort of shim-->signed grub-->unsigned kernel+initramfs boot chain. During the installation the user should first burn an ISO compatible for their platform (either the ISO with SB-compatible bootloader chain or the unsigned one) and when bootstrapping to the HDD could have the choice to install either one of for example the unsigned systemd-boot or the signed grub bootloader from the Arch repo. This way the kernel would not need to be signed, and the SB-compatible bootloader would merely exist only for those people that can't disable it from their machine..?
Also, ubuntu *do* require signing since 16.04.
But just on SB-enabled system, thanks to a patch (not sure why it hasn't been upstreamed yet)
https://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/unstable/log/arch/x86/kernel
https://src.fedoraproject.org/rpms/kernel/blob/master/f/0001-efi-Lock-down-the-kernel-if-booted-in-secure-boot-mo.patch
Which makes all sense of the world since for the user everything is as smooth as possible.
SB-off is the same that it ever was, and you just gain support for the proper SB-on case (whose security you may or may not care and appreciate).
p.s. putting aside that the only thing separating shims is the signature they automatically accept in unattended mode, maybe their grub is also working fine due to this
https://github.com/torvalds/linux/commit/f3cf6f7434debcc65f397228c689641b07c1be35
Like, did we even settle which theoretical design is good to begin with?
For this purpose shim has now been added to [community].
Note, that it is an unsigned version of course and we now have to get involved in the rest of the process as described by @diabonas
It is basically a very simple patch to mkarchiso that adds shim to the archiso. You have to enroll your keys with shim before booting it. As this is custom made, you can include your key, on the iso.
What would be needed so that that patch is included in archlinux?