In the first week of January 2018, every operating system on earth shipped an emergency update for a bug that was not in any of them. Meltdown and Spectre were flaws in the processors themselves — in a performance trick that Intel, AMD and ARM had all been using for twenty years — and the only place they could be worked around was in software, at a cost you could measure on a stopwatch. For the first time in most people’s memory, a security fix made computers visibly slower, and the reason was that the fix was papering over the hardware the software was running on. Meltdown and Spectre are the pages in this series where the trusted surface stops being code at all.
This is the fifth page in a series on the vulnerabilities that changed how Linux is built and defended, after Heartbleed, Shellshock, regreSSHion and the privilege-escalation decade. It is the one where the bug was in the CPU, and Linux had to defend against its own hardware.
What happened
Several groups arrived at the same discovery within months of each other in 2017. Jann Horn of Google’s Project Zero worked it out independently and, on 1 June 2017, reported it to Intel, AMD and ARM. The same underlying effect was found by a team at Graz University of Technology (Daniel Gruss, Moritz Lipp, Michael Schwarz, Stefan Mangard), by Werner Haas and Thomas Prescher at Cyberus Technology, and, for the Spectre half, by Paul Kocher working with Daniel Genkin, Mike Hamburg, Moritz Lipp and Yuval Yarom. A coordinated disclosure was set for 9 January 2018 to give the vendors and operating systems time to prepare. It did not hold: press reports and visible kernel changes gave the game away, and Google published early, on 3 January, with the operating-system updates following in a scramble over the next few days.
There were three variants, and they did not all behave the same way. Project Zero numbered them variant 1, “bounds check bypass” (CVE-2017-5753); variant 2, “branch target injection” (CVE-2017-5715); and variant 3, “rogue data cache load” (CVE-2017-5754). Variant 3 was named Meltdown; variants 1 and 2 were named Spectre. The distinction that mattered to a system administrator was which chips were affected: Meltdown was essentially an Intel problem (with some ARM cores), and had a relatively clean software fix; Spectre was verified on Intel, AMD and ARM alike, was far harder to fix completely, and — as its name was meant to suggest — would be with the industry for years.
The flaw, in one paragraph
A modern CPU does not wait around. Rather than sit idle while it works out whether a branch will be taken or whether a memory access is allowed, it guesses and runs ahead speculatively, and throws the work away if the guess was wrong. The architecture guarantees that mis-speculated work never officially happens: the registers roll back, the fault is raised, and as far as the program is concerned nothing was computed. The flaw is that the rollback is not perfect. Speculative execution leaves faint traces in the processor’s caches — a memory location is now loaded that was not before — and those traces survive the rollback. By timing how fast later, legitimate memory accesses complete, a program can read those traces back and so recover a value that the speculation touched before the permission check caught up. Meltdown used this to read kernel memory from an ordinary program; Spectre used it to trick one program into leaking its own secrets across a boundary it was trusted to hold. In Horn’s own words, “CPU data cache timing can be abused to efficiently leak information out of mis-speculated execution.” No instruction was executed that the rules forbid; the rules simply never contemplated that the shadow of a forbidden instruction could be measured.
The lasting mark of all this on Linux is a directory that did not exist before 2018, shown here on the machine used for this page:
$ for f in /sys/devices/system/cpu/vulnerabilities/*; do
printf '%-14s %s\n' "$(basename $f)" "$(cat $f)"; done
meltdown Not affected
spectre_v1 Mitigation: usercopy/swapgs barriers and __user pointer sanitization
spectre_v2 Mitigation: Enhanced / Automatic IBRS; IBPB: conditional; ...
spec_store_bypass Mitigation: Speculative Store Bypass disabled via prctl
l1tf Not affected
mds Not affected
retbleed Not affectedThe Xeon here reports meltdown: Not affected — later Intel silicon fixes Meltdown in hardware — while the two Spectre variants show the mitigations the kernel has turned on. The entries below them (l1tf, mds, retbleed and more) are the rest of the family that followed, which is the real point of the directory: speculative-execution flaws turned out not to be a single event.
Why the fix cost performance
The Linux answer to Meltdown had been in development, under the name KAISER, before the public knew why it was needed. A team at Graz had published it in 2017 as a defence against a different side channel; Dave Hansen and others reworked it into the kernel as Kernel Page Table Isolation, or KPTI. The idea, as LWN described it in November 2017, is to stop sharing: instead of one set of page tables that maps both user and kernel memory for a running process, the kernel keeps two — a full set for when it is running in kernel mode, and a “shadow” set, active while user code runs, that leaves the kernel side almost entirely unmapped. If the kernel is not mapped, a user program cannot speculatively read it, and Meltdown is closed.
The cost is that the processor now has to switch between those two page-table sets on every system call, interrupt and exception — exactly the boundary crossings a busy server does constantly. The kernel developers were blunt about the price: most workloads showed single-digit regressions, “5% is a good round number for what is typical,” and the worst case they saw was “a roughly 30% regression on a loopback networking test that did a ton of syscalls and context switches.” A hardware feature called PCID, which lets the processor avoid flushing its address-translation cache on every switch, brought the typical cost back down, which is why a machine made after about 2017 pays far less for KPTI than an older one. KPTI was rushed into the kernel released that January and backported to the stable series then in support.
Spectre was worse, because it is not one boundary but a whole category, and could not be closed by hiding the kernel. Variant 2 was addressed partly in the kernel and partly by a compiler technique called retpoline, which rewrites indirect jumps so the processor cannot be tricked into speculating down an attacker-chosen path, and partly by new CPU control bits delivered in microcode updates. Variant 1 was handled by adding explicit barriers at the specific places in the kernel where untrusted input met a bounds check. None of this was a single switch; it was years of work spread across the compiler, the kernel and the chips, and it is still going on as new members of the family are found.
What it taught Linux
The hardware is part of the trusted computing base, and it can be wrong. Before 2018, the mental model most developers had was that the CPU was a correct machine that executed their instructions faithfully, and that security was a matter of getting the software right on top of it. Meltdown and Spectre ended that. The abstraction the processor presents — that instructions happen in order, that forbidden ones simply fault — turned out to be a performance-driven illusion with observable seams. Every security boundary Linux enforces, between users, between kernel and user, between virtual machines, ultimately rests on the CPU honouring those boundaries, and the lesson of 2018 is that “the hardware does it” is an assumption to be checked rather than a foundation to build on.
Security and performance are sometimes a real trade, and someone has to decide. For most of Linux’s history, security improvements had been close to free: a bounds check here, a dropped privilege there, nothing you could feel. KPTI was the moment that stopped being true, and the kernel had to ship a mitigation that it knew would slow some workloads by a measurable amount, with a boot-time switch (nopti) for the few operators who understood their threat model well enough to decline it. That pattern — a mitigation that costs something, on by default, with a documented way to turn it off — is now normal, and the family of speculative-execution bugs since has made “which of these mitigations do I actually need?” a genuine engineering question rather than a reflexive “all of them.”
A shared CPU is a shared fate, which is the cloud’s problem too. Spectre’s variant 2 was demonstrated reaching from a guest virtual machine toward the host, and the whole class is most dangerous exactly where untrusting workloads share physical hardware — which is to say, on every public cloud. The response reached past Linux into how multi-tenant infrastructure is built: core scheduling, careful use of hyper-threading, and the microcode-plus-kernel mitigations all exist because “your code and an attacker’s code run on the same silicon” became a threat to take seriously. It is the hardware version of the point the privilege-escalation page makes about containers sharing a kernel: isolation that looks total from inside can be thinner than it appears.
Defence became legible. The quietly important thing Linux built in response was not any single mitigation but the /sys/devices/system/cpu/vulnerabilities/ interface — a standard, readable place where the kernel states, for each known hardware flaw, whether this machine is affected and what it is doing about it. Before it, answering “is my server mitigated?” meant reading changelogs and decoding microcode versions. After it, it is one cat. That shift, from security as something you had to take on faith to something the system reports plainly, is as much a part of the legacy as KPTI itself.
What to check on your machine today
You do not patch Meltdown and Spectre so much as confirm the kernel and the microcode are handling them, and the kernel will tell you if you ask. The one interface worth knowing is the vulnerabilities directory.
grep -r . /sys/devices/system/cpu/vulnerabilities/ 2>/dev/null
lscpu | sed -n '/Vulnerabilit/,$p' # the same information, grouped, with the CPU model
grep -c . /proc/cpuinfo && grep -m1 microcode /proc/cpuinfo # microcode revision in playEach file reads either Not affected, which usually means the silicon is new enough to fix that flaw in hardware; Mitigation: ..., which names what the kernel has turned on; or Vulnerable, which means something is missing — most often a microcode update the firmware has not delivered, or a mitigation disabled at boot. On the machine used for this page meltdown reads Not affected and the Spectre variants read Mitigation:, which is the expected picture for a maintained kernel on a modern Intel part.
uname -r # KPTI and the Spectre mitigations live in the kernel
ls -l /var/run/reboot-required 2>/dev/null # a kernel or microcode update you haven't booted into
dmesg 2>&1 | grep -iE 'pti|page table isolation|spectre|retpoline' # what the kernel enabled at boot (needs privilege)The mitigations are only as current as your kernel and your firmware, and both need a reboot. A Vulnerable line that you did not deliberately choose is usually a sign that a microcode package or a BIOS update is waiting, since the Spectre family depends on CPU control bits that only firmware can deliver — and like the kernel bugs on the previous page, a mitigation that has been installed but not booted into is not protecting anything yet. Keeping the intel-microcode or amd64-microcode package current alongside the kernel, through the routine on Keeping a Server Patched, is the whole of the ongoing maintenance here.
Sources
- meltdownattack.com, the official site for both vulnerabilities — the CVE mapping (Meltdown CVE-2017-5754; Spectre CVE-2017-5753 and CVE-2017-5715), the lists of independent discoverers and their affiliations, the affected-hardware statements (Meltdown on Intel and some ARM; Spectre verified on Intel, AMD and ARM), and the note that the attacks leave no traces in ordinary logs
- Jann Horn, Google Project Zero, “Reading privileged memory with a side-channel”, 3 January 2018 — the report to Intel, AMD and ARM on 1 June 2017, the three variant names and numbers, and the description of cache-timing as the channel that survives mis-speculation
- Google Security Blog, “Today’s CPU vulnerability: what you need to know”, 3 January 2018 — the early publication ahead of the coordinated date of 9 January 2018, and the three-independent-variants framing
- LWN.net, “KAISER: hiding the kernel from user space”, Jonathan Corbet, 15 November 2017 — the page-table-isolation design, its origin in the Graz KAISER paper and Dave Hansen’s rework, and the performance figures (single-digit typical, “5% is a good round number”, worst case “roughly 30%” on a syscall-heavy loopback test)
- The Linux kernel’s Page Table Isolation documentation (docs.kernel.org) — what PTI does, the
CONFIG_MITIGATION_PAGE_TABLE_ISOLATIONoption, thenoptiboot switch, and the role of PCID in reducing its cost - The vulnerabilities directory,
lscpuoutput and CPU model were read on the Ubuntu 24.04 machine (an Intel Xeon) used for this page
Related reading
- Heartbleed, Shellshock, regreSSHion and the privilege-escalation decade — the rest of this series
- The Life of a System Call — the kernel-boundary crossing that KPTI made more expensive, stage by stage
- Permissions and Privilege — the boundaries these attacks read across, and what enforces them
- Keeping a Server Patched — keeping the microcode package current alongside the kernel, which is the maintenance this bug class needs
- What Ships in Your Container Image — why a shared CPU, like a shared kernel, is a shared fate
- The Morris worm — the last page in the series, and the 1988 origin of the habits the other five keep returning to

