Kernel lockdown locked out — for now
As the 4.17 merge window opened, it seemed possible that the kernel lockdown patch set could be merged at last. That was before the linux-kernel mailing list got its hands on the issue. What resulted was not one of the kernel community's finest moments. But it did result in a couple of evident conclusions: kernel lockdown will almost certainly not be merged for 4.17, but something that looks very much like it is highly likely to be accepted in a subsequent merge window.
As a reminder: the purpose of the lockdown patches is to enforce a distinction between running as root and the ability to run code in kernel mode. Proponents of UEFI secure boot maintain that this separation is necessary; otherwise the promise of secure boot (that the system will only run trusted code in kernel mode) cannot be kept. Closing off the paths by which a privileged attacker could run arbitrary code in kernel mode requires disabling a number of features in the kernel; see the above-linked article for the details. Most users will never miss the disabled features, but there are always exceptions.
There are, naturally, a number of disagreements on how the lockdown mode is implemented. The use of a blacklist to disable "dangerous" kernel command-line options seems sure to let some of those options through. It is unlikely that all of the potentially hazardous operations supported by device drivers can ever be found. And so on.
The interesting thing, though, is that almost nobody seems to object to the lockdown concept in general — as long as it can be turned off. Even Linus Torvalds, who argued against the lockdown patches and their developers in typical Torvalds style, sees some potential value in the lockdown concept. There does not appear to be any significant opposition to making it available in the kernel.
The sticking point
The reason that the lockdown patches will not be merged this time around thus doesn't depend on their core purpose. Instead, the whole thing hinges on a single detail: the patch set automatically turns the lockdown mode on if secure boot is detected at startup time. It is the tying together of lockdown and secure boot that brought about a long and unpleasant linux-kernel thread.
Torvalds pointed out that there is a long
list of security-related features that can be enabled in current kernels.
None of those features depend on whether secure boot is enabled on the
system; they are configured in or out on their own merits. The behavior of
the kernel should not vary as a result of a BIOS setting, he argued.
He also claimed that connecting the two features means
that few kernel developers will ever test kernels with lockdown enabled,
since few of them enable secure boot on their development systems. No
"sane distribution
" would ship a kernel with this mode turned
on, he said. One little problem with that
last claim, as Matthew Garrett pointed out,
is that many major distributions have been shipping a version of this patch
set for about five years.
On the other side, proponents argue that lockdown without secure boot (or
something like it) will instill a false sense of security, since the
lockdown can be circumvented by attacking the boot chain. As Garrett put it: "Without some sort of verified
boot mechanism, lockdown is just security theater
". The same is
said to be true of a kernel that supports secure boot without lockdown;
that kernel can be compromised after boot to run untrusted code in kernel
mode — exactly the scenario that secure boot is meant to prevent. A
secure-boot kernel without lockdown is not only false security for its
user; it is presented as a threat to others
as well:
See also this blog post from Garrett describing his view of this discussion in more detail.
Not everybody agrees that lockdown without secure boot is useless; they see it like all of the other hardening technologies that have been put into the kernel. Compromising the boot chain (and forcing a reboot) is not always an easy thing to do, especially for a remote attacker. Secure boot is unlikely to ever protect all of the places where a persistent exploit could be placed anyway — init scripts, for example. Even without secure boot, it is argued, lockdown raises the bar for a potential attacker.
The "bootloader" argument is an interesting one; it says that a kernel without lockdown can be compromised and used to load a new, modified kernel that hides any malware it contains. According to Peter Jones, this is a common model for malware installations. Under this line of reasoning, any kernel that can be corrupted in this way and carries a signature that will enable it to boot on a secure-boot system can be used to attack any system that trusts the signing key. Automatically enabling lockdown with secure boot is a way to avoid creating this kind of attack tool.
If that is the issue, Alan Cox said, then we have already lost:
One other aspect of this issue that came up briefly is the fear that, if
Linux looks like a tool that can be used to compromise secure-boot systems
running Windows, that Microsoft might blacklist the signing key and render
Linux unbootable on most x86 hardware. David Howells expressed this worry, for example. Greg
Kroah-Hartman said, though, that he has
researched this claim numerous times and it has turned out to be an
"urban myth
".
Resolution?
Toward the end of the discussion, Torvalds (and others) suggested that lockdown should just be enabled unconditionally, especially since distributors have been shipping it for some time. The problem with that, of course, is that lockdown does occasionally break a working system. In such cases, users have been advised by distributors to disable secure boot as the easiest solution. Torvalds rephrased that point:
Had things been expressed that way from the beginning, he said, the
connection between lockdown and secure boot would have been "much
more palatable
".
A statement like that strongly suggests that the lockdown feature, even
perhaps with a secure-boot connection, should be able to get past Torvalds
eventually. Howells has said that he is
reworking the patch set to loosen that connection, which may help as well.
While another attempt to push this work for 4.17 could happen, it seems
more likely that everybody will want to step away from this discussion and
address the issue again in 4.18.
| Index entries for this article | |
|---|---|
| Kernel | Security/UEFI secure boot |
| Security | Linux kernel |
| Security | Secure boot |
Posted Apr 8, 2018 9:13 UTC (Sun)
by darwish (guest, #102479)
[Link] (6 responses)
I've written a number of remote exploits (white-hat; merged in Metasploit), and the ability to modify the boot chain is not as easy as the lockdown authors claim. It might be much easier in the servers world due to extreme PC boot-protocol standardization, but it's hard as hell in the embedded world due to esoteric SoCs, unknown custom-built boot-loaders, and read-only storage.
In these cases, and even without secure-boot, basic kernel hardening features like disabling /dev/mem, /proc/<pid>/mem, /proc/kcore, etc. etc. are __invaluable__ in making the attackers life much harder -- even if they got execute access as UID 0.
Yes, with UID0 the attacker can create a kernel module to re-expose all that, but again this is embedded: (f)init_module() might be removed from the kernel. Even funnier: you might only have a root _shell_ access, but not pure uid 0 binary execution context; and then you find yourself with a busybox having wget and insmod removed ;-) You try to write your exploit ELF, byte by byte, using 'echo' to a tmpfs partition; on a lot of devices this will succeed, but others might have a brain-dead 'echo' version that does not support the necessary "-en" parameters, and so on.
So, honestly, Linus is __absolutely__ right:
"Because as long as the explanation is just some 'you must use secure boot or you've already lost and further security is pointless' hocus-pocus magical thinking, I immediately go 'no, that sounds completely bogus and it makes testing and coverage much worse, we've done other things quite like that without this secure boot tie-in'".
Posted Apr 8, 2018 17:00 UTC (Sun)
by bluca (subscriber, #118303)
[Link]
Posted Apr 9, 2018 0:22 UTC (Mon)
by nivedita76 (subscriber, #121790)
[Link] (4 responses)
embedded doesn't seem very relevant in any case, it's not going to have UEFI secure boot in any case. The argument is about whether you should turn lockdown on automatically if secure boot is enabled, which is really only a PC/x86 server thing for the most part.
Posted Apr 9, 2018 6:16 UTC (Mon)
by darwish (guest, #102479)
[Link]
Posted Apr 9, 2018 9:53 UTC (Mon)
by excors (subscriber, #95769)
[Link] (2 responses)
Posted Apr 9, 2018 11:01 UTC (Mon)
by kugel (subscriber, #70540)
[Link] (1 responses)
Posted Apr 10, 2018 13:12 UTC (Tue)
by arekm (guest, #4846)
[Link]
Posted Apr 8, 2018 11:48 UTC (Sun)
by niner (subscriber, #26151)
[Link] (5 responses)
Posted Apr 8, 2018 13:17 UTC (Sun)
by epa (subscriber, #39769)
[Link] (4 responses)
Posted Apr 8, 2018 15:07 UTC (Sun)
by niner (subscriber, #26151)
[Link] (2 responses)
Posted Apr 10, 2018 3:51 UTC (Tue)
by pabs (subscriber, #43278)
[Link] (1 responses)
Posted Apr 10, 2018 6:32 UTC (Tue)
by niner (subscriber, #26151)
[Link]
Posted Apr 8, 2018 15:13 UTC (Sun)
by Paf (subscriber, #91811)
[Link]
Posted Apr 8, 2018 18:59 UTC (Sun)
by ballombe (subscriber, #9523)
[Link] (1 responses)
Posted Apr 9, 2018 7:02 UTC (Mon)
by matthias (subscriber, #94967)
[Link]
Posted Apr 24, 2018 5:22 UTC (Tue)
by mcortese (guest, #52099)
[Link] (1 responses)
I can understand that someone values convenience above security and doesn't want to enable neither secure boot, nor kernel lockdown. At the other end of the spectrum, those highly concerned with security will enable both. Somewhere in the middle, someone might want the increased security of lockdown without the hassle of enabling secure boot.
But who will want to go so far as to enable secure boot and then fails to avtivate lockdown?
In other words, who will benefit from lockdown not automatically activated by secure boot?
Posted Apr 24, 2018 19:06 UTC (Tue)
by zlynx (guest, #2285)
[Link]
Maybe I missed finding a Fedora command-line option that would have done it.
Kernel lockdown vis-à-vis secure-boot
Kernel lockdown vis-à-vis secure-boot
Kernel lockdown vis-à-vis secure-boot
Kernel lockdown vis-à-vis secure-boot
Kernel lockdown vis-à-vis secure-boot
Kernel lockdown vis-à-vis secure-boot
Kernel lockdown vis-à-vis secure-boot
Kernel lockdown locked out — for now
Kernel lockdown locked out — for now
Kernel lockdown locked out — for now
Kernel lockdown locked out — for now
Kernel lockdown locked out — for now
Kernel lockdown locked out — for now
microcode
microcode
Kernel lockdown locked out — for now
Kernel lockdown locked out — for now
