tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: meltdown
> On Jan 4, 2018, at 6:01 PM, Warner Losh <imp%bsdimp.com@localhost> wrote:
>
>
>
> On Thu, Jan 4, 2018 at 2:58 PM, Mouse <mouse%rodents-montreal.org@localhost> wrote:
> > As I understand it, on intel cpus and possibly more, we'll need to
> > unmap the kernel on userret, or else userland can read arbitrary
> > kernel memory.
>
> "Possibly more"? Anything that does speculative execution needs a good
> hard look, and that's damn near everything these days.
>
> > Also, I understand that to exploit this, one has to attempt to access
> > kernel memory a lot, and SEGV at least once per bit.
>
> I don't think so. Traps that would be taken during normal execution
> are not taken during speculative execution. The problem is, to quote
> one writeup I found, "Intel CPUs are allowed to access kernel memory
> when performing speculative execution, even when the application in
> question is running in user memory space. The CPU does check to see if
> an invalid memory access occurs, but it performs the check after
> speculative execution, not before.". This means that things like cache
> line loads can occur based on values the currently executing process
> should not be able to access; timing access to data that cache-collides
> with the cache lines of interest reveals the leaked bit(s).
>
> Nowhere in there is a SEGV generated.
>
> That's the meltdown stuff. Spectre targets other things (I've seen
> branch prediction mentioned) to leak information around protection
> barriers.
>
> I think you are confusing spectre and meltdown.
>
> meltdown requires a sequence like:
>
> exception (*0 = 0 or a = 1 / 0);
> do speculative read
>
> to force a trip into kernel land just before the speculative read so that otherwise not readable stuff gets (or does not get) read into cache which can then be probed for data.
No, that's not correct. You were being mislead by the "Toy example".
The toy example demonstrates that speculative operation are done
after the point in the code that generates an exception, but it in
itself is NOT the exploit.
The exploit has the form:
x = read(secret_memory_location);
touch (cacheline[x]);
while (1) ;
The first line will SEGV, of course, but in the vulnerable CPUs
the speculative load is issued before that happens. And also before
the SEGV happens, cacheline[x] is touched, making that line resident
in the cache. This "transmits to the side channel".
Next, the SEGV happens. The exploit catches that, and then it
does a timing test on references to cacheline[i] to see which i is
now resident. That i is the value of x.
As the paper points out, it would be possible in principle to prefix
the exploit with
if (false) // predict_true
so the illegal read is also speculative, and is voided (exception
and all) when the wrong branch prediction is sorted out. But it
looks like the paper is saying that refinement has not been
demonstrated, though such branch prediction hacks have been shown
in other exploits. Still, if that can be done, a test for
"SEGV too often" is no help.
The Meltdown paper clearly says that the KAISER fix cures this
vulnerability. And while it doesn't say so, it is also clear that
the problem does not exist on CPUs where speculative memory references
do page protection checks.
All the above applies to Meltdown. Spectre is unrelated in its
core mechanism. The fact that both eventually end up using side
channels and were published at the same time seems to have caused
some confusion between the two. It is important to understand they
are independent, stem from different underlying problems, apply
to a different set of vulnerable chips, and have different cures.
paul
Home |
Main Index |
Thread Index |
Old Index