News for hackers. Stuff that matters.
Re:Spectre/Meltdown Pits Transparency Against Liability by tomc1985 on Thursday February 01, 2018 @01:56PM (#16284611)
Halfway through he notes how processors have millions of transistors, each being slightly different, and notes how we are just soooo lucky to have found a hardware bug now.

Except both Spectre and Meltdown, AFAIK (IANAHWE) are design flaws as the silicon is working as intended. The hardware is fine -- the real problem is that the Intel's reputation is partially built on speed, and, now that the cladding has fallen off, we've discovered the platform was built with really flimsy supports.

Re:Spectre/Meltdown Pits Transparency Against Liability by avianlyric on Thursday February 01, 2018 @04:35PM (#16286137)
> Halfway through he notes how processors have millions of transistors, each being slightly different, and notes how we are just soooo lucky to have found a hardware bug now.

I read that as the other way around. He says:

> We should all be more surprised that it took so long for a major hardware bug to be found, than the fact that one was ever found.

Which I would read as, "it's surprising we don't discover bugs in hardware more often".

I would also say, that in the world of embedded devices, HW bugs in silicon are the norm, and your chips come with some form of errata.

Re:Spectre/Meltdown Pits Transparency Against Liability by monocasa on Thursday February 01, 2018 @04:37PM (#16286165)
And it's not just embedded devices. AMD and Intel put out tons of errata too.
Re:Spectre/Meltdown Pits Transparency Against Liability by monocasa on Thursday February 01, 2018 @03:16PM (#16285453)
IDK, I think there's a way to have your cake and eat it too WRT chip level optimizations.

For instance brushing off rings 1 and 2 from the dust bin of history could give user and kernel code ways to describe multiple levels of memory protection in a way that the chip can understand. That way, the same way that AMD was protected from Meltdown ("I can tell from the TLB that address is outside of what this code is supposed to touch, so I'm not going to speculate past that") could be expanded to a more general form.

Re:Spectre/Meltdown Pits Transparency Against Liability by tomc1985 on Thursday February 01, 2018 @04:18PM (#16286004)
I didn't even know rings 1 and 2 were even relegated to the dustbin.... so everything is ring 0 now??

Which brings me to another something I don't understand about this. If mispredictions leave their calculations in cache why can't that cached data be cleared after the branch is determined to be bad?

Re:Spectre/Meltdown Pits Transparency Against Liability by monocasa on Thursday February 01, 2018 @04:30PM (#16286090)
> I didn't even know rings 1 and 2 were even relegated to the dustbin.... so everything is ring 0 now??

It's all either ring 3 (user) or ring 0 (kernel) for the purposes of this discussion. The biggest architectural impediment is the single bit for ring selection in page table entries. And since long mode requires paging, there's currently not a way to select rings 1 and 2.

Although you might be able to play with some of the hypervisor extensions to give you guest ring 0 context inside a regular user process... See Akaros for a good example of what that looks like.

> Which brings me to another something I don't understand about this. If mispredictions leave their calculations in cache why can't that cached data be cleared after the branch is determined to be bad?

Because the cache is a fixed size, and that just kicks the can down the road. You'll just test for the eviction in your exploit instead.

Re:Spectre/Meltdown Pits Transparency Against Liability by CamperBob2 on Thursday February 01, 2018 @04:45PM (#16286223)
If mispredictions leave their calculations in cache why can't that cached data be cleared after the branch is determined to be bad?

"Clearing the cached data" is just as detectable as caching the data in the first place. You'd have to treat the line fill as a transaction that could be rolled back. Unfortunately, transactional memory and CPU caches lie at polar-opposite ends of the performance spectrum.

Re:Spectre/Meltdown Pits Transparency Against Liability by caf on Thursday February 01, 2018 @09:41PM (#16287961)
You don't have to roll it back, you could have speculated loads store into a speculation buffer rather than directly into the cache, then at retirement the spec buffer entry is committed to the cache.
Re:Spectre/Meltdown Pits Transparency Against Liability by CamperBob2 on Thursday February 01, 2018 @10:19PM (#16288137)
Perhaps, but isn't the time taken by the line fill ultimately what's leaking the information? Sure, it's probed by monitoring L1 eviction, but I'd still be nervous about the timing.

IMHO the only safe way to do a fetch from prohibited memory is to not do it at all.

Re:Spectre/Meltdown Pits Transparency Against Liability by caf on Thursday February 01, 2018 @10:48PM (#16288261)
No, you can't time what happens on the mis-speculated path itself. What's leaking the information is the change to the cache state which is observable after the original mis-speculated branch is resolved (by timing subsequent accesses to addresses that alias in the cache).

You can also observe changes to the TLB state, though - so you'd have to do the same buffering-and-commit dance there as well.

Maybe you can also leak data through the BTB or RTB (double-Spectre!), or by tieing up particular execution units conditionally which is observable by a sibling hyperthread?

Re:Spectre/Meltdown Pits Transparency Against Liability by rayiner on Thursday February 01, 2018 @04:28PM (#16286073)
How would ring 1 and ring 2 help? The PTE has a supervisor bit saying that pages are mapped but not accessible outside ring 0 code. That information cached in the TLB. Intel’s problem is that it speculatively executes memory instructions before checking this bit.
Re:Spectre/Meltdown Pits Transparency Against Liability by monocasa on Thursday February 01, 2018 @04:36PM (#16286151)
Right, it totally wouldn't help current Intel processors. This is totally a future microarchtectural change. Also, there's not really a way to use Rings 1 and 2 in long mode since long mode requires paging to be enabled and the PTEs only have the one bit for ring selection.

But (given the idea that we're talking about future chips) it could help describe protection boundaries in a finer grain way to protect against Spectre in the same way that AMD is protected against Meltdown.

The main issue with spectre (in a long term sense) is that the CPU really has no way of understanding that you're running lower privileged code in a higher context, whether that be BPF in the kernel, or JS in the browser. IMO, we're going to be fighting the same battle over and over again as the all of the mitigations so far are heavily microarchitecure specific.

Re:Spectre/Meltdown Pits Transparency Against Liability by pdpi on Thursday February 01, 2018 @04:52PM (#16286266)
BPF in the kernel was just for the sake of expediency. The point is that the BPF code shows a somewhat common pattern that real kernel code also uses. The “real” exploit is finding a syscall that falls into that pattern somewhere
Re:Spectre/Meltdown Pits Transparency Against Liability by monocasa on Thursday February 01, 2018 @06:23PM (#16286911)
Absolutely. There's memory unsafety bugs that'll allow you to ROP, and probably otherwise valid code that doesn't need unsafety that'll speculatively hit user memory in current kernels.

But in the context of trends, we're moving towards User^Kernel memory mapping with features SMAP. That idea combined with kernel changes to holistically enforce separation boundaries more effectively along with cache partitioning AFAICT leads to potential end game win on this front.

Edit: And to be totally up front my major side project is adding a BPF/seccomp esque virtual machine into a formally verified kernel, so my head is in that space.

Re:Spectre/Meltdown Pits Transparency Against Liability by rayiner on Thursday February 01, 2018 @04:39PM (#16286178)
Ah okay I get it.
Re:Spectre/Meltdown Pits Transparency Against Liability by samstave on Thursday February 01, 2018 @02:48PM (#16285197)
Can you please unpack "really flimsy supports" in ELI5 language? I dont get that part of your comment - though I was surprised IN understood your "I am not a hardware engineer" fluidly...

But define "flimsy supports"

Re:Spectre/Meltdown Pits Transparency Against Liability by username223 on Thursday February 01, 2018 @03:16PM (#16285451)
> Can you please unpack "really flimsy supports" in ELI5 language?

Modern CPUs rely upon "speculative execution" for speed, i.e. running code that they guess will be run. This usually works, but relies upon the CPU getting rid of the results of its incorrect guesses. Intel CPUs failed to do this in a very obvious way, which was recently exploited. As a result, they broke software security checks.

EDIT: Let's say your code is

    if (security_check()) {
      secure_stuff();
    } else {
      error();
    }
The Intel CPU may guess that security_check() will return true, and run secure_stuff(). When security_check() actually returns false, it doesn't clean up all of the results of running secure_stuff(), so error() can spy on what it would have done if security_check() returned true.
Re:Spectre/Meltdown Pits Transparency Against Liability by rayiner on Thursday February 01, 2018 @04:38PM (#16286168)
“Results” is a loaded term. In computation, “results” means the return value of a computation. Intel does keep you from observing the result of secure_stuff. What it doesn’t do is clean up all the side effects.
Re:Spectre/Meltdown Pits Transparency Against Liability by pdpi on Thursday February 01, 2018 @04:58PM (#16286315)
Speculative execution modifies observable state. What you call it is imaterial.
Re:Spectre/Meltdown Pits Transparency Against Liability by dfox on Thursday February 01, 2018 @05:17PM (#16286449)
The point there is that what spectre/meltdown exploits are sideffects that are not part of the architectural state as it is specified by any manufacturer. The whole issue points to the fact that security-wise the typical approach used for descriptions of CPU's architectural behavior is insufficient as there can be implementation-specific observable sideeffects that have security ramifications.
Re:Spectre/Meltdown Pits Transparency Against Liability by rayiner on Thursday February 01, 2018 @05:01PM (#16286339)
Words have meaning. The “result” of a computation is different from side effects. The distinction is important. Speculative execution will always modify “observable state.” E.g. power usage.
Re:Spectre/Meltdown Pits Transparency Against Liability by mannykannot on Thursday February 01, 2018 @06:10PM (#16286841)
'Results' and 'side-effects' are useful modifiers of 'modifies observable state', and the long-overlooked fact that the latter falls into the category is an important insight. I think you would find it very difficult to explain the problem or discuss possible solutions without making additional distinctions, beyond 'modifies observable state', with regard to what speculative execution does.
Re:Spectre/Meltdown Pits Transparency Against Liability by gjjfdg on Thursday February 01, 2018 @08:35PM (#16287643)
ELI5 is an internet acronym for "Explain like I'm five (years old)". In this example, "secure_stuff" may well be a call to a function that does not return any value. Some functions are like that. But if it isn't, we no longer are sure that the code in the else branch of the loop won't be able to deduce what would be returned as the result, thanks to Intel, no thanks to Intel.

Shame on you.

Re:Spectre/Meltdown Pits Transparency Against Liability by dang on Friday February 02, 2018 @01:50AM (#16288888)
Personal attacks are not allowed on HN and we ban accounts that do this. Please post civilly and substantively, or not at all.

https://news.ycombinator.com/newsguidelines.html

Re:Spectre/Meltdown Pits Transparency Against Liability by steiger on Thursday February 01, 2018 @02:55PM (#16285264)
Intel valued speed optimizations that are inherently insecure.
Re:Spectre/Meltdown Pits Transparency Against Liability by samstave on Thursday February 01, 2018 @06:22PM (#16286907)
ah.

Hmm.

I worked at intel in the 90s... Ran the game lab - when they came out with the Celeron, they created SIMD instructions - and they paid (bribed) game companies to optimize their games against the instruction set - fofr $1MM in marketing bonuses.... (i.e. "play gameX on intels celeron based PCs and achieve X% performance gain")

And all of this was to prove that they could produce a <$1,000 machine that a consumer would want (the basis of the celeron proc)

Re:Spectre/Meltdown Pits Transparency Against Liability by tomc1985 on Thursday February 01, 2018 @04:17PM (#16285996)
I am referring to their flawed implementation of speculative execution, with respect to how much of today's CPU performance is due to it.
Re:Spectre/Meltdown Pits Transparency Against Liability by MaxBarraclough on Friday February 02, 2018 @04:49AM (#16289488)
> Intel's reputation is partially built on speed

Except the Spectre vulnerability isn't specific to Intel's chips.