Re: [RFC PATCH 2/2] x86/ibpb: Prevent missed IBPB flush

From: David Woodhouse
Date: Thu Jan 25 2018 - 03:20:17 EST


On Wed, 2018-01-24 at 16:36 -0800, Tim Chen wrote:
> It is possible that the last uesr mm that we recorded for a cpu was
> released, and a new mm with identical address was allocated when we
> check it again. We could skip IBPB flush here for the process with
> the new mm.
>
> It is a difficult to exploit case as we have to exit() a process on a
> cpu, free the mm, and fork() the victim to use the mm pointer on that
> cpu. The exploiter needs the old mm to get recycled to the
> newly forked process and no other processes run on the target cpu.

That's what it takes to have the victim process leak information into
the cache. In order to *harvest* that information, the attacker must
then get run on the same CPU again? And since her first process had to
exits, as described above, she needs a new process for that?

I confess, with all the other wildly theoretical loopholes that exist,
I wasn't losing much sleep over this one.

> Nevertheless, the patch below is one way to close this hole by
> adding a ref count to prevent the last user mm from being released.
> It does add ref counting overhead, and extra memory cost of keeping an mm
> (though not the VMAs and most of page tables) around longer than we will
> otherwise need to. Any better solutions are welcomed.

This has no upper bound on the amount of time the user mm gets held,
right? If a given CPU remains idle for ever (and what happens if it's
taken offline?) we'll never do that mmdrop() ?

Attachment: smime.p7s
Description: S/MIME cryptographic signature