Matthew Garrett: Why UEFI secure boot is difficult for Linux
I wrote about the technical details of supporting the UEFI secure boot specification with Linux. Despite me pretty clearly saying that this was ignoring issues of licensing and key distribution and the like, people are now using it to claim that Linux could support secure boot with minimal effort. In a sense, they're right. The technical implementation details are fairly straightforward. But they're not the difficult bit.Secure boot requires that all code that can touch hardware be trustedRight now, if you can run unstrusted code before the OS then you can subvert the OS. Secure boot gives you a mechanism for making sure you only run trusted code, which protects against that. So your UEFI drivers have to be signed, your bootloader has to be signed, and your bootloader must only load a signed kernel. If you've only booted trusted code then you know that your OS is safe. But, unlike trusted boot, secure boot provides no way for you to know that only trusted code was executed. That has to be ensured by OS policy.
This doesn't sound like too much of a problem. But it is. Imagine we have a signed Linux bootloader and a signed Linux kernel, and that these signatures are made with a globally trusted key. These will boot on any hardware using secure boot. Now imagine that an attacker writes a kernel module that sets up a fake UEFI environment, stops the kernel from running code and then executes the Windows bootloader - kind of like kexec, but a little more fiddly. The Windows bootloader believes that it's performing a secure boot, but in fact everything that it believes is trustworthy is the attacker's fake UEFI code. The user's encryption passphrase is logged, the Windows kernel is modified to hide the Linux code and despite everything looking fine your credit card details are on their way to China. In this scenario, the signed Linux kernel is simply used as a malware loader. The only sign that anything is wrong is that boot will be slightly slowed down.
Signing the kernel isn't enough. Signed Linux kernels must refuse to load any unsigned kernel modules. Virtualbox on Linux? Dead. Nvidia binary driver on Linux? Dead. All out of tree kernel modules? Utterly, utterly dead. Building an updated driver locally? Not going to happen. That's going to make some people fairly unhappy.
(The same applies to Windows, of course. Windows 7 allows you to disable driver integrity checks. Windows 8 will have to forbid that when the system's using secure boot)
LicensingGPLv3 has various requirements for signing keys to be available. Microsoft's new requirement that systems support the installation of user keys would let users boot their own modified bootloaders, so that may end up being sufficient to satisfy the license. But we're then beholden on Microsoft - if they remove that requirement then users lose that freedom, and suddenly we're in an awkward licensing situation. There are ongoing conversations about exactly what we're able to do here, but it's not a solved problem.
Key distributionThe UEFI spec doesn't describe or mandate a central certifying authority. Microsoft require that everyone carry their key. We could generate our own, but we have much less sway with vendors. There's no way to guarantee that all hardware vendors will generate our key. And, obviously, if we generate a key, we can't just hand the private half out to others. That means that it becomes impossible for people to produce derivative versions of Linux distributions without getting their own key. The kind of identity verification that would be required for getting such a key is likely to be expensive, and also fairly likely to require that the distribution have a legally registered company in order to facilitate the identity verification. Think Extended Validation certificates, not Startssl Free. Hobbyist Linux distributions will be a thing of the past.
Doesn't custom mode fix this?Microsoft's certification requirements now state that all systems must support a custom mode, implying that it will be possible for a user to install their own keys. Linux vendors would then be able to ship with their own keys on the install media and impose their own policies. Everyone's happy. It's not really good enough, though. People have spent incredible amounts of time and effort making it easy to install Linux by doing little more than putting a CD in a drive. Asking them to go into the firmware and reconfigure things adds an extra barrier that restricts the ability to install Linux to more technically skilled users. And it's even worse than that. This is the full description of the requirement for custom mode:
- It shall be possible for a physically present user to use the Custom Mode firmware setup option to modify the contents of the Secure Boot signature databases and the PK.
- If the user ends up deleting the PK then, upon exiting the Custom Mode firmware setup, the system will be operating in Setup Mode with Secure Boot turned off.
- The firmware setup shall indicate if Secure Boot is turned on, and if it is operated in Standard or Custom Mode. The firmware setup must provide an option to return from Custom to Standard Mode which restores the factory defaults.
There's a few things missing from this, namely:
- Any description of the UI. It's effectively impossible to document Linux installation when the first step becomes (a) complicated and (b) vendor specific. Vendors are using the UEFI transition to differentiate themselves by coming up with their own unique firmware interfaces. Custom mode is going to look different everywhere.
- Any description of the key format. A raw binary representation of the key? An EFI_SIGNATURE_DATA struct? A base64 encoding of one, further protected with ROT13? We just don't know.
- Any way to use custom mode for unattended installs. It's a firmware interface that requires a physically present user. Want to install a few thousand machines over the network? This isn't a scalable approach
- and this one's nitpicking, but there's not actually any requirement that the user be able to add keys - a vendor could conform to this language by only letting users delete keys. This is actually ok as long as the user deletes Pk, because then we'll effectively be back in setup mode and can install our own keys from the installer, but it still results in some practical problems
So no, custom mode doesn't make everything ok. Custom mode with a mandated UI and a documented key format would be much closer, but it wouldn't solve the problem of unattended automated installs.
SummaryWe can write the code required to support secure boot on Linux in a minimal amount of time - in fact, most of it's now done. But significant practical problems remain, and so far we have no workable solutions for any of them.
Yesterday, I've unpacked new toy -
Today I released two entirely different pieces of software with the
identical version number 3.20120115. Debian developers also will be soon
noticing a piece of software I released with the version number 9.20120115.
I expect to move more of my software to this version number scheme over
time, unless I find something badly wrong with it. It reflects how I think
about versions for my software; there's a kind of continual "now" that
development progresses through, in which individual releases have little
discrete meaning and at the same time, there can also be significant
discontinuities, that require the user to do something to deal with
(such as a new debhelper compat version, or a new git-annex repository
format).
Those two things are really all that I need a version number for my
software to communicate. I can do without the rest of the things that
version numbers are used for:
(This is not quite a Dear lazyweb post. If anything, it's Dear
lazyweb, I've done my homework, now what? )
I'm looking for the ultimate distributed filesystem. Something that's
simple to use, redundant, fault-tolerant, and still smart enough to
avoid the more obvious performance chokepoints. Ideally, it should
work for all of the following sets of files:
I thought it was about time to get a faster machine for... well,
mostly for compiling kernels faster, but I'm sure I will find other
applications for it. I was originally intending to upgrade my
laptop (Thinkpad T61, 1.8 GHz Core 2 Duo) but it seems that in the 3
years since I bought it second-hand laptop prices have not dropped
in line with Moore's law. So instead I decided to upgrade (well,
replace most of) a desktop PC.
The last time I got a new desktop at home was in 2002. It has an
Athlon XP, PATA drives and a huge CRT monitor. It has had some
upgrades since then (DVD writer, more RAM, slightly faster CPU,
replacement fan and PSU). Obviously it was time to replace
motherboard, CPU and RAM. Not so obviously, the PSU needed changing
again as modern CPUs apparently need more 12V electrons (?!). The
DVD writer was salvageable via a USB adapter and its local HD is
currently a laptop drive (the only spare SATA HD I had). The
monitor is of course reusable, though the firmware setup program
doesn't entirely agree with it.
Windows
Yes, I do sometimes run Windows. It's for games, and also seems to
be needed for streaming video with stupid DRM.
On the assumption that Windows is less likely to play nice with an
existing installation, I tried installing it first. The firmware
appear to allow me to boot the DVD in either BIOS or UEFI mode, so I
selected the UEFI option. This worked so far as loading the
initramfs (or whatever the Windows equivalent is) but then Windows
was lacking a driver to access the DVD. This stumped me for a day
or so until I realised I had plugged the drive into a USB 3 (XHCI)
port. Apparently Windows 7 SP1 still doesn't include an XHCI driver
in the installer (but neither does Debian 6.0.3 - we should fix
that).
The installation was mostly uneventful after this. The Windows
installer includes a reasonably capable partition editor.
Debian
Installation of files was entirely uneventful. The installer
correctly detected the GPT (GUID partition table) created by
Windows. However, it was not able to install a boot loader.
Currently it only includes support for the LILO and GRUB-PC
boot loaders that run under BIOS.
After much experimentation and cursing, I found instructions for
Steve McIntyre has been contributing to Debian since 1996, 2 years before I joined! But I quickly stumbled upon Steve: in 1999, he was struggling with getting his debian-cd script to produce 2 ISO images (it was the first time that Debian did no longer fit on a single CD), I helped him by rewriting debian-cd with a robust system to split packages on as many ISO images as required.
I remember those times very well because Steve was very supportive of my efforts and it was a real pleasure to get this done. His friendly nature probably also explains why he got elected Debian Project Leader twice!
Anyway, enough history, check out his interview to learn more about the great work he s doing nowadays. My questions are in bold, the rest is by Steve.
Raphael: Who are you?
Steve: I m a professional software engineer, 37, living in Cambridge
(England) with my new wife Jo. I studied for the EIST degree at the
University of Cambridge, then (like many people here, it seems) I just
forgot to go home again afterwards and settled here. I spent more of
my study time playing with Linux than working on my degree, so I
guess I m lucky that it worked and I found a career in that area!
Raphael: How did you start contributing to Debian?
Steve: During my time in college, I started hacking on software in my free
time, using Slackware as my first Linux distribution from the middle
of 1994. After encountering more and more problems with Slackware, I
was encouraged by a number of friends to make the jump over to Debian
and in October 1996 I did. The installation process back then was
much harder than anything people see today, but after
a long weekend I finally had my Debian system up and running.
I was already one of the main upstream developers for the Mikmod music
player at that time, so that very same weekend I applied to be a DD so
I could maintain it in Debian too. Back then, the NM process was much
simpler: I just mailed a key to Bruce and he set me up with an account
almost immediately!
I then found that Joey Hess had beaten me to it and already packaged Mikmod. Grrr!
So, in 2002 I attended my first

Current status
Back in September,
I 
Recently I've been wanting to replace my old point and shoot camera, a
That time of the year comes where I summarize my running
activities. It's now 4.5 years that I resumed running, after nearly 10
years without active sports. Apparently, things continue to improve,
though I'm logically reaching my limits in some way.
I finally missed the 2500km mark by 14 kilometers, mostly because of a
cold I had during the last 2 days of the year.
The grand total is thus 2486 kilometers run, in 237 hours (9 days
21hours), at about 10.5km/h. The climbed height difference is 27700
meters, so about three times the altitude of Mount Sagarmatha..:-)
This was achieved in 294 "activities". That seems to be a lot (nearly
1 activity per day): indeed, there are days where I have up to 4
activities, when I run to/back work, which means two runs in the
morning (3+4km) and two in the evening. If I count the number of days
where I had at least one running activity, this lowers to 181.
In short, I ran about every 2 days. Indeed, along the year, the
biggest timeframe between two runs has been 7 days. In short, I ran
at least once every week during this year. The most active month was
July with 272km and the less active was September with 163.5.
When counted by distance, this summarizes to: