Messages in this thread | | | Subject | Re: [PATCH] x86/speculation: Use Indirect Branch Prediction Barrier in context switch | From | Tim Chen <> | Date | Tue, 30 Jan 2018 13:03:20 -0800 |
| |
On 01/30/2018 12:38 PM, Borislav Petkov wrote: > On Mon, Jan 29, 2018 at 10:04:47PM +0000, David Woodhouse wrote: >> + if (tsk && tsk->mm && >> + tsk->mm->context.ctx_id != last_ctx_id && >> + get_dumpable(tsk->mm) != SUID_DUMP_USER) >> + indirect_branch_prediction_barrier(); > > Ok, so while staring at this, someone just came up with the following > sequence: > > 1. Malicious process runs with UID=A, does BTB poisoning > 2. Sensitive process (e.g. gpg) starts also with UID=A, no IBPB flush occurs since task is initially dumpable > 3. gpg now does prctl(PR_SET_DUMPABLE, ...) to clear the dumpable flag > 4. gpg now does sensitive stuff that it thinks is protected > 5. gpg does indirect branches that shouldn't be influenced by the malicious process > > Now, if you switch between steps 3. and 4., you're good because gpg > became non-dumpable. But if you *don't* switch, the bad BTB entries are > still there.
The attacker has to guarantee itself to run right before victim. And the window of attack is very small, as only the first context switch to victim may be vulnerable. The victim will be immune on the next switch. For timing attack, the attacker needs to scan one bit at a time. So probably the attacker could glean 1 bit of information on the switch back to the attacker and then the attacker could not scan further. So it doesn't seem to be very practical attack if the victim has set itself to be non-dumpable.
Tim
> > So, *actually*, we need to flush IBPB in set_dumpable() too, when we > clear SUID_DUMP_USER. > > Or, are we missing something obvious here and that is not needed because > of reasons I haven't thought about? > > I know, gpg doesn't do prctl() but disables core dumping with > setrlimit() but there might be other processes who do that... > > Thx. >
| |