All of lore.kernel.org
 help / color / mirror / Atom feed
* [MODERATED] Generic eBPF hardening
@ 2018-05-17 20:55 Dave Hansen
  2018-05-17 22:22 ` [MODERATED] " Alexei Starovoitov
  0 siblings, 1 reply; 9+ messages in thread
From: Dave Hansen @ 2018-05-17 20:55 UTC (permalink / raw)
  To: speck

[-- Attachment #1: Type: text/plain, Size: 1349 bytes --]

I'm hoping Alexei is on the list now.

Andi Kleen and I were talking about ways to generally harden eBPF.  We
were a bit concerned that eBPF could leave around attacker-controlled
values on the stack that might allow later, speculatively-executed
kernel code to be exploited.

One thing I wanted to clarify: The eBPF stack (BPF_REG_FP) *is* the
kernel stack, correct?  I see this code getting generated by
emit_prologue(), for instance:

>         /* sub rsp, rounded_stack_depth + AUX_STACK_SPACE */
>         EMIT3_off32(0x48, 0x81, 0xEC,
>                     round_up(stack_depth, 8) + AUX_STACK_SPACE);

Or does that only apply to the JIT?

One cheap, simple, mitigation for that would be to zero any kernel stack
that could have eBPF data in it during BPF_EXIT.  I guess we could do
that after the 'leave' but before the 'ret' in the x86 JIT.

We could also zero out all of the eBPF contents in the hardware
registers at this point.  That would help reduce the gadgets in the
kernel that could be exploited.

For speculative store bypass, specifically, would it make sense to do an
MFENCE at BFP_EXIT for unprivileged programs that do writes to the
stack?  That way, the result of any BPF stores will be known before we
start running kernel code again.

We would not need any of these for privileged programs.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-05-18 22:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-17 20:55 [MODERATED] Generic eBPF hardening Dave Hansen
2018-05-17 22:22 ` [MODERATED] " Alexei Starovoitov
2018-05-17 22:54   ` Andi Kleen
2018-05-17 23:21     ` Alexei Starovoitov
2018-05-17 23:39       ` Andi Kleen
2018-05-18 18:18       ` Dave Hansen
2018-05-18 22:26         ` Alexei Starovoitov
2018-05-17 23:13   ` Dave Hansen
2018-05-17 23:24     ` Alexei Starovoitov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.